2013-10-29 06:08:34 -04:00
|
|
|
// Test that a type which is invariant with respect to its region
|
|
|
|
// parameter used in a covariant way yields an error.
|
|
|
|
//
|
|
|
|
// Note: see variance-regions-*.rs for the tests that check that the
|
|
|
|
// variance inference works in the first place.
|
|
|
|
|
|
|
|
struct Invariant<'a> {
|
2015-01-08 21:54:35 +11:00
|
|
|
f: &'a mut &'a isize
|
2013-10-29 06:08:34 -04:00
|
|
|
}
|
|
|
|
|
2013-11-08 15:52:36 -05:00
|
|
|
fn use_<'b>(c: Invariant<'b>) {
|
|
|
|
|
|
|
|
// For this assignment to be legal, Invariant<'b> <: Invariant<'static>.
|
|
|
|
// Since 'b <= 'static, this would be true if Invariant were covariant
|
|
|
|
// with respect to its parameter 'a.
|
|
|
|
|
2022-04-19 12:56:18 +02:00
|
|
|
let _: Invariant<'static> = c;
|
2022-04-01 13:13:25 -04:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2013-10-29 06:08:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|