I have this in main.rs:
struct Element {
Head: i64,
Tail: &Element
}
fn main() {
println!("Hello, world!");
}
when I ran cargo run
i got:
error[E0106]: missing lifetime specifier
--> src/main.rs:3:11
|
3 | Tail: &Element
| ^ expected named lifetime parameter
|
help: consider introducing a named lifetime parameter
|
1 | struct Element<'a> {
2 | Head: i64,
3 | Tail: &'a Element
|
I then changed it to what was suggested and ran cargo run
again and i got:
error[E0106]: missing lifetime specifier
--> src/main.rs:3:15
|
3 | Tail: &'a Element
| ^^^^^^^ expected named lifetime parameter
|
help: consider using the `'a` lifetime
|
3 | Tail: &'a Element<'a>
| ^^^^^^^^^^^
So i made the change; and it compiled and printed the line. (along with some warnings)
My question is, what caused it to produce help message in this two steps? Instead of proving the full fix at the first time.
rustc 1.51.0