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.
8 // ignore-compare-mode-nll
9 //[nll] compile-flags: -Z borrowck=mir
11 // This is contravariant with respect to 'a, meaning that
12 // Contravariant<'long> <: Contravariant<'short> iff
14 struct Contravariant<'a> {
18 fn use_<'short,'long>(c: Contravariant<'short>,
21 _where:Option<&'short &'long ()>) {
23 // Test whether Contravariant<'short> <: Contravariant<'long>. Since
24 // 'short <= 'long, this would be true if the Contravariant type were
25 // covariant with respect to its parameter 'a.
27 let _: Contravariant<'long> = c;
28 //[base]~^ ERROR E0623
29 //[nll]~^^ ERROR lifetime may not live long enough