Skip to content
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

Improve E0317 long diagnostics #31045

Merged
merged 1 commit into from
Jan 23, 2016
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
36 changes: 35 additions & 1 deletion src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,41 @@ https://doc.rust-lang.org/reference.html#statements
E0317: r##"
User-defined types or type parameters cannot shadow the primitive types.
This error indicates you tried to define a type, struct or enum with the same
name as an existing primitive type.
name as an existing primitive type:

```
struct u8 {
// ...
}
```

To fix this, simply name it something else.

Such an error may also occur if you define a type parameter which shadows a
primitive type. An example would be something like:

```
impl<u8> MyTrait for Option<u8> {
// ...
}
```

In such a case, if you meant for `u8` to be a generic type parameter (i.e. any
type can be used in its place), use something like `T` instead:

```
impl<T> MyTrait for Option<T> {
// ...
}
```

On the other hand, if you wished to refer to the specific type `u8`, remove it
from the type parameter list:

```
impl MyTrait for Option<u8> {
// ...
}

See the Types section of the reference for more information about the primitive
types:
Expand Down