Rollup merge of #113350 - chenyukang:yukang-fix-113342-parser, r=compiler-errors

Fix the issue of wrong diagnosis for extern pub fn

Fixes #113342
This commit is contained in:
fee1-dead
2023-07-06 09:20:34 +08:00
committed by GitHub
3 changed files with 25 additions and 1 deletions
+9
View File
@@ -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() {}
+11
View File
@@ -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