]> git.lizzy.rs Git - rust.git/blob - src/test/ui/variance/variance-regions-indirect.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / variance / variance-regions-indirect.rs
1 // Test that we correctly infer variance for region parameters in
2 // case that involve multiple intricate types.
3 // Try enums too.
4
5 #![feature(rustc_attrs)]
6
7 #[rustc_variance]
8 enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR [+, -, o, *]
9     Test8A(extern "Rust" fn(&'a isize)),
10     Test8B(&'b [isize]),
11     Test8C(&'b mut &'c str),
12 }
13
14 #[rustc_variance]
15 struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR [*, o, -, +]
16     f: Base<'z, 'y, 'x, 'w>
17 }
18
19 #[rustc_variance] // Combine - and + to yield o
20 struct Derived2<'a, 'b:'a, 'c> { //~ ERROR [o, o, *]
21     f: Base<'a, 'a, 'b, 'c>
22 }
23
24 #[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here)
25 struct Derived3<'a:'b, 'b, 'c> { //~ ERROR [o, -, *]
26     f: Base<'a, 'b, 'a, 'c>
27 }
28
29 #[rustc_variance] // Combine + and * to yield + (just pay attention to 'a here)
30 struct Derived4<'a, 'b, 'c:'b> { //~ ERROR [+, -, o]
31     f: Base<'a, 'b, 'c, 'a>
32 }
33
34 fn main() {}