Skip to content

parser: unsafe block should expect { as well #37158

New issue

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

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

Already on GitHub? # to your account

Closed
liigo opened this issue Oct 14, 2016 · 1 comment
Closed

parser: unsafe block should expect { as well #37158

liigo opened this issue Oct 14, 2016 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@liigo
Copy link
Contributor

liigo commented Oct 14, 2016

fn main() {
    unsafe // {
        std::mem::transmute::<f32, u32>(1.0);
    // }
}
error: expected one of `extern` or `fn`, found `std`
 --> <anon>:3:9
  |
3 |         std::mem::transmute::<f32, u32>(1.0);
  |         ^^^

error: aborting due to previous error
@eddyb
Copy link
Member

eddyb commented Oct 14, 2016

This is because it's not parsing an unsafe block but a nested function.
A bit weird, not sure there's a nice way to reconcile them.

@Mark-Simulacrum Mark-Simulacrum added the A-parser Area: The lexing & parsing of Rust source code to an AST label May 14, 2017
@Mark-Simulacrum Mark-Simulacrum added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 22, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 24, 2018
…ikomatsakis

When encountering invalid token after `unsafe`, mention `{`

Fix rust-lang#37158.
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 24, 2018
…ikomatsakis

When encountering invalid token after `unsafe`, mention `{`

Fix rust-lang#37158.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

3 participants