-
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.
Rollup merge of #113350 - chenyukang:yukang-fix-113342-parser, r=comp…
…iler-errors Fix the issue of wrong diagnosis for extern pub fn Fixes #113342
- Loading branch information
Showing
3 changed files
with
25 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#[link(name = "my_c_library")] | ||
extern "C" { | ||
fn my_c_function(x: i32) -> bool; | ||
} | ||
|
||
#[no_mangle] | ||
extern "C" pub fn id(x: i32) -> i32 { x } //~ ERROR expected `fn`, found keyword `pub` | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: expected `fn`, found keyword `pub` | ||
--> $DIR/issue-113342.rs:7:12 | ||
| | ||
LL | extern "C" pub fn id(x: i32) -> i32 { x } | ||
| -----------^^^ | ||
| | | | ||
| | expected `fn` | ||
| help: visibility `pub` must come before `extern "C"`: `pub extern "C"` | ||
|
||
error: aborting due to previous error | ||
|