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 3 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
49 changes: 47 additions & 2 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
```

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 +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 };
Copy link
Member

Choose a reason for hiding this comment

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

capitalize f throughout this example

Copy link
Member Author

Choose a reason for hiding this comment

The 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!
Copy link
Member

Choose a reason for hiding this comment

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

What is t?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's where the error comes from.

Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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 `&`).
Expand Down Expand Up @@ -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,
Expand Down