summaryrefslogtreecommitdiffstats
path: root/src/test/ui/variance/variance-associated-types2.rs
blob: e487eefea63e63c62f2a1afeba7afb7f7c38a93c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Test that dyn Foo<Bar = T> is invariant with respect to T.
// Failure to enforce invariance here can be weaponized, see #71550 for details.

trait Foo {
    type Bar;
}

fn make() -> Box<dyn Foo<Bar = &'static u32>> {
    panic!()
}

fn take<'a>(_: &'a u32) {
    let _: Box<dyn Foo<Bar = &'a u32>> = make();
    //~^ ERROR lifetime may not live long enough
}

fn main() {}