1 // Make sure we honor region constraints when normalizing type annotations.
5 #![feature(more_qualified_paths)]
15 type Assoc = MyTy<()>;
28 fn method2<X>(&self) {}
32 const TRAIT_CONST: ();
33 fn trait_method<X>(&self);
35 impl<T> TraitAssoc for T {
36 const TRAIT_CONST: () = ();
37 fn trait_method<X>(&self) {}
40 type Ty<'a> = <&'a () as Trait>::Assoc;
43 let _: Ty<'a> = MyTy::Unit;
44 //~^ ERROR lifetime may not live long enough
47 fn test_closure_sig<'a, 'b>() {
49 //~^ ERROR lifetime may not live long enough
50 || -> Option<Ty<'b>> { None };
51 //~^ ERROR lifetime may not live long enough
54 fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() {
55 <Ty<'a>>::method::<Ty<'static>>;
56 //~^ ERROR lifetime may not live long enough
57 <Ty<'static>>::method::<Ty<'b>>;
58 //~^ ERROR lifetime may not live long enough
60 <Ty<'c>>::trait_method::<Ty<'static>>;
61 //~^ ERROR lifetime may not live long enough
62 <Ty<'static>>::trait_method::<Ty<'d>>;
63 //~^ ERROR lifetime may not live long enough
66 //~^ ERROR lifetime may not live long enough
67 <Ty<'f>>::TRAIT_CONST;
68 //~^ ERROR lifetime may not live long enough
70 <Ty<'static>>::method::<Ty<'static>>;
71 <Ty<'static>>::trait_method::<Ty<'static>>;
73 <Ty<'static>>::TRAIT_CONST;
76 //~^ ERROR lifetime may not live long enough
78 //~^ ERROR lifetime may not live long enough
81 fn test_call<'a, 'b, 'c>() {
82 <Ty<'a>>::method::<Ty<'static>>();
83 //~^ ERROR lifetime may not live long enough
84 <Ty<'static>>::method::<Ty<'b>>();
85 //~^ ERROR lifetime may not live long enough
88 fn test_variants<'a, 'b, 'c>() {
90 //~^ ERROR lifetime may not live long enough
92 //~^ ERROR lifetime may not live long enough
94 //~^ ERROR lifetime may not live long enough
97 fn test_method_call<'a, 'b>(x: MyTy<()>) {
98 x.method2::<Ty<'a>>();
99 //~^ ERROR lifetime may not live long enough
100 x.trait_method::<Ty<'b>>();
101 //~^ ERROR lifetime may not live long enough
104 fn test_struct_path<'a, 'b, 'c, 'd>() {
105 struct Struct<T> { x: Option<T>, }
111 impl<T> Project for T {
112 type Struct = Struct<()>;
113 type Enum = MyTy<()>;
116 // Resolves to enum variant
117 MyTy::<Ty<'a>>::Struct {}; // without SelfTy
118 //~^ ERROR lifetime may not live long enough
119 <Ty<'b> as Project>::Enum::Struct {}; // with SelfTy
120 //~^ ERROR lifetime may not live long enough
122 // Resolves to struct and associated type respectively
123 Struct::<Ty<'c>> { x: None, }; // without SelfTy
124 //~^ ERROR lifetime may not live long enough
125 <Ty<'d> as Project>::Struct { x: None, }; // with SelfTy
126 //~^ ERROR lifetime may not live long enough
129 fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() {
132 Struct::<Ty<'a>> {..} => {},
133 //~^ ERROR lifetime may not live long enough
134 Tuple::<Ty<'b>> (..) => {},
135 //~^ ERROR lifetime may not live long enough
136 Unit::<Ty<'c>> => {},
137 //~^ ERROR lifetime may not live long enough
141 <Ty<'d>>::Struct {..} => {},
142 //~^ ERROR lifetime may not live long enough
143 <Ty<'e>>::Tuple (..) => {},
144 //~^ ERROR lifetime may not live long enough
145 <Ty<'f>>::Unit => {},
146 //~^ ERROR lifetime may not live long enough