Skip to content

Adding detailed error text for E0118 #28263

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 9 commits into from
Sep 15, 2015
Merged
Changes from 8 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
21 changes: 20 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,26 @@ For information on the design of the orphan rules, see [RFC 1023].
[RFC 1023]: https://github.com/rust-lang/rfcs/pull/1023
"##,

E0118: r##"
Rust can't find a base type for an implementation you are providing, or the type
cannot have an implementation. For example, a typedef can't have an
implementation, since it isn't its own type (this was done in PR #6087):
Copy link
Contributor

Choose a reason for hiding this comment

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

This text isn't quite accurate. Whether something is a type alias is not relevant. See for example this code on play. The rule is that you can only do an inherent impl (meaning, an impl without a trait) for a named type (struct, enum, or trait) defined in the local crate. The reason that your example below is prohibited is because the type [char, ..9] is an array type, which is not a named type.


```
type NineString = [char, ..9]
impl NineString {
// Some code here
}
```

In the other, simpler case, Rust just can't find the type you are providing an
impelementation for:

```
impl SomeTypeThatDoesntExist { }
```
"##,

E0119: r##"
There are conflicting trait implementations for the same type.
Example of erroneous code:
Expand Down Expand Up @@ -3194,7 +3214,6 @@ register_diagnostics! {
E0090,
E0103, // @GuillaumeGomez: I was unable to get this error, try your best!
E0104,
E0118,
// E0123,
// E0127,
// E0129,
Expand Down