Skip to content

Commit a2b75ed

Browse files
review comments
1 parent adadefd commit a2b75ed

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Diff for: src/librustc/diagnostics.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ struct Foo1 { x: &bool }
363363
struct Foo2<'a> { x: &'a bool } // correct
364364
365365
impl Foo2 {}
366-
// ^ expected lifetime parameter
366+
// ^^^^ expected lifetime parameter
367367
impl<'a> Foo2<'a> {} // correct
368368
369369
struct Bar1 { x: Foo2 }
@@ -770,40 +770,40 @@ struct Foo {
770770
These can be fixed by declaring lifetime parameters:
771771
772772
```
773-
fn foo<'a>(x: &'a str) {}
774-
775773
struct Foo<'a> {
776774
x: &'a str,
777775
}
776+
777+
fn foo<'a>(x: &'a str) {}
778778
```
779779
780780
Impl blocks declare lifetime parameters separately. You need to add lifetime
781781
parameters to an impl block if you're implementing a type that has a lifetime
782782
parameter of its own.
783783
For 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`
787791
impl 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
800804
impl<'a> Foo<'a> {
801805
fn foo(x: &'a str) {}
802806
}
803-
804-
struct Foo<'a> {
805-
x: &'a str,
806-
}
807807
```
808808
"##,
809809

0 commit comments

Comments
 (0)