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 // `S` is contravariant with respect to both parameters.
13 fn use_<'short,'long>(c: S<'long, 'short>,
16 _where:Option<&'short &'long ()>) {
18 let _: S<'long, 'short> = c; // OK
19 let _: S<'short, 'short> = c; // OK
21 // Test whether S<_,'short> <: S<_,'long>. Since
22 // 'short <= 'long, this would be true if the Contravariant type were
23 // covariant with respect to its parameter 'a.
25 let _: S<'long, 'long> = c;
26 //~^ ERROR lifetime may not live long enough