File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 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 }
363363struct Foo2<'a> { x: &'a bool } // correct
364364
365365impl Foo2 {}
366- // ^ expected lifetime parameter
366+ // ^^^^ expected lifetime parameter
367367impl<'a> Foo2<'a> {} // correct
368368
369369struct Bar1 { x: Foo2 }
@@ -770,40 +770,40 @@ struct Foo {
770770These can be fixed by declaring lifetime parameters:
771771
772772```
773- fn foo<'a>(x: &'a str) {}
774-
775773struct Foo<'a> {
776774 x: &'a str,
777775}
776+
777+ fn foo<'a>(x: &'a str) {}
778778```
779779
780780Impl blocks declare lifetime parameters separately. You need to add lifetime
781781parameters to an impl block if you're implementing a type that has a lifetime
782782parameter of its own.
783783For example:
784-
784+
785785```compile_fail,E0261
786+ struct Foo<'a> {
787+ x: &'a str,
788+ }
789+
786790// error, use of undeclared lifetime name `'a`
787791impl Foo<'a> {
788792 fn foo<'a>(x: &'a str) {}
789793}
790-
791- struct Foo<'a> {
792- x: &'a str,
793- }
794794```
795795
796- This is fixed by declaring impl block like this:
796+ This is fixed by declaring the impl block like this:
797797
798798```
799+ struct Foo<'a> {
800+ x: &'a str,
801+ }
802+
799803// correct
800804impl<'a> Foo<'a> {
801805 fn foo(x: &'a str) {}
802806}
803-
804- struct Foo<'a> {
805- x: &'a str,
806- }
807807```
808808"## ,
809809
You can’t perform that action at this time.
0 commit comments