]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-no-variance-from-fn-generics.rs
internally change regions to be covariant
[rust.git] / tests / ui / regions / regions-no-variance-from-fn-generics.rs
1 // run-pass
2 #![allow(unused_variables)]
3 // Issue #12856: a lifetime formal binding introduced by a generic fn
4 // should not upset the variance inference for actual occurrences of
5 // that lifetime in type expressions.
6
7
8 pub trait HasLife<'a> {
9     fn dummy(&'a self) { } // just to induce a variance on 'a
10 }
11
12 trait UseLife01 {
13     fn refs<'a, H: HasLife<'a>>(&'a self) -> H;
14 }
15
16 trait UseLife02 {
17     fn refs<'a, T: 'a, H: HasType<&'a T>>(&'a self) -> H;
18 }
19
20
21 pub trait HasType<T>
22 {
23     fn dummy(&self, t: T) -> T { panic!() }
24 }
25
26
27 trait UseLife03<T> {
28     fn refs<'a, H: HasType<&'a T>>(&'a self) -> H where T: 'a;
29 }
30
31
32 // (The functions below were not actually a problem observed during
33 // fixing of #12856; they just seem like natural tests to put in to
34 // cover a couple more points in the testing space)
35
36 pub fn top_refs_1<'a, H: HasLife<'a>>(_s: &'a ()) -> H {
37     unimplemented!()
38 }
39
40 pub fn top_refs_2<'a, T: 'a, H: HasType<&'a T>>(_s: &'a ()) -> H {
41     unimplemented!()
42 }
43
44 pub fn main() {}