Closed
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