Skip to content

nested tuple field access in offset_of gets parsed as float #112204

Closed
@lukas-code

Description

@lukas-code

I tried this code: playground

#![feature(offset_of)]
#![feature(builtin_syntax)]

use std::mem::offset_of;

fn main() {
    let _ = (((), ()), ()). 0.0; // OK
    let _ = offset_of!((((), ()), ()), 0 .0); // OK
    let _ = offset_of!((((), ()), ()), 0.0); // ERROR
    let _ = builtin # offset_of((((), ()), ()), 0.0); // still ERROR
}

I expected to see this happen: It compiles, because offset_of allows nested field access in general and regular field access works with "float" tokens.

Instead, this happened: Compile error:

error: expected identifier, found `0.0`
  --> src/main.rs:10:49
   |
10 |     let _ = builtin # offset_of((((), ()), ()), 0.0); // still ERROR
   |                                                 ^^^ expected identifier

error: expected identifier, found `0.0`
 --> src/main.rs:9:40
  |
9 |     let _ = offset_of!((((), ()), ()), 0.0); // ERROR
  |                                        ^^^ expected identifier

Meta

rustc --version --verbose:

playground 1.72.0-nightly (2023-06-01 d59363ad0b6391b7fc5b)

@rustbot label F-offset_of

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-offset_of`#![feature(offset_of)]`

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions