@@ -208,17 +208,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
208208 return Some ( region_name) ;
209209 }
210210
211- let ( _argument_name, argument_span) = self . get_argument_name_and_span_for_region (
212- mir, argument_index) ;
213-
214- let region_name = self . synthesize_region_name ( counter) ;
215-
216- diag. span_label (
217- argument_span,
218- format ! ( "lifetime `{}` appears in this argument" , region_name, ) ,
219- ) ;
220-
221- Some ( region_name)
211+ self . give_name_if_we_cannot_match_hir_ty (
212+ infcx,
213+ mir,
214+ fr,
215+ arg_ty,
216+ counter,
217+ diag,
218+ )
222219 }
223220
224221 fn give_name_if_we_can_match_hir_ty_from_argument (
@@ -336,14 +333,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
336333
337334 search_stack. push ( ( argument_ty, argument_hir_ty) ) ;
338335
339- let mut closest_match: & hir:: Ty = argument_hir_ty;
340-
341336 while let Some ( ( ty, hir_ty) ) = search_stack. pop ( ) {
342- // While we search, also track the closet match.
343- if tcx. any_free_region_meets ( & ty, |r| r. to_region_vid ( ) == needle_fr) {
344- closest_match = hir_ty;
345- }
346-
347337 match ( & ty. sty , & hir_ty. node ) {
348338 // Check if the `argument_ty` is `&'X ..` where `'X`
349339 // is the region we are looking for -- if so, and we have a `&T`
@@ -418,13 +408,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
418408 }
419409 }
420410
421- let region_name = self . synthesize_region_name ( counter) ;
422- diag. span_label (
423- closest_match. span ,
424- format ! ( "lifetime `{}` appears in this type" , region_name) ,
425- ) ;
426-
427- return Some ( region_name) ;
411+ return None ;
428412 }
429413
430414 /// We've found an enum/struct/union type with the substitutions
0 commit comments