File tree 1 file changed +13
-13
lines changed
1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -363,7 +363,7 @@ struct Foo1 { x: &bool }
363
363
struct Foo2<'a> { x: &'a bool } // correct
364
364
365
365
impl Foo2 {}
366
- // ^ expected lifetime parameter
366
+ // ^^^^ expected lifetime parameter
367
367
impl<'a> Foo2<'a> {} // correct
368
368
369
369
struct Bar1 { x: Foo2 }
@@ -770,40 +770,40 @@ struct Foo {
770
770
These can be fixed by declaring lifetime parameters:
771
771
772
772
```
773
- fn foo<'a>(x: &'a str) {}
774
-
775
773
struct Foo<'a> {
776
774
x: &'a str,
777
775
}
776
+
777
+ fn foo<'a>(x: &'a str) {}
778
778
```
779
779
780
780
Impl blocks declare lifetime parameters separately. You need to add lifetime
781
781
parameters to an impl block if you're implementing a type that has a lifetime
782
782
parameter of its own.
783
783
For example:
784
-
784
+
785
785
```compile_fail,E0261
786
+ struct Foo<'a> {
787
+ x: &'a str,
788
+ }
789
+
786
790
// error, use of undeclared lifetime name `'a`
787
791
impl Foo<'a> {
788
792
fn foo<'a>(x: &'a str) {}
789
793
}
790
-
791
- struct Foo<'a> {
792
- x: &'a str,
793
- }
794
794
```
795
795
796
- This is fixed by declaring impl block like this:
796
+ This is fixed by declaring the impl block like this:
797
797
798
798
```
799
+ struct Foo<'a> {
800
+ x: &'a str,
801
+ }
802
+
799
803
// correct
800
804
impl<'a> Foo<'a> {
801
805
fn foo(x: &'a str) {}
802
806
}
803
-
804
- struct Foo<'a> {
805
- x: &'a str,
806
- }
807
807
```
808
808
"## ,
809
809
You can’t perform that action at this time.
0 commit comments