Skip to content

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

Merged
merged 5 commits into from
Jun 24, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,22 @@ 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); }
```
"##,

Copy link
Contributor

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!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh crap ! Bad rebase...

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
Expand Down Expand Up @@ -733,6 +749,44 @@ 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 { FirstValue };

let u = Foo::FirstValue { value: 0i32 }; // error: Foo::FirstValue
// isn't a structure!
// or even simpler, if the structure wasn't defined at all:
let u = RandomName { random_field: 0i32 }; // error: RandomName
// isn't a structure!
```

To fix this, please check:
* Did you spell it right?
* Did you accidentaly used an enum as a struct?
* Did you accidentaly make an enum when you intended to use a struct?

Here is the previous code with all missing information:

```
struct Inner {
value: i32
}

enum Foo {
FirstValue(Inner)
}

fn main() {
let u = Foo::FirstValue(Inner { value: 0i32 });

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 `&`).
Expand Down Expand Up @@ -1488,9 +1542,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,
Expand Down