rust/tests/ui/traits/object/issue-44454-1.rs
2023-01-11 09:32:08 +00:00

23 lines
422 B
Rust

// Taken from https://github.com/rust-lang/rust/issues/44454#issue-256435333
trait Animal<X>: 'static {}
fn foo<Y, X>()
where
Y: Animal<X> + ?Sized,
{
// `Y` implements `Animal<X>` so `Y` is 'static.
baz::<Y>()
}
fn bar<'a>(_arg: &'a i32) {
foo::<dyn Animal<&'a i32>, &'a i32>() //~ ERROR: lifetime may not live long enough
}
fn baz<T: 'static + ?Sized>() {}
fn main() {
let a = 5;
bar(&a);
}