]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/regions-variance-contravariant-use-covariant.rs
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 contravariant with respect to 'a, meaning that
8 // Contravariant<'long> <: Contravariant<'short> iff
10 struct Contravariant
<'a
> {
14 fn use_
<'short
,'long
>(c
: Contravariant
<'short
>,
17 _where
:Option
<&'short
&'
long ()>) {
19 // Test whether Contravariant<'short> <: Contravariant<'long>. Since
20 // 'short <= 'long, this would be true if the Contravariant type were
21 // covariant with respect to its parameter 'a.
23 let _
: Contravariant
<'long
> = c
;
24 //~^ ERROR lifetime may not live long enough