rust/tests/ui/lifetimes/no_lending_iterators.stderr

31 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-05-24 10:20:33 -05:00
error: associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
--> $DIR/no_lending_iterators.rs:4:17
|
LL | type Item = &str;
| ^
|
2024-06-21 17:20:45 -05:00
note: you can't create an `Iterator` that borrows each `Item` from itself, but you can instead create a new type that borrows your existing type and implement `Iterator` for that new type
--> $DIR/no_lending_iterators.rs:3:19
|
LL | impl Iterator for Data {
| ^^^^
2024-05-24 10:20:33 -05:00
error: in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
--> $DIR/no_lending_iterators.rs:18:17
|
LL | type Item = &usize;
| ^ this lifetime must come from the implemented type
error[E0195]: lifetime parameters or bounds on type `Item` do not match the trait declaration
--> $DIR/no_lending_iterators.rs:27:14
|
LL | type Item;
| - lifetimes in impl do not match this type in trait
...
LL | type Item<'a> = &'a isize;
| ^^^^ lifetimes do not match type in trait
error: aborting due to 3 previous errors
2024-05-24 10:20:33 -05:00
For more information about this error, try `rustc --explain E0195`.