-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Improve diagnostics for wrongly ordered keywords in function declaration #87235
Conversation
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the code changes as they are right now. The test failures seem to indicate there are a fair number of effects on other diagnostics so those need to be reviewed still (which I can do after the ui test outputs are blessed)
src/test/ui/parser/issue-87217-keyword-order/wrong-unsafe copy.rs
Outdated
Show resolved
Hide resolved
c7793a6
to
99097d4
Compare
I reverted the changes to I would still like to change |
This comment has been minimized.
This comment has been minimized.
99097d4
to
1be06cc
Compare
I tried to write a more precise |
@rustbot label -S-waiting-on-author +S-waiting-on-review |
This comment has been minimized.
This comment has been minimized.
I don't understand how my changes could have broken those tests. I can't run them locally too, they're always ignored and I see no way to force run them. |
☔ The latest upstream changes (presumably #87434) made this pull request unmergeable. Please resolve the merge conflicts. |
1be06cc
to
0212a09
Compare
This comment has been minimized.
This comment has been minimized.
0212a09
to
ad3d233
Compare
// Qualifier keywords ordering check | ||
|
||
// This will allow the machine fix to directly place the keyword in the correct place | ||
let current_qual_sp = if self.check_keyword(kw::Const) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading this correctly, we will trigger the diagnostic here below for code that has duplicate keywords, such as e.g. in
const async const fn
and I believe that the machine applicable suggestion will suggest a const const async fn
which is invalid.
It may not be critical to fix this now in this PR, but could you please at least add a test for that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I will add a test for it.
pub pub fn test() {}
already behaves like that and has a MachineApplicable
fix, I think it is because it is expected to sometimes misplace keywords but repeating them is not something that happens often so it should be okay ? I can try to fix it in this PR or open another issue+PR combo, I don't know what's best here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this must be fixed in this PR, but I would consider that a bug.
910096a
to
eabf19b
Compare
Please squash the commits a little so that its 1 or 2 commits. |
After this commit, `unsafe async fn ...` now suggests the `async unsafe` fix instead of misunderstanding the issue. This is not perfect for repeated keywords (`const async const`) and for keywords that are misplaced after `extern "some abi"` because of the way `check_fn_font_matter` works, but changing it breaks so many tests and diagnostics it has been judged too high a cost for this PR.
eabf19b
to
690cbb7
Compare
@bors r+ |
📌 Commit 690cbb7 has been approved by |
☀️ Test successful - checks-actions |
…compiler-errors Improve `extern "<abi>" unsafe fn()` error message These errors were already reported in rust-lang#87217, and fixed by rust-lang#87235 but missed the case of an explicit ABI. This PR does not cover multiple keywords like `extern "C" pub const unsafe fn()`, but I don't know what a good way to cover this would be. It also seems rarer than `extern "C" unsafe` which I saw happen a few times in workshops.
…compiler-errors Improve `extern "<abi>" unsafe fn()` error message These errors were already reported in rust-lang#87217, and fixed by rust-lang#87235 but missed the case of an explicit ABI. This PR does not cover multiple keywords like `extern "C" pub const unsafe fn()`, but I don't know what a good way to cover this would be. It also seems rarer than `extern "C" unsafe` which I saw happen a few times in workshops.
…compiler-errors Improve `extern "<abi>" unsafe fn()` error message These errors were already reported in rust-lang#87217, and fixed by rust-lang#87235 but missed the case of an explicit ABI. This PR does not cover multiple keywords like `extern "C" pub const unsafe fn()`, but I don't know what a good way to cover this would be. It also seems rarer than `extern "C" unsafe` which I saw happen a few times in workshops.
Rollup merge of rust-lang#128229 - tdittr:unsafe-extern-abi-error, r=compiler-errors Improve `extern "<abi>" unsafe fn()` error message These errors were already reported in rust-lang#87217, and fixed by rust-lang#87235 but missed the case of an explicit ABI. This PR does not cover multiple keywords like `extern "C" pub const unsafe fn()`, but I don't know what a good way to cover this would be. It also seems rarer than `extern "C" unsafe` which I saw happen a few times in workshops.
Fix #87217
@rustbot label A-diagnostics T-compiler