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

Bad parse error on token sequences safe unsafe and unsafe safe (before extern fns) #133630

Closed
ionicmc-rs opened this issue Nov 29, 2024 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-edition-2024 Area: The 2024 edition A-parser Area: The parsing of Rust source code to an AST D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ionicmc-rs
Copy link
Contributor

ionicmc-rs commented Nov 29, 2024

Code

safe unsafe extern "C" fn foo() {
   // ...
}

Current output

help: unsafe comes before safe: `unsafe safe`

Desired output

error: safe is invalid outside of `unsafe extern` blocks
help: extern functions are safe by default

Rationale and extra context

this is a follow-up to my previous issue #133586, for more info you can visit it or see the PR (#133618 (closed))

Other cases

unsafe safe extern "C" fn foo() {} // safe is recognised as an identifier, and suggests putting a block around it

Rust Version

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

Anything else?

The same happens with nightly releases

@ionicmc-rs ionicmc-rs added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 29, 2024
@jieyouxu jieyouxu added A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug. A-edition-2024 Area: The 2024 edition D-confusing Diagnostics: Confusing error or lint that should be reworked. labels Dec 7, 2024
@fmease fmease changed the title follow up issue to #133586 (Safe keyword undescriptive errors) Bad parse error on sequences safe unsafe and unsafe safe Dec 20, 2024
@fmease fmease removed the C-bug Category: This is a bug. label Dec 20, 2024
@fmease fmease changed the title Bad parse error on sequences safe unsafe and unsafe safe Bad parse error on token sequences safe unsafe and unsafe safe (on extern fns) Dec 20, 2024
@fmease fmease changed the title Bad parse error on token sequences safe unsafe and unsafe safe (on extern fns) Bad parse error on token sequences safe unsafe and unsafe safe (before extern fns) Dec 20, 2024
@ionicmc-rs
Copy link
Contributor Author

This issue has been combined into one with #133586 at #134580

@ionicmc-rs ionicmc-rs closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2024
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-edition-2024 Area: The 2024 edition A-parser Area: The parsing of Rust source code to an AST D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants