]> git.lizzy.rs Git - rust.git/blob - src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
update comment to explain the importance of this check more clearly
[rust.git] / src / test / ui / underscore-lifetime / dyn-trait-underscore.stderr
1 error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
2   --> $DIR/dyn-trait-underscore.rs:8:20
3    |
4 LL |     Box::new(items.iter())
5    |                    ^^^^
6    |
7 note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 6:1...
8   --> $DIR/dyn-trait-underscore.rs:6:1
9    |
10 LL | / fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
11 LL | |     //                      ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
12 LL | |     Box::new(items.iter())
13 LL | | }
14    | |_^
15 note: ...so that reference does not outlive borrowed content
16   --> $DIR/dyn-trait-underscore.rs:8:14
17    |
18 LL |     Box::new(items.iter())
19    |              ^^^^^
20    = note: but, the lifetime must be valid for the static lifetime...
21    = note: ...so that the expression is assignable:
22            expected std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>
23               found std::boxed::Box<dyn std::iter::Iterator<Item = &T>>
24
25 error: aborting due to previous error
26
27 For more information about this error, try `rustc --explain E0495`.