Skip to content
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

parser: unsafe block should expect { as well #37158

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 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 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The 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