-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
struct Thing {}
impl Thing {
unsafe const fn from_u32(val: u32) -> Self {
Self {}
}
fn oof(self) -> u32 {
0
}
}
fn main() {
Thing {}.oof();
}
Current output
error: expected one of `extern` or `fn`, found keyword `const`
--> src/main.rs:4:12
|
3 | impl Thing {
| - while parsing this item list starting here
4 | unsafe const fn from_u32(val: u32) -> Self {
| -------^^^^^
| | |
| | expected one of `extern` or `fn`
| help: `const` must come before `unsafe`: `const unsafe`
...
11 | }
| - the item list ends here
|
= note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`
error[[E0599]](https://doc.rust-lang.org/stable/error_codes/E0599.html): no method named `oof` found for struct `Thing` in the current scope
--> src/main.rs:14:14
|
1 | struct Thing {}
| ------------ method `oof` not found for this struct
...
14 | Thing {}.oof();
| ^^^ method not found in `Thing`
For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground` (bin "playground") due to 2 previous errors
Desired output
The compiler should understand that I just got the keyword order wrong, and recover-parse appropriately, instead of losing track of all methods in the impl.
Rationale and extra context
No response
Other cases
No response
Anything else?
No response
KisaragiEffective
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.