summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/object/issue-44454-1.rs
blob: bbaf3188a8963bd4735aa1c7ae115df660675a1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 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);
}