2013-10-29 10:08:34 +00: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 10:54:35 +00:00
|
|
|
f: &'a mut &'a isize
|
2013-10-29 10:08:34 +00:00
|
|
|
}
|
|
|
|
|
2013-11-08 20:52:36 +00: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 10:56:18 +00:00
|
|
|
let _: Invariant<'static> = c;
|
2022-04-01 17:13:25 +00:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2013-10-29 10:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|