2013-10-29 10:08:34 +00:00
|
|
|
// Test that we correctly infer variance for region parameters in
|
2014-08-01 23:42:13 +00:00
|
|
|
// case that involve multiple intricate types.
|
2013-10-29 10:08:34 +00:00
|
|
|
// Try enums too.
|
|
|
|
|
2015-02-16 20:21:41 +00:00
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
|
2013-10-29 10:08:34 +00:00
|
|
|
#[rustc_variance]
|
2023-01-26 23:23:08 +00:00
|
|
|
enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR [-, +, o, *]
|
2015-01-08 10:54:35 +00:00
|
|
|
Test8A(extern "Rust" fn(&'a isize)),
|
|
|
|
Test8B(&'b [isize]),
|
2013-10-29 10:08:34 +00:00
|
|
|
Test8C(&'b mut &'c str),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rustc_variance]
|
2023-01-26 23:23:08 +00:00
|
|
|
struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR [*, o, +, -]
|
2013-10-29 10:08:34 +00:00
|
|
|
f: Base<'z, 'y, 'x, 'w>
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rustc_variance] // Combine - and + to yield o
|
2016-08-26 22:13:48 +00:00
|
|
|
struct Derived2<'a, 'b:'a, 'c> { //~ ERROR [o, o, *]
|
2013-10-29 10:08:34 +00:00
|
|
|
f: Base<'a, 'a, 'b, 'c>
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here)
|
2023-01-26 23:23:08 +00:00
|
|
|
struct Derived3<'a:'b, 'b, 'c> { //~ ERROR [o, +, *]
|
2013-10-29 10:08:34 +00:00
|
|
|
f: Base<'a, 'b, 'a, 'c>
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rustc_variance] // Combine + and * to yield + (just pay attention to 'a here)
|
2023-01-26 23:23:08 +00:00
|
|
|
struct Derived4<'a, 'b, 'c:'b> { //~ ERROR [-, +, o]
|
2013-10-29 10:08:34 +00:00
|
|
|
f: Base<'a, 'b, 'c, 'a>
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|