error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements --> $DIR/dyn-trait-underscore.rs:18:20 | LL | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime | ^^^^ | note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 16:1... --> $DIR/dyn-trait-underscore.rs:16:1 | LL | / fn a(items: &[T]) -> Box> { LL | | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static` LL | | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime LL | | } | |_^ note: ...so that reference does not outlive borrowed content --> $DIR/dyn-trait-underscore.rs:18:14 | LL | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime | ^^^^^ = note: but, the lifetime must be valid for the static lifetime... = note: ...so that the expression is assignable: expected std::boxed::Box<(dyn std::iter::Iterator + 'static)> found std::boxed::Box> error: aborting due to previous error For more information about this error, try `rustc --explain E0495`.