File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
src/librustc_infer/infer/error_reporting Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -297,7 +297,18 @@ pub fn unexpected_hidden_region_diagnostic(
297
297
) ;
298
298
299
299
// Explain the region we are capturing.
300
- if let ty:: ReEarlyBound ( _) | ty:: ReFree ( _) | ty:: ReStatic | ty:: ReEmpty ( _) = hidden_region {
300
+ match hidden_region {
301
+ ty:: ReEmpty ( ty:: UniverseIndex :: ROOT ) => {
302
+ // All lifetimes shorter than the function body are `empty` in
303
+ // lexical region resolution. The default explanation of "an empty
304
+ // lifetime" isn't really accurate here.
305
+ let message = format ! (
306
+ "hidden type `{}` captures lifetime smaller than the function body" ,
307
+ hidden_ty
308
+ ) ;
309
+ err. span_note ( span, & message) ;
310
+ }
311
+ ty:: ReEarlyBound ( _) | ty:: ReFree ( _) | ty:: ReStatic | ty:: ReEmpty ( _) => {
301
312
// Assuming regionck succeeded (*), we ought to always be
302
313
// capturing *some* region from the fn header, and hence it
303
314
// ought to be free. So under normal circumstances, we will go
@@ -313,7 +324,8 @@ pub fn unexpected_hidden_region_diagnostic(
313
324
hidden_region,
314
325
"" ,
315
326
) ;
316
- } else {
327
+ }
328
+ _ => {
317
329
// Ugh. This is a painful case: the hidden region is not one
318
330
// that we can easily summarize or explain. This can happen
319
331
// in a case like
@@ -358,6 +370,7 @@ pub fn unexpected_hidden_region_diagnostic(
358
370
) ;
359
371
}
360
372
}
373
+ }
361
374
362
375
err
363
376
}
You can’t perform that action at this time.
0 commit comments