Skip to content

Commit 030d60f

Browse files
committed
more tests
1 parent dca15fd commit 030d60f

File tree

5 files changed

+208
-37
lines changed

5 files changed

+208
-37
lines changed

src/test/ui/nll/user-annotations/normalization-2.rs

+42-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,20 @@ enum MyTy<T> {
2323
}
2424

2525
impl<T> MyTy<T> {
26+
const CONST: () = ();
2627
fn method<X>() {}
2728
fn method2<X>(&self) {}
2829
}
2930

31+
trait TraitAssoc {
32+
const TRAIT_CONST: ();
33+
fn trait_method<X>(&self);
34+
}
35+
impl<T> TraitAssoc for T {
36+
const TRAIT_CONST: () = ();
37+
fn trait_method<X>(&self) {}
38+
}
39+
3040
type Ty<'a> = <&'a () as Trait>::Assoc;
3141

3242
fn test_local<'a>() {
@@ -41,13 +51,30 @@ fn test_closure_sig<'a, 'b>() {
4151
//~^ ERROR lifetime may not live long enough
4252
}
4353

44-
fn test_path<'a, 'b, 'c, 'd>() {
54+
fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() {
4555
<Ty<'a>>::method::<Ty<'static>>;
4656
//~^ ERROR lifetime may not live long enough
4757
<Ty<'static>>::method::<Ty<'b>>;
4858
//~^ ERROR lifetime may not live long enough
4959

50-
MyTy::Unit::<Ty<'c>>;
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
64+
65+
<Ty<'e>>::CONST;
66+
//~^ ERROR lifetime may not live long enough
67+
<Ty<'f>>::TRAIT_CONST;
68+
//~^ ERROR lifetime may not live long enough
69+
70+
<Ty<'static>>::method::<Ty<'static>>;
71+
<Ty<'static>>::trait_method::<Ty<'static>>;
72+
<Ty<'static>>::CONST;
73+
<Ty<'static>>::TRAIT_CONST;
74+
75+
MyTy::Unit::<Ty<'g>>;
76+
//~^ ERROR lifetime may not live long enough
77+
MyTy::<Ty<'h>>::Unit;
5178
//~^ ERROR lifetime may not live long enough
5279
}
5380

@@ -67,9 +94,11 @@ fn test_variants<'a, 'b, 'c>() {
6794
//~^ ERROR lifetime may not live long enough
6895
}
6996

70-
fn test_method_call<'a>(x: MyTy<()>) {
97+
fn test_method_call<'a, 'b>(x: MyTy<()>) {
7198
x.method2::<Ty<'a>>();
7299
//~^ ERROR lifetime may not live long enough
100+
x.trait_method::<Ty<'b>>();
101+
//~^ ERROR lifetime may not live long enough
73102
}
74103

75104
fn test_struct_path<'a, 'b, 'c, 'd>() {
@@ -97,7 +126,7 @@ fn test_struct_path<'a, 'b, 'c, 'd>() {
97126
//~^ ERROR lifetime may not live long enough
98127
}
99128

100-
fn test_pattern<'a, 'b, 'c>() {
129+
fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() {
101130
use MyTy::*;
102131
match MyTy::Unit {
103132
Struct::<Ty<'a>> {..} => {},
@@ -108,6 +137,15 @@ fn test_pattern<'a, 'b, 'c>() {
108137
//~^ ERROR lifetime may not live long enough
109138
Dumb(_) => {},
110139
};
140+
match MyTy::Unit {
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
147+
Dumb(_) => {},
148+
};
111149
}
112150

113151

src/test/ui/nll/user-annotations/normalization-2.stderr

+123-29
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
error: lifetime may not live long enough
2-
--> $DIR/normalization-2.rs:33:12
2+
--> $DIR/normalization-2.rs:43:12
33
|
44
LL | fn test_local<'a>() {
55
| -- lifetime `'a` defined here
66
LL | let _: Ty<'a> = MyTy::Unit;
77
| ^^^^^^ requires that `'a` must outlive `'static`
88

99
error: lifetime may not live long enough
10-
--> $DIR/normalization-2.rs:38:6
10+
--> $DIR/normalization-2.rs:48:6
1111
|
1212
LL | fn test_closure_sig<'a, 'b>() {
1313
| -- lifetime `'a` defined here
1414
LL | |_: Ty<'a>| {};
1515
| ^ requires that `'a` must outlive `'static`
1616

1717
error: lifetime may not live long enough
18-
--> $DIR/normalization-2.rs:40:11
18+
--> $DIR/normalization-2.rs:50:11
1919
|
2020
LL | fn test_closure_sig<'a, 'b>() {
2121
| -- lifetime `'b` defined here
@@ -29,47 +29,97 @@ help: the following changes may resolve your lifetime errors
2929
= help: replace `'b` with `'static`
3030

3131
error: lifetime may not live long enough
32-
--> $DIR/normalization-2.rs:45:5
32+
--> $DIR/normalization-2.rs:55:5
3333
|
34-
LL | fn test_path<'a, 'b, 'c, 'd>() {
34+
LL | fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() {
3535
| -- lifetime `'a` defined here
3636
LL | <Ty<'a>>::method::<Ty<'static>>;
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
3838

3939
error: lifetime may not live long enough
40-
--> $DIR/normalization-2.rs:47:5
40+
--> $DIR/normalization-2.rs:57:5
4141
|
42-
LL | fn test_path<'a, 'b, 'c, 'd>() {
42+
LL | fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() {
4343
| -- lifetime `'b` defined here
4444
...
4545
LL | <Ty<'static>>::method::<Ty<'b>>;
4646
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static`
4747

4848
error: lifetime may not live long enough
49-
--> $DIR/normalization-2.rs:50:5
49+
--> $DIR/normalization-2.rs:60:5
5050
|
51-
LL | fn test_path<'a, 'b, 'c, 'd>() {
51+
LL | fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() {
5252
| -- lifetime `'c` defined here
5353
...
54-
LL | MyTy::Unit::<Ty<'c>>;
55-
| ^^^^^^^^^^^^^^^^^^^^ requires that `'c` must outlive `'static`
54+
LL | <Ty<'c>>::trait_method::<Ty<'static>>;
55+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'c` must outlive `'static`
56+
57+
error: lifetime may not live long enough
58+
--> $DIR/normalization-2.rs:62:5
59+
|
60+
LL | fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() {
61+
| -- lifetime `'d` defined here
62+
...
63+
LL | <Ty<'static>>::trait_method::<Ty<'d>>;
64+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'d` must outlive `'static`
65+
66+
error: lifetime may not live long enough
67+
--> $DIR/normalization-2.rs:65:5
68+
|
69+
LL | fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() {
70+
| -- lifetime `'e` defined here
71+
...
72+
LL | <Ty<'e>>::CONST;
73+
| ^^^^^^^^^^^^^^^ requires that `'e` must outlive `'static`
74+
75+
error: lifetime may not live long enough
76+
--> $DIR/normalization-2.rs:67:5
77+
|
78+
LL | fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() {
79+
| -- lifetime `'f` defined here
80+
...
81+
LL | <Ty<'f>>::TRAIT_CONST;
82+
| ^^^^^^^^^^^^^^^^^^^^^ requires that `'f` must outlive `'static`
83+
84+
error: lifetime may not live long enough
85+
--> $DIR/normalization-2.rs:75:5
86+
|
87+
LL | fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() {
88+
| -- lifetime `'g` defined here
89+
...
90+
LL | MyTy::Unit::<Ty<'g>>;
91+
| ^^^^^^^^^^^^^^^^^^^^ requires that `'g` must outlive `'static`
92+
93+
error: lifetime may not live long enough
94+
--> $DIR/normalization-2.rs:77:5
95+
|
96+
LL | fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() {
97+
| -- lifetime `'h` defined here
98+
...
99+
LL | MyTy::<Ty<'h>>::Unit;
100+
| ^^^^^^^^^^^^^^^^^^^^ requires that `'h` must outlive `'static`
56101

57102
help: the following changes may resolve your lifetime errors
58103
|
59104
= help: replace `'a` with `'static`
60105
= help: replace `'b` with `'static`
61106
= help: replace `'c` with `'static`
107+
= help: replace `'d` with `'static`
108+
= help: replace `'e` with `'static`
109+
= help: replace `'f` with `'static`
110+
= help: replace `'g` with `'static`
111+
= help: replace `'h` with `'static`
62112

63113
error: lifetime may not live long enough
64-
--> $DIR/normalization-2.rs:55:5
114+
--> $DIR/normalization-2.rs:82:5
65115
|
66116
LL | fn test_call<'a, 'b, 'c>() {
67117
| -- lifetime `'a` defined here
68118
LL | <Ty<'a>>::method::<Ty<'static>>();
69119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
70120

71121
error: lifetime may not live long enough
72-
--> $DIR/normalization-2.rs:57:5
122+
--> $DIR/normalization-2.rs:84:5
73123
|
74124
LL | fn test_call<'a, 'b, 'c>() {
75125
| -- lifetime `'b` defined here
@@ -83,15 +133,15 @@ help: the following changes may resolve your lifetime errors
83133
= help: replace `'b` with `'static`
84134

85135
error: lifetime may not live long enough
86-
--> $DIR/normalization-2.rs:62:5
136+
--> $DIR/normalization-2.rs:89:5
87137
|
88138
LL | fn test_variants<'a, 'b, 'c>() {
89139
| -- lifetime `'a` defined here
90140
LL | <Ty<'a>>::Struct {};
91141
| ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
92142

93143
error: lifetime may not live long enough
94-
--> $DIR/normalization-2.rs:64:5
144+
--> $DIR/normalization-2.rs:91:5
95145
|
96146
LL | fn test_variants<'a, 'b, 'c>() {
97147
| -- lifetime `'b` defined here
@@ -100,7 +150,7 @@ LL | <Ty<'b>>::Tuple();
100150
| ^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static`
101151

102152
error: lifetime may not live long enough
103-
--> $DIR/normalization-2.rs:66:5
153+
--> $DIR/normalization-2.rs:93:5
104154
|
105155
LL | fn test_variants<'a, 'b, 'c>() {
106156
| -- lifetime `'c` defined here
@@ -115,15 +165,29 @@ help: the following changes may resolve your lifetime errors
115165
= help: replace `'c` with `'static`
116166

117167
error: lifetime may not live long enough
118-
--> $DIR/normalization-2.rs:71:7
168+
--> $DIR/normalization-2.rs:98:7
119169
|
120-
LL | fn test_method_call<'a>(x: MyTy<()>) {
170+
LL | fn test_method_call<'a, 'b>(x: MyTy<()>) {
121171
| -- lifetime `'a` defined here
122172
LL | x.method2::<Ty<'a>>();
123173
| ^^^^^^^ requires that `'a` must outlive `'static`
124174

125175
error: lifetime may not live long enough
126-
--> $DIR/normalization-2.rs:88:5
176+
--> $DIR/normalization-2.rs:100:7
177+
|
178+
LL | fn test_method_call<'a, 'b>(x: MyTy<()>) {
179+
| -- lifetime `'b` defined here
180+
...
181+
LL | x.trait_method::<Ty<'b>>();
182+
| ^^^^^^^^^^^^ requires that `'b` must outlive `'static`
183+
184+
help: the following changes may resolve your lifetime errors
185+
|
186+
= help: replace `'a` with `'static`
187+
= help: replace `'b` with `'static`
188+
189+
error: lifetime may not live long enough
190+
--> $DIR/normalization-2.rs:117:5
127191
|
128192
LL | fn test_struct_path<'a, 'b, 'c, 'd>() {
129193
| -- lifetime `'a` defined here
@@ -132,7 +196,7 @@ LL | MyTy::<Ty<'a>>::Struct {}; // without SelfTy
132196
| ^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
133197

134198
error: lifetime may not live long enough
135-
--> $DIR/normalization-2.rs:90:5
199+
--> $DIR/normalization-2.rs:119:5
136200
|
137201
LL | fn test_struct_path<'a, 'b, 'c, 'd>() {
138202
| -- lifetime `'b` defined here
@@ -141,7 +205,7 @@ LL | <Ty<'b> as Project>::Enum::Struct {}; // with SelfTy
141205
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static`
142206

143207
error: lifetime may not live long enough
144-
--> $DIR/normalization-2.rs:94:5
208+
--> $DIR/normalization-2.rs:123:5
145209
|
146210
LL | fn test_struct_path<'a, 'b, 'c, 'd>() {
147211
| -- lifetime `'c` defined here
@@ -150,7 +214,7 @@ LL | Struct::<Ty<'c>> { x: None, }; // without SelfTy
150214
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'c` must outlive `'static`
151215

152216
error: lifetime may not live long enough
153-
--> $DIR/normalization-2.rs:96:5
217+
--> $DIR/normalization-2.rs:125:5
154218
|
155219
LL | fn test_struct_path<'a, 'b, 'c, 'd>() {
156220
| -- lifetime `'d` defined here
@@ -166,37 +230,67 @@ help: the following changes may resolve your lifetime errors
166230
= help: replace `'d` with `'static`
167231

168232
error: lifetime may not live long enough
169-
--> $DIR/normalization-2.rs:103:9
233+
--> $DIR/normalization-2.rs:132:9
170234
|
171-
LL | fn test_pattern<'a, 'b, 'c>() {
235+
LL | fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() {
172236
| -- lifetime `'a` defined here
173237
...
174238
LL | Struct::<Ty<'a>> {..} => {},
175239
| ^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
176240

177241
error: lifetime may not live long enough
178-
--> $DIR/normalization-2.rs:105:9
242+
--> $DIR/normalization-2.rs:134:9
179243
|
180-
LL | fn test_pattern<'a, 'b, 'c>() {
244+
LL | fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() {
181245
| -- lifetime `'b` defined here
182246
...
183247
LL | Tuple::<Ty<'b>> (..) => {},
184248
| ^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static`
185249

186250
error: lifetime may not live long enough
187-
--> $DIR/normalization-2.rs:107:9
251+
--> $DIR/normalization-2.rs:136:9
188252
|
189-
LL | fn test_pattern<'a, 'b, 'c>() {
253+
LL | fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() {
190254
| -- lifetime `'c` defined here
191255
...
192256
LL | Unit::<Ty<'c>> => {},
193257
| ^^^^^^^^^^^^^^ requires that `'c` must outlive `'static`
194258

259+
error: lifetime may not live long enough
260+
--> $DIR/normalization-2.rs:141:9
261+
|
262+
LL | fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() {
263+
| -- lifetime `'d` defined here
264+
...
265+
LL | <Ty<'d>>::Struct {..} => {},
266+
| ^^^^^^^^^^^^^^^^^^^^^ requires that `'d` must outlive `'static`
267+
268+
error: lifetime may not live long enough
269+
--> $DIR/normalization-2.rs:143:9
270+
|
271+
LL | fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() {
272+
| -- lifetime `'e` defined here
273+
...
274+
LL | <Ty<'e>>::Tuple (..) => {},
275+
| ^^^^^^^^^^^^^^^^^^^^ requires that `'e` must outlive `'static`
276+
277+
error: lifetime may not live long enough
278+
--> $DIR/normalization-2.rs:145:9
279+
|
280+
LL | fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() {
281+
| -- lifetime `'f` defined here
282+
...
283+
LL | <Ty<'f>>::Unit => {},
284+
| ^^^^^^^^^^^^^^ requires that `'f` must outlive `'static`
285+
195286
help: the following changes may resolve your lifetime errors
196287
|
197288
= help: replace `'a` with `'static`
198289
= help: replace `'b` with `'static`
199290
= help: replace `'c` with `'static`
291+
= help: replace `'d` with `'static`
292+
= help: replace `'e` with `'static`
293+
= help: replace `'f` with `'static`
200294

201-
error: aborting due to 19 previous errors
295+
error: aborting due to 28 previous errors
202296

0 commit comments

Comments
 (0)