-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recover from incorrectly ordered/duplicated function keywords
- Loading branch information
Showing
14 changed files
with
136 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/ui/parser/issues/issue-87217-keyword-order/recovery.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// test for #115714 | ||
|
||
struct Misplaced; | ||
|
||
impl Misplaced { | ||
unsafe const fn from_u32(val: u32) {} | ||
//~^ ERROR expected one of `extern` or `fn` | ||
fn oof(self){} | ||
} | ||
|
||
struct Duplicated; | ||
|
||
impl Duplicated { | ||
unsafe unsafe fn from_u32(val: u32) {} | ||
//~^ ERROR expected one of `extern` or `fn` | ||
fn oof(self){} | ||
} | ||
|
||
fn main() { | ||
Misplaced.oof(); | ||
Duplicated.oof(); | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/ui/parser/issues/issue-87217-keyword-order/recovery.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
error: expected one of `extern` or `fn`, found keyword `const` | ||
--> $DIR/recovery.rs:6:12 | ||
| | ||
LL | unsafe const fn from_u32(val: u32) {} | ||
| -------^^^^^ | ||
| | | | ||
| | expected one of `extern` or `fn` | ||
| help: `const` must come before `unsafe`: `const unsafe` | ||
| | ||
= note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` | ||
|
||
error: expected one of `extern` or `fn`, found keyword `unsafe` | ||
--> $DIR/recovery.rs:14:12 | ||
| | ||
LL | unsafe unsafe fn from_u32(val: u32) {} | ||
| ^^^^^^ | ||
| | | ||
| expected one of `extern` or `fn` | ||
| help: `unsafe` already used earlier, remove this one | ||
| | ||
note: `unsafe` first seen here | ||
--> $DIR/recovery.rs:14:5 | ||
| | ||
LL | unsafe unsafe fn from_u32(val: u32) {} | ||
| ^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters