Skip to content

MetaItem fails to parse global paths #53048

Closed

Description

@djrenren
#[my_attr(::foo::bar)]

Does not parse as a MetaItemKind::List if the first element begins with a ::. If you remove the leading :: it parses correctly.

Activity

  1. added
    A-attributesArea: Attributes (`#[…]`, `#![…]`)
    A-parserArea: The lexing & parsing of Rust source code to an AST
    on Jan 27, 2019
  2. Enselic commented on Nov 16, 2023

    @Enselic
    Member

    Triage: Can you give complete reproduction steps please? Ideally something to copy-paste into the terminal that reproduces the problem. Thanks!

  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Nov 16, 2023
  4. fmease commented on Aug 15, 2025

    @fmease
    Member

    I'm assuming they referred to something like:

    macro_rules! accept { (#[$meta:meta]) => {}; }
    
    accept!(#[my_attr(::foo::bar)]);

    Looking at the date of submission, 2018-08-04, I first assumed that they must've used version 1.28 (released: 2018-07-30) but I couldn't repro it there. Then I randomly chose 1.25 (released: 2018-03-25) and bingo!

    In 1.25, the code I've posted above fails with:

    error: expected unsuffixed literal or identifier, found ::
     --> file.rs:5:19
      |
    5 | accept!(#[my_attr(::foo::bar)]);
      |                   ^^
    

    and in 1.28 and on nightly, it passes.

  5. fmease commented on Aug 15, 2025

    @fmease
    Member

    Next, grepping for #\[\w+\(:: in tests/ I found

    tests/ui/macros/meta-item-absolute-path.rs
    1:#[derive(::Absolute)] //~ ERROR failed to resolve
    

    So we have a test for that, kinda.

  6. fmease commented on Aug 16, 2025

    @fmease
    Member

    We might have better tests for this but I don't want to "grep around" rn. Tentatively tagging with E-needs-test but it might not need one, needs investigation first.

  7. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Aug 16, 2025
  8. KevinA-cpu commented on Aug 20, 2026

    @KevinA-cpu
    Contributor

    @rustbot claim

  9. added a commit that references this issue on Oct 9, 2026
    5e803f2
  10. added a commit that references this issue on Oct 10, 2026
    e9fa184
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions