rust/src/test/ui/issues/issue-16922.rs
Esteban Küber 65f492be12 Account for returned dyn Trait evaluating to 'static lifetime
Provide a suggestion for `dyn Trait + '_` when possible.
2020-05-30 10:22:26 -07:00

10 lines
190 B
Rust

use std::any::Any;
fn foo<T: Any>(value: &T) -> Box<dyn Any> {
Box::new(value) as Box<dyn Any>
//~^ ERROR cannot infer an appropriate lifetime
}
fn main() {
let _ = foo(&5);
}