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(
297297 ) ;
298298
299299 // 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 ( _) => {
301312 // Assuming regionck succeeded (*), we ought to always be
302313 // capturing *some* region from the fn header, and hence it
303314 // ought to be free. So under normal circumstances, we will go
@@ -313,7 +324,8 @@ pub fn unexpected_hidden_region_diagnostic(
313324 hidden_region,
314325 "" ,
315326 ) ;
316- } else {
327+ }
328+ _ => {
317329 // Ugh. This is a painful case: the hidden region is not one
318330 // that we can easily summarize or explain. This can happen
319331 // in a case like
@@ -358,6 +370,7 @@ pub fn unexpected_hidden_region_diagnostic(
358370 ) ;
359371 }
360372 }
373+ }
361374
362375 err
363376}
You can’t perform that action at this time.
0 commit comments