Skip to content

Terse parse error on &raw expr #133231

Closed
@sadmac7000

Description

@sadmac7000

I tried this code:

mod foo {
    pub static A: i32 = 0;
    pub static B: i32 = 0;
    pub static C: i32 = 0;
}


fn main() {
    let _arr = [ &raw foo::A, &raw foo::B, &raw foo::C ];
}

I expected to see this happen: Code compiles normally

Instead, this happened: A parser error.

error: expected one of `!`, `,`, `.`, `::`, `;`, `?`, `]`, `{`, or an operator, found `foo`
 --> src/main.rs:9:23
  |
9 |     let _arr = [ &raw foo::A, &raw foo::B, &raw foo::C ];
  |                       ^^^ expected one of 9 possible tokens

Meta

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 19.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTA-raw-pointersArea: raw pointers, MaybeUninit, NonNullD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.F-raw_ref_op`#![feature(raw_ref_op)]`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