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