Improve E0118 description
This commit is contained in:
parent
d778203da2
commit
1c1bb1309f
7 changed files with 71 additions and 21 deletions
|
@ -1,10 +1,10 @@
|
|||
An inherent implementation was defined for something which isn't a struct nor
|
||||
an enum.
|
||||
An inherent implementation was defined for something which isn't a struct, an
|
||||
enum, a union or a trait object.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0118
|
||||
impl (u8, u8) { // error: no base type found for inherent implementation
|
||||
impl (u8, u8) { // error: no nominal type found for inherent implementation
|
||||
fn get_state(&self) -> String {
|
||||
// ...
|
||||
}
|
||||
|
@ -41,3 +41,24 @@ impl TypeWrapper {
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
Instead of defining an inherent implementation on a reference, you could also
|
||||
move the reference inside the implementation:
|
||||
|
||||
```compile_fail,E0118
|
||||
struct Foo;
|
||||
|
||||
impl &Foo { // error: no nominal type found for inherent implementation
|
||||
fn bar(self, other: Self) {}
|
||||
}
|
||||
```
|
||||
|
||||
becomes
|
||||
|
||||
```
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
fn bar(&self, other: &Self) {}
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue