forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error message for
extern "C" unsafe fn()
This was handled correctly already for `extern unsafe fn()`. Co-authored-by: Folkert <[email protected]>
- Loading branch information
1 parent
33dd288
commit 3fdc991
Showing
5 changed files
with
30 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
trait T { | ||
extern "Rust" unsafe fn foo(); | ||
//~^ ERROR expected `{`, found keyword `unsafe` | ||
//~^ ERROR expected `fn`, found keyword `unsafe` | ||
//~| NOTE expected `fn` | ||
//~| HELP `unsafe` must come before `extern "Rust"` | ||
//~| SUGGESTION unsafe extern "Rust" | ||
//~| NOTE keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` | ||
} | ||
|
||
fn main() {} |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
error: expected `{`, found keyword `unsafe` | ||
error: expected `fn`, found keyword `unsafe` | ||
--> $DIR/issue-19398.rs:2:19 | ||
| | ||
LL | trait T { | ||
| - while parsing this item list starting here | ||
LL | extern "Rust" unsafe fn foo(); | ||
| ^^^^^^ expected `{` | ||
LL | | ||
LL | } | ||
| - the item list ends here | ||
| --------------^^^^^^ | ||
| | | | ||
| | expected `fn` | ||
| help: `unsafe` must come before `extern "Rust"`: `unsafe extern "Rust"` | ||
| | ||
= note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` | ||
|
||
error: aborting due to 1 previous error | ||
|
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
9 changes: 7 additions & 2 deletions
9
tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe-abi.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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
error: expected `{`, found keyword `unsafe` | ||
error: expected `fn`, found keyword `unsafe` | ||
--> $DIR/wrong-unsafe-abi.rs:9:12 | ||
| | ||
LL | extern "C" unsafe fn test() {} | ||
| ^^^^^^ expected `{` | ||
| -----------^^^^^^ | ||
| | | | ||
| | expected `fn` | ||
| help: `unsafe` must come before `extern "C"`: `unsafe extern "C"` | ||
| | ||
= note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` | ||
|
||
error: aborting due to 1 previous error | ||
|