]> git.proxmox.com Git - rustc.git/blame - src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / underscore-lifetime / dyn-trait-underscore.stderr
CommitLineData
3dfed10e 1error[E0759]: `items` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
0731742a 2 --> $DIR/dyn-trait-underscore.rs:8:20
0531ce1d 3 |
f9f354fc 4LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
f035d41b 5 | ---- this data with an anonymous lifetime `'_`...
f9f354fc 6LL | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
532ac7d7 7LL | Box::new(items.iter())
f035d41b 8 | ---------------^^^^--- ...is captured and required to live as long as `'static` here
0531ce1d 9 |
f035d41b 10help: to declare that the trait object captures data from argument `items`, you can add an explicit `'_` lifetime bound
0531ce1d 11 |
f9f354fc 12LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T> + '_> {
94222f64 13 | ++++
0531ce1d
XL
14
15error: aborting due to previous error
16
f035d41b 17For more information about this error, try `rustc --explain E0759`.