]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-variance-invariant-use-covariant.rs
Auto merge of #106143 - matthiaskrgr:rollup-3kpy1dc, r=matthiaskrgr
[rust.git] / src / test / ui / regions / regions-variance-invariant-use-covariant.rs
1 // Test that a type which is invariant with respect to its region
2 // parameter used in a covariant way yields an error.
3 //
4 // Note: see variance-regions-*.rs for the tests that check that the
5 // variance inference works in the first place.
6
7 struct Invariant<'a> {
8     f: &'a mut &'a isize
9 }
10
11 fn use_<'b>(c: Invariant<'b>) {
12
13     // For this assignment to be legal, Invariant<'b> <: Invariant<'static>.
14     // Since 'b <= 'static, this would be true if Invariant were covariant
15     // with respect to its parameter 'a.
16
17     let _: Invariant<'static> = c;
18     //~^ ERROR lifetime may not live long enough
19 }
20
21 fn main() { }