]> git.lizzy.rs Git - rust.git/blob - src/test/ui/variance/variance-associated-types2.rs
Rollup merge of #88858 - spektom:to_lower_upper_rev, r=dtolnay
[rust.git] / src / test / ui / variance / variance-associated-types2.rs
1 // Test that dyn Foo<Bar = T> is invariant with respect to T.
2 // Failure to enforce invariance here can be weaponized, see #71550 for details.
3
4 trait Foo {
5     type Bar;
6 }
7
8 fn make() -> Box<dyn Foo<Bar = &'static u32>> {
9     panic!()
10 }
11
12 fn take<'a>(_: &'a u32) {
13     let _: Box<dyn Foo<Bar = &'a u32>> = make();
14     //~^ ERROR mismatched types [E0308]
15 }
16
17 fn main() {}