-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-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
A programmer new to Rust (yours truly, for example) may assume that these two syntaxes are equivalent:
extern "C" {
fn foo() -> i32 {
return 0;
}
}
extern "C" fn foo() -> i32 {
return 0;
}
This is not the case, of course—the first is a syntax error. However, the compiler points this out rather unhelpfully:
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `where`, found `{`
--> src/lib.rs:2:21
|
2 | fn foo() -> i32 {
| ^ expected one of 7 possible tokens here
A message such as "If you're trying to declare a function callable from other languages, use extern "C" fn foo()
(wording is bikesheddable, obviously) would have saved me a lot of hair-tearing.
Patryk27
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-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.