]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-variance-covariant-use-covariant.rs
internally change regions to be covariant
[rust.git] / tests / ui / regions / regions-variance-covariant-use-covariant.rs
1 // run-pass
2 #![allow(dead_code)]
3 // Test that a type which is covariant with respect to its region
4 // parameter is successful when used in a covariant way.
5 //
6 // Note: see ui/variance/variance-regions-*.rs for the tests that
7 // check that the variance inference works in the first place.
8
9 // This is covariant with respect to 'a, meaning that
10 // Covariant<'foo> <: Covariant<'static> because
11 // 'foo <= 'static
12 // pretty-expanded FIXME #23616
13
14 struct Covariant<'a> {
15     f: extern "Rust" fn(&'a isize)
16 }
17
18 fn use_<'a>(c: Covariant<'a>) {
19     // OK Because Covariant<'a> <: Covariant<'static> iff 'a <= 'static
20     let _: Covariant<'static> = c;
21 }
22
23 pub fn main() {}