Closed
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.