@@ -95,8 +95,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
95
95
debug ! ( "give_region_a_name: error_region = {:?}" , error_region) ;
96
96
match error_region {
97
97
ty:: ReEarlyBound ( ebr) => {
98
- self . highlight_named_span ( tcx, error_region, & ebr. name , diag) ;
99
- Some ( ebr. name )
98
+ if ebr. has_name ( ) {
99
+ self . highlight_named_span ( tcx, error_region, & ebr. name , diag) ;
100
+ Some ( ebr. name )
101
+ } else {
102
+ None
103
+ }
100
104
} ,
101
105
102
106
ty:: ReStatic => Some ( keywords:: StaticLifetime . name ( ) . as_interned_str ( ) ) ,
@@ -238,17 +242,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
238
242
return Some ( region_name) ;
239
243
}
240
244
241
- let ( _argument_name, argument_span) = self . get_argument_name_and_span_for_region (
242
- mir, argument_index) ;
243
-
244
- let region_name = self . synthesize_region_name ( counter) ;
245
-
246
- diag. span_label (
247
- argument_span,
248
- format ! ( "lifetime `{}` appears in this argument" , region_name, ) ,
249
- ) ;
250
-
251
- Some ( region_name)
245
+ self . give_name_if_we_cannot_match_hir_ty (
246
+ infcx,
247
+ mir,
248
+ fr,
249
+ arg_ty,
250
+ counter,
251
+ diag,
252
+ )
252
253
}
253
254
254
255
fn give_name_if_we_can_match_hir_ty_from_argument (
@@ -366,14 +367,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
366
367
367
368
search_stack. push ( ( argument_ty, argument_hir_ty) ) ;
368
369
369
- let mut closest_match: & hir:: Ty = argument_hir_ty;
370
-
371
370
while let Some ( ( ty, hir_ty) ) = search_stack. pop ( ) {
372
- // While we search, also track the closet match.
373
- if tcx. any_free_region_meets ( & ty, |r| r. to_region_vid ( ) == needle_fr) {
374
- closest_match = hir_ty;
375
- }
376
-
377
371
match ( & ty. sty , & hir_ty. node ) {
378
372
// Check if the `argument_ty` is `&'X ..` where `'X`
379
373
// is the region we are looking for -- if so, and we have a `&T`
@@ -448,13 +442,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
448
442
}
449
443
}
450
444
451
- let region_name = self . synthesize_region_name ( counter) ;
452
- diag. span_label (
453
- closest_match. span ,
454
- format ! ( "lifetime `{}` appears in this type" , region_name) ,
455
- ) ;
456
-
457
- return Some ( region_name) ;
445
+ return None ;
458
446
}
459
447
460
448
/// We've found an enum/struct/union type with the substitutions
0 commit comments