rust/tests/ui/nll/ty-outlives/projection-no-regions-fn.st...

32 lines
1.3 KiB
Plaintext

error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough
--> $DIR/projection-no-regions-fn.rs:13:5
|
LL | fn no_region<'a, T>(mut x: T) -> Box<dyn Anything + 'a>
| -- the associated type `<T as Iterator>::Item` must be valid for the lifetime `'a` as defined here...
...
LL | Box::new(x.next())
| ^^^^^^^^^^^^^^^^^^ ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound
|
LL | T: Iterator, <T as Iterator>::Item: 'a
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough
--> $DIR/projection-no-regions-fn.rs:28:5
|
LL | fn wrong_region<'a, 'b, T>(mut x: T) -> Box<dyn Anything + 'a>
| -- the associated type `<T as Iterator>::Item` must be valid for the lifetime `'a` as defined here...
...
LL | Box::new(x.next())
| ^^^^^^^^^^^^^^^^^^ ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound
|
LL | T: 'b + Iterator, <T as Iterator>::Item: 'a
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0309`.