Closed
Description
Code
#[no_mangle]
extern "C" pub fn id(x: i32) -> i32 { x }
Current output
error: expected `{`, found keyword `pub`
--> error.rs:2:12
|
2 | extern "C" pub fn id(x: i32) -> i32 { x }
| ^^^ expected `{`
error: aborting due to previous error
Desired output
error: expected `{` or `fn`, found keyword `pub`
--> error.rs:2:12
|
2 | extern "C" pub fn id(x: i32) -> i32 { x }
| ^^^ expected `{`
error: aborting due to previous error
Rationale and extra context
The correct code here is
extern "C" fn id(x: i32) -> i32 { x }
but the error doesn't suggest that fn
keyword would be allowed here.
Ideally we'd recover from this, and say "visibility isn't allowed for extern
functions", but if that's not feasible, then we should accurately report the tokens allowed.
Other cases
No response
Anything else?
No response