]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-enum-not-wf.rs
Auto merge of #60093 - GuillaumeGomez:fix-attrs-pos, r=Manishearth
[rust.git] / src / test / ui / regions / regions-enum-not-wf.rs
1 // ignore-tidy-linelength
2
3 // Various examples of structs whose fields are not well-formed.
4
5 #![allow(dead_code)]
6
7 trait Dummy<'a> {
8   type Out;
9 }
10 impl<'a, T> Dummy<'a> for T
11 where T: 'a
12 {
13   type Out = ();
14 }
15 type RequireOutlives<'a, T> = <T as Dummy<'a>>::Out;
16
17 enum Ref1<'a, T> {
18     Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough
19 }
20
21 enum Ref2<'a, T> {
22     Ref2Variant1,
23     Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough
24 }
25
26 enum RefOk<'a, T:'a> {
27     RefOkVariant1(&'a T)
28 }
29
30 // This is now well formed. RFC 2093
31 enum RefIndirect<'a, T> {
32     RefIndirectVariant1(isize, RefOk<'a,T>)
33 }
34
35 enum RefDouble<'a, 'b, T> { //~ ERROR the parameter type `T` may not live long enough [E0309]
36     RefDoubleVariant1(&'a RequireOutlives<'b, T>)
37         //~^ the parameter type `T` may not live long enough [E0309]
38 }
39
40 fn main() { }