-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Add E0044 and E0071 error explanations #26431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
0770f66
67c11b0
e52b94e
4c2587c
3c98781
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -380,6 +380,21 @@ fn main() { | |
``` | ||
"##, | ||
|
||
E0044: r##" | ||
You can't use type parameters on foreign items. Example of erroneous code: | ||
|
||
``` | ||
extern { fn some_func<T>(x: T); } | ||
``` | ||
|
||
To fix this, replace the type parameter with the specializations that you | ||
need: | ||
|
||
``` | ||
extern { fn some_func_i32(x: i32); } | ||
extern { fn some_func_i64(x: i64); } | ||
``` | ||
|
||
E0045: r##" | ||
Rust only supports variadic parameters for interoperability with C code in its | ||
FFI. As such, variadic parameters can only be used with functions which are | ||
|
@@ -733,6 +748,38 @@ fn some_func(x: &mut i32) { | |
``` | ||
"##, | ||
|
||
E0071: r##" | ||
You tried to use a structure initialization with a non-structure type. | ||
Example of erroneous code: | ||
|
||
``` | ||
enum Foo { f }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. capitalize There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll create a "complete" name instead of just "f". |
||
|
||
let u = Foo::f { value: 0i32 }; // error: Foo:f isn't a structure! | ||
// or even simpler: | ||
let u = t { random_field: 0i32 }; //error: t isn't a structure! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's where the error comes from. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not been defined .. oh, I see (make that explicit "or even simpler, if the structure wasn't defined at all") |
||
``` | ||
|
||
To fix this error, please declare the structure with the given name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't the fix. There's no way to "fix" this, really, one should use variant constructors for enums and struct constructors for structs; if the wrong one is being used, find out why and fix the struct/enum or the constructor. |
||
first: | ||
|
||
``` | ||
struct Inner { | ||
value: i32 | ||
} | ||
|
||
enum Foo { | ||
f(Inner) | ||
} | ||
|
||
fn main() { | ||
let u = Foo::f(Inner { value: 0i32 }); | ||
// or even simpler: | ||
let t = Inner { value: 0i32 }; | ||
} | ||
``` | ||
"##, | ||
|
||
E0072: r##" | ||
When defining a recursive struct or enum, any use of the type being defined | ||
from inside the definition must occur behind a pointer (like `Box` or `&`). | ||
|
@@ -1488,9 +1535,7 @@ For more information see the [opt-in builtin traits RFC](https://github.com/rust | |
} | ||
|
||
register_diagnostics! { | ||
E0044, // foreign items may not have type parameters | ||
E0068, | ||
E0071, | ||
E0074, | ||
E0075, | ||
E0076, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're missing an end of string here, currently E0045 and its message are included in E0044's message!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh crap ! Bad rebase...