@@ -208,17 +208,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
208
208
return Some ( region_name) ;
209
209
}
210
210
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
+ )
222
219
}
223
220
224
221
fn give_name_if_we_can_match_hir_ty_from_argument (
@@ -336,14 +333,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
336
333
337
334
search_stack. push ( ( argument_ty, argument_hir_ty) ) ;
338
335
339
- let mut closest_match: & hir:: Ty = argument_hir_ty;
340
-
341
336
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
-
347
337
match ( & ty. sty , & hir_ty. node ) {
348
338
// Check if the `argument_ty` is `&'X ..` where `'X`
349
339
// is the region we are looking for -- if so, and we have a `&T`
@@ -418,13 +408,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
418
408
}
419
409
}
420
410
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 ;
428
412
}
429
413
430
414
/// We've found an enum/struct/union type with the substitutions
0 commit comments