Skip to content

Commit

Permalink
Extend E0106, E0261
Browse files Browse the repository at this point in the history
Added an example that points out hardly obvious mistake one could make when writing impl for a new type.
  • Loading branch information
purple-ice committed Jan 3, 2019
1 parent 2442823 commit c738e60
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/librustc/diagnostics.rs
Expand Up @@ -362,6 +362,10 @@ struct Foo1 { x: &bool }
// ^ expected lifetime parameter
struct Foo2<'a> { x: &'a bool } // correct
impl Foo2 { ... }
// ^ expected lifetime parameter
impl<'a> Foo2<'a> { ... } // correct
struct Bar1 { x: Foo2 }
// ^^^^ expected lifetime parameter
struct Bar2<'a> { x: Foo2<'a> } // correct
Expand Down Expand Up @@ -772,6 +776,24 @@ struct Foo<'a> {
x: &'a str,
}
```
Implementations need their own lifetime declarations:
```
// error, undeclared lifetime
impl Foo<'a> {
...
}
```
Which are declared like this:
```
// correct
impl<'a> Foo<'a> {
...
}
```
"##,

E0262: r##"
Expand Down

0 comments on commit c738e60

Please sign in to comment.