Skip to content

Commit adadefd

Browse files
authored
Fix changes for E0106, E0261
Replaced impl block dock with suggested one and made sure that blocks compile.
1 parent c738e60 commit adadefd

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

Diff for: src/librustc/diagnostics.rs

+19-8
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ struct Foo1 { x: &bool }
362362
// ^ expected lifetime parameter
363363
struct Foo2<'a> { x: &'a bool } // correct
364364
365-
impl Foo2 { ... }
365+
impl Foo2 {}
366366
// ^ expected lifetime parameter
367-
impl<'a> Foo2<'a> { ... } // correct
367+
impl<'a> Foo2<'a> {} // correct
368368
369369
struct Bar1 { x: Foo2 }
370370
// ^^^^ expected lifetime parameter
@@ -777,21 +777,32 @@ struct Foo<'a> {
777777
}
778778
```
779779
780-
Implementations need their own lifetime declarations:
780+
Impl blocks declare lifetime parameters separately. You need to add lifetime
781+
parameters to an impl block if you're implementing a type that has a lifetime
782+
parameter of its own.
783+
For example:
781784
782-
```
783-
// error, undeclared lifetime
785+
```compile_fail,E0261
786+
// error, use of undeclared lifetime name `'a`
784787
impl Foo<'a> {
785-
...
788+
fn foo<'a>(x: &'a str) {}
789+
}
790+
791+
struct Foo<'a> {
792+
x: &'a str,
786793
}
787794
```
788795
789-
Which are declared like this:
796+
This is fixed by declaring impl block like this:
790797
791798
```
792799
// correct
793800
impl<'a> Foo<'a> {
794-
...
801+
fn foo(x: &'a str) {}
802+
}
803+
804+
struct Foo<'a> {
805+
x: &'a str,
795806
}
796807
```
797808
"##,

0 commit comments

Comments
 (0)