Skip to content

Commit f87189d

Browse files
committed
update tests and add stderr files
1 parent a13c9f6 commit f87189d

10 files changed

+72
-81
lines changed

src/test/ui/nll/ty-outlives/projection-body.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Test that when we infer the lifetime to a subset of the fn body, it
22
// works out.
3+
//
4+
// compile-pass
35

46
trait MyTrait<'a> {
57
type Output;

src/test/ui/nll/ty-outlives/projection-one-region-closure.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,10 @@ where
7474
T: Anything<'b>,
7575
T::AssocType: 'a,
7676
{
77-
// This error is unfortunate. This code ought to type-check: we
78-
// are projecting `<T as Anything<'b>>::AssocType`, and we know
79-
// that this outlives `'a` because of the where-clause. However,
80-
// the way the region checker works, we don't register this
81-
// outlives obligation, and hence we get an error: this is because
82-
// what we see is a projection like `<T as
83-
// Anything<'?0>>::AssocType`, and we don't yet know if `?0` will
84-
// equal `'b` or not, so we ignore the where-clause. Obviously we
85-
// can do better here with a more involved verification step.
77+
// We are projecting `<T as Anything<'b>>::AssocType`, and we know
78+
// that this outlives `'a` because of the where-clause.
8679

8780
with_signature(cell, t, |cell, t| require(cell, t));
88-
//~^ ERROR
8981
}
9082

9183
#[rustc_regions]

src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
106106
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ closure body requires that `'b` must outlive `'a`
107107

108108
note: External requirements
109-
--> $DIR/projection-one-region-closure.rs:87:29
109+
--> $DIR/projection-one-region-closure.rs:80:29
110110
|
111111
LL | with_signature(cell, t, |cell, t| require(cell, t));
112112
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -129,7 +129,7 @@ LL | | where
129129
LL | | T: Anything<'b>,
130130
LL | | T::AssocType: 'a,
131131
... |
132-
LL | | //~^ ERROR
132+
LL | | with_signature(cell, t, |cell, t| require(cell, t));
133133
LL | | }
134134
| |_^
135135
|
@@ -139,16 +139,8 @@ LL | | }
139139
T
140140
]
141141

142-
error[E0309]: the associated type `<T as Anything<'_#5r>>::AssocType` may not live long enough
143-
--> $DIR/projection-one-region-closure.rs:87:29
144-
|
145-
LL | with_signature(cell, t, |cell, t| require(cell, t));
146-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
147-
|
148-
= help: consider adding an explicit lifetime bound `<T as Anything<'_#5r>>::AssocType: ReEarlyBound(0, 'a)`...
149-
150142
note: External requirements
151-
--> $DIR/projection-one-region-closure.rs:98:29
143+
--> $DIR/projection-one-region-closure.rs:90:29
152144
|
153145
LL | with_signature(cell, t, |cell, t| require(cell, t));
154146
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -165,7 +157,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
165157
= note: where '_#2r: '_#3r
166158

167159
note: No external requirements
168-
--> $DIR/projection-one-region-closure.rs:92:1
160+
--> $DIR/projection-one-region-closure.rs:84:1
169161
|
170162
LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
171163
LL | | where
@@ -182,6 +174,6 @@ LL | | }
182174
T
183175
]
184176

185-
error: aborting due to 5 previous errors
177+
error: aborting due to 4 previous errors
186178

187179
For more information about this error, try `rustc --explain E0309`.

src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,10 @@ where
6464
T: Anything<'b>,
6565
T::AssocType: 'a,
6666
{
67-
// This error is unfortunate. This code ought to type-check: we
68-
// are projecting `<T as Anything<'b>>::AssocType`, and we know
69-
// that this outlives `'a` because of the where-clause. However,
70-
// the way the region checker works, we don't register this
71-
// outlives obligation, and hence we get an error: this is because
72-
// what we see is a projection like `<T as
73-
// Anything<'?0>>::AssocType`, and we don't yet know if `?0` will
74-
// equal `'b` or not, so we ignore the where-clause. Obviously we
75-
// can do better here with a more involved verification step.
67+
// We are projecting `<T as Anything<'b>>::AssocType`, and we know
68+
// that this outlives `'a` because of the where-clause.
7669

7770
with_signature(cell, t, |cell, t| require(cell, t));
78-
//~^ ERROR
7971
}
8072

8173
#[rustc_regions]

src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
8888
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ closure body requires that `'b` must outlive `'a`
8989

9090
note: External requirements
91-
--> $DIR/projection-one-region-trait-bound-closure.rs:77:29
91+
--> $DIR/projection-one-region-trait-bound-closure.rs:70:29
9292
|
9393
LL | with_signature(cell, t, |cell, t| require(cell, t));
9494
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -111,7 +111,7 @@ LL | | where
111111
LL | | T: Anything<'b>,
112112
LL | | T::AssocType: 'a,
113113
... |
114-
LL | | //~^ ERROR
114+
LL | | with_signature(cell, t, |cell, t| require(cell, t));
115115
LL | | }
116116
| |_^
117117
|
@@ -121,16 +121,8 @@ LL | | }
121121
T
122122
]
123123

124-
error[E0309]: the associated type `<T as Anything<'_#5r>>::AssocType` may not live long enough
125-
--> $DIR/projection-one-region-trait-bound-closure.rs:77:29
126-
|
127-
LL | with_signature(cell, t, |cell, t| require(cell, t));
128-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
129-
|
130-
= help: consider adding an explicit lifetime bound `<T as Anything<'_#5r>>::AssocType: ReEarlyBound(0, 'a)`...
131-
132124
note: External requirements
133-
--> $DIR/projection-one-region-trait-bound-closure.rs:87:29
125+
--> $DIR/projection-one-region-trait-bound-closure.rs:79:29
134126
|
135127
LL | with_signature(cell, t, |cell, t| require(cell, t));
136128
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -146,7 +138,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
146138
= note: where '_#2r: '_#3r
147139

148140
note: No external requirements
149-
--> $DIR/projection-one-region-trait-bound-closure.rs:82:1
141+
--> $DIR/projection-one-region-trait-bound-closure.rs:74:1
150142
|
151143
LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
152144
LL | | where
@@ -164,7 +156,7 @@ LL | | }
164156
]
165157

166158
note: External requirements
167-
--> $DIR/projection-one-region-trait-bound-closure.rs:99:29
159+
--> $DIR/projection-one-region-trait-bound-closure.rs:91:29
168160
|
169161
LL | with_signature(cell, t, |cell, t| require(cell, t));
170162
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -179,7 +171,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
179171
= note: where '_#1r: '_#2r
180172

181173
note: No external requirements
182-
--> $DIR/projection-one-region-trait-bound-closure.rs:91:1
174+
--> $DIR/projection-one-region-trait-bound-closure.rs:83:1
183175
|
184176
LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T)
185177
LL | | where
@@ -195,6 +187,5 @@ LL | | }
195187
T
196188
]
197189

198-
error: aborting due to 3 previous errors
190+
error: aborting due to 2 previous errors
199191

200-
For more information about this error, try `rustc --explain E0309`.

src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,10 @@ where
6565
T: Anything<'b, 'c>,
6666
T::AssocType: 'a,
6767
{
68-
// This error is unfortunate. This code ought to type-check: we
69-
// are projecting `<T as Anything<'b>>::AssocType`, and we know
70-
// that this outlives `'a` because of the where-clause. However,
71-
// the way the region checker works, we don't register this
72-
// outlives obligation, and hence we get an error: this is because
73-
// what we see is a projection like `<T as
74-
// Anything<'?0>>::AssocType`, and we don't yet know if `?0` will
75-
// equal `'b` or not, so we ignore the where-clause. Obviously we
76-
// can do better here with a more involved verification step.
68+
// We are projecting `<T as Anything<'b>>::AssocType`, and we know
69+
// that this outlives `'a` because of the where-clause.
7770

7871
with_signature(cell, t, |cell, t| require(cell, t));
79-
//~^ ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
8072
}
8173

8274
#[rustc_regions]

src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
8686
= help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: ReEarlyBound(0, 'a)`...
8787

8888
note: External requirements
89-
--> $DIR/projection-two-region-trait-bound-closure.rs:78:29
89+
--> $DIR/projection-two-region-trait-bound-closure.rs:71:29
9090
|
9191
LL | with_signature(cell, t, |cell, t| require(cell, t));
9292
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -110,7 +110,7 @@ LL | | where
110110
LL | | T: Anything<'b, 'c>,
111111
LL | | T::AssocType: 'a,
112112
... |
113-
LL | | //~^ ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
113+
LL | | with_signature(cell, t, |cell, t| require(cell, t));
114114
LL | | }
115115
| |_^
116116
|
@@ -121,16 +121,8 @@ LL | | }
121121
T
122122
]
123123

124-
error[E0309]: the associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
125-
--> $DIR/projection-two-region-trait-bound-closure.rs:78:29
126-
|
127-
LL | with_signature(cell, t, |cell, t| require(cell, t));
128-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
129-
|
130-
= help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: ReEarlyBound(0, 'a)`...
131-
132124
note: External requirements
133-
--> $DIR/projection-two-region-trait-bound-closure.rs:88:29
125+
--> $DIR/projection-two-region-trait-bound-closure.rs:80:29
134126
|
135127
LL | with_signature(cell, t, |cell, t| require(cell, t));
136128
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -147,7 +139,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
147139
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r
148140

149141
note: No external requirements
150-
--> $DIR/projection-two-region-trait-bound-closure.rs:83:1
142+
--> $DIR/projection-two-region-trait-bound-closure.rs:75:1
151143
|
152144
LL | / fn elements_outlive1<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
153145
LL | | where
@@ -166,7 +158,7 @@ LL | | }
166158
]
167159

168160
note: External requirements
169-
--> $DIR/projection-two-region-trait-bound-closure.rs:97:29
161+
--> $DIR/projection-two-region-trait-bound-closure.rs:89:29
170162
|
171163
LL | with_signature(cell, t, |cell, t| require(cell, t));
172164
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -183,7 +175,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
183175
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r
184176

185177
note: No external requirements
186-
--> $DIR/projection-two-region-trait-bound-closure.rs:92:1
178+
--> $DIR/projection-two-region-trait-bound-closure.rs:84:1
187179
|
188180
LL | / fn elements_outlive2<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
189181
LL | | where
@@ -202,7 +194,7 @@ LL | | }
202194
]
203195

204196
note: External requirements
205-
--> $DIR/projection-two-region-trait-bound-closure.rs:105:29
197+
--> $DIR/projection-two-region-trait-bound-closure.rs:97:29
206198
|
207199
LL | with_signature(cell, t, |cell, t| require(cell, t));
208200
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -218,7 +210,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
218210
= note: where <T as Anything<ReClosureBound('_#1r), ReClosureBound('_#1r)>>::AssocType: '_#2r
219211

220212
note: No external requirements
221-
--> $DIR/projection-two-region-trait-bound-closure.rs:101:1
213+
--> $DIR/projection-two-region-trait-bound-closure.rs:93:1
222214
|
223215
LL | / fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
224216
LL | | where
@@ -235,7 +227,7 @@ LL | | }
235227
]
236228

237229
error: unsatisfied lifetime constraints
238-
--> $DIR/projection-two-region-trait-bound-closure.rs:105:29
230+
--> $DIR/projection-two-region-trait-bound-closure.rs:97:29
239231
|
240232
LL | fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
241233
| -- -- lifetime `'b` defined here
@@ -246,7 +238,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
246238
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ closure body requires that `'b` must outlive `'a`
247239

248240
note: External requirements
249-
--> $DIR/projection-two-region-trait-bound-closure.rs:115:29
241+
--> $DIR/projection-two-region-trait-bound-closure.rs:107:29
250242
|
251243
LL | with_signature(cell, t, |cell, t| require(cell, t));
252244
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -262,7 +254,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
262254
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#2r)>>::AssocType: '_#3r
263255

264256
note: No external requirements
265-
--> $DIR/projection-two-region-trait-bound-closure.rs:110:1
257+
--> $DIR/projection-two-region-trait-bound-closure.rs:102:1
266258
|
267259
LL | / fn two_regions_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
268260
LL | | where
@@ -280,7 +272,7 @@ LL | | }
280272
]
281273

282274
note: External requirements
283-
--> $DIR/projection-two-region-trait-bound-closure.rs:127:29
275+
--> $DIR/projection-two-region-trait-bound-closure.rs:119:29
284276
|
285277
LL | with_signature(cell, t, |cell, t| require(cell, t));
286278
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -295,7 +287,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
295287
= note: where <T as Anything<ReClosureBound('_#1r), ReClosureBound('_#1r)>>::AssocType: '_#2r
296288

297289
note: No external requirements
298-
--> $DIR/projection-two-region-trait-bound-closure.rs:119:1
290+
--> $DIR/projection-two-region-trait-bound-closure.rs:111:1
299291
|
300292
LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T)
301293
LL | | where
@@ -311,6 +303,6 @@ LL | | }
311303
T
312304
]
313305

314-
error: aborting due to 4 previous errors
306+
error: aborting due to 3 previous errors
315307

316308
For more information about this error, try `rustc --explain E0309`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0309]: the associated type `<T as MyTrait<'_>>::Output` may not live long enough
2+
--> $DIR/projection-where-clause-env-wrong-bound.rs:17:5
3+
|
4+
LL | bar::<T::Output>() //~ ERROR may not live long enough
5+
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: consider adding an explicit lifetime bound `<T as MyTrait<'_>>::Output: 'a`...
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0309`.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0309]: the associated type `<T as MyTrait<'a>>::Output` may not live long enough
2+
--> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5
3+
|
4+
LL | bar::<<T as MyTrait<'a>>::Output>() //~ ERROR the associated type `<T as MyTrait<'a>>::Output` may not live long enough
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: consider adding an explicit lifetime bound `<T as MyTrait<'a>>::Output: 'a`...
8+
note: ...so that the type `<T as MyTrait<'a>>::Output` will meet its required lifetime bounds
9+
--> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5
10+
|
11+
LL | bar::<<T as MyTrait<'a>>::Output>() //~ ERROR the associated type `<T as MyTrait<'a>>::Output` may not live long enough
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
error: aborting due to previous error
15+
16+
For more information about this error, try `rustc --explain E0309`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0309]: the parameter type `T` may not live long enough
2+
--> $DIR/projection-where-clause-none.rs:16:5
3+
|
4+
LL | bar::<T::Output>() //~ ERROR the parameter type `T` may not live long enough
5+
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: consider adding an explicit lifetime bound `T: 'a`...
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0309`.

0 commit comments

Comments
 (0)