-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.