Skip to content

Commit c738e60

Browse files
authored
Extend E0106, E0261
Added an example that points out hardly obvious mistake one could make when writing impl for a new type.
1 parent 2442823 commit c738e60

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/librustc/diagnostics.rs

+22
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ struct Foo1 { x: &bool }
362362
// ^ expected lifetime parameter
363363
struct Foo2<'a> { x: &'a bool } // correct
364364
365+
impl Foo2 { ... }
366+
// ^ expected lifetime parameter
367+
impl<'a> Foo2<'a> { ... } // correct
368+
365369
struct Bar1 { x: Foo2 }
366370
// ^^^^ expected lifetime parameter
367371
struct Bar2<'a> { x: Foo2<'a> } // correct
@@ -772,6 +776,24 @@ struct Foo<'a> {
772776
x: &'a str,
773777
}
774778
```
779+
780+
Implementations need their own lifetime declarations:
781+
782+
```
783+
// error, undeclared lifetime
784+
impl Foo<'a> {
785+
...
786+
}
787+
```
788+
789+
Which are declared like this:
790+
791+
```
792+
// correct
793+
impl<'a> Foo<'a> {
794+
...
795+
}
796+
```
775797
"##,
776798

777799
E0262: r##"

0 commit comments

Comments
 (0)