]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / rfc-2093-infer-outlives / regions-enum-not-wf.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-tidy-linelength
12
13 // Various examples of structs whose fields are not well-formed.
14
15 #![allow(dead_code)]
16
17 trait Dummy<'a> {
18   type Out;
19 }
20 impl<'a, T> Dummy<'a> for T
21 where T: 'a
22 {
23   type Out = ();
24 }
25 type RequireOutlives<'a, T> = <T as Dummy<'a>>::Out;
26
27 enum Ref1<'a, T> {
28     Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough
29 }
30
31 enum Ref2<'a, T> {
32     Ref2Variant1,
33     Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough
34 }
35
36 enum RefOk<'a, T:'a> {
37     RefOkVariant1(&'a T)
38 }
39
40 // This is now well formed. RFC 2093
41 enum RefIndirect<'a, T> {
42     RefIndirectVariant1(isize, RefOk<'a,T>)
43 }
44
45 enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309]
46     RefDoubleVariant1(&'a RequireOutlives<'b, T>)
47         //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309]
48 }
49
50 fn main() { }