@@ -242,17 +242,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
242242 return Some ( region_name) ;
243243 }
244244
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+ )
256253 }
257254
258255 fn give_name_if_we_can_match_hir_ty_from_argument (
@@ -370,14 +367,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
370367
371368 search_stack. push ( ( argument_ty, argument_hir_ty) ) ;
372369
373- let mut closest_match: & hir:: Ty = argument_hir_ty;
374-
375370 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-
381371 match ( & ty. sty , & hir_ty. node ) {
382372 // Check if the `argument_ty` is `&'X ..` where `'X`
383373 // is the region we are looking for -- if so, and we have a `&T`
@@ -452,13 +442,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
452442 }
453443 }
454444
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 ;
462446 }
463447
464448 /// We've found an enum/struct/union type with the substitutions
0 commit comments