@@ -242,17 +242,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
242
242
return Some ( region_name) ;
243
243
}
244
244
245
- let ( _argument_name, argument_span) = self . get_argument_name_and_span_for_region (
246
- mir, argument_index) ;
247
-
248
- let region_name = self . synthesize_region_name ( counter) ;
249
-
250
- diag. span_label (
251
- argument_span,
252
- format ! ( "lifetime `{}` appears in this argument" , region_name, ) ,
253
- ) ;
254
-
255
- 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
+ )
256
253
}
257
254
258
255
fn give_name_if_we_can_match_hir_ty_from_argument (
@@ -370,14 +367,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
370
367
371
368
search_stack. push ( ( argument_ty, argument_hir_ty) ) ;
372
369
373
- let mut closest_match: & hir:: Ty = argument_hir_ty;
374
-
375
370
while let Some ( ( ty, hir_ty) ) = search_stack. pop ( ) {
376
- // While we search, also track the closet match.
377
- if tcx. any_free_region_meets ( & ty, |r| r. to_region_vid ( ) == needle_fr) {
378
- closest_match = hir_ty;
379
- }
380
-
381
371
match ( & ty. sty , & hir_ty. node ) {
382
372
// Check if the `argument_ty` is `&'X ..` where `'X`
383
373
// is the region we are looking for -- if so, and we have a `&T`
@@ -452,13 +442,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
452
442
}
453
443
}
454
444
455
- let region_name = self . synthesize_region_name ( counter) ;
456
- diag. span_label (
457
- closest_match. span ,
458
- format ! ( "lifetime `{}` appears in this type" , region_name) ,
459
- ) ;
460
-
461
- return Some ( region_name) ;
445
+ return None ;
462
446
}
463
447
464
448
/// We've found an enum/struct/union type with the substitutions
0 commit comments