1 // Test that a type which is covariant with respect to its region
2 // parameter yields an error when used in a contravariant way.
4 // Note: see variance-regions-*.rs for the tests that check that the
5 // variance inference works in the first place.
7 // This is covariant with respect to 'a, meaning that
8 // Covariant<'foo> <: Covariant<'static> because
10 struct Covariant<'a> {
11 f: extern "Rust" fn(&'a isize)
14 fn use_<'short,'long>(c: Covariant<'long>,
17 _where:Option<&'short &'long ()>) {
19 // Test whether Covariant<'long> <: Covariant<'short>. Since
20 // 'short <= 'long, this would be true if the Covariant type were
21 // contravariant with respect to its parameter 'a.
23 let _: Covariant<'short> = c;
24 //~^ ERROR lifetime may not live long enough