Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lukas-code opened this issue Jun 2, 2023 · 0 comments · Fixed by #112216
Closed

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

lukas-code opened this issue Jun 2, 2023 · 0 comments · Fixed by #112216
Assignees
Labels
C-bug Category: This is a bug. F-offset_of `#![feature(offset_of)]`

Comments

@lukas-code
Copy link
Member

lukas-code commented Jun 2, 2023

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

@lukas-code lukas-code added the C-bug Category: This is a bug. label Jun 2, 2023
@rustbot rustbot added the F-offset_of `#![feature(offset_of)]` label Jun 2, 2023
@est31 est31 self-assigned this Jun 2, 2023
@bors bors closed this as completed in 43062c4 Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-offset_of `#![feature(offset_of)]`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants