@@ -336,13 +336,19 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
336
336
337
337
let arg_ty = self . regioncx . universal_regions ( ) . unnormalized_input_tys
338
338
[ implicit_inputs + argument_index] ;
339
+ let ( _, span) = self . regioncx . get_argument_name_and_span_for_region (
340
+ & self . body ,
341
+ & self . local_names ,
342
+ argument_index,
343
+ ) ;
344
+
339
345
self . highlight_if_we_can_match_hir_ty_from_argument ( fr, arg_ty, argument_index)
340
346
. or_else ( || {
341
347
// `highlight_if_we_cannot_match_hir_ty` needs to know the number we will give to
342
348
// the anonymous region. If it succeeds, the `synthesize_region_name` call below
343
349
// will increment the counter, "reserving" the number we just used.
344
350
let counter = * self . next_region_name . try_borrow ( ) . unwrap ( ) ;
345
- self . highlight_if_we_cannot_match_hir_ty ( fr, arg_ty, counter)
351
+ self . highlight_if_we_cannot_match_hir_ty ( fr, arg_ty, span , counter)
346
352
} )
347
353
. map ( |highlight| RegionName {
348
354
name : self . synthesize_region_name ( ) ,
@@ -385,26 +391,20 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
385
391
fn highlight_if_we_cannot_match_hir_ty (
386
392
& self ,
387
393
needle_fr : RegionVid ,
388
- argument_ty : Ty < ' tcx > ,
394
+ ty : Ty < ' tcx > ,
395
+ span : Span ,
389
396
counter : usize ,
390
397
) -> Option < RegionNameHighlight > {
391
398
let mut highlight = RegionHighlightMode :: default ( ) ;
392
399
highlight. highlighting_region_vid ( needle_fr, counter) ;
393
- let type_name = self . infcx . extract_type_name ( & argument_ty , Some ( highlight) ) . 0 ;
400
+ let type_name = self . infcx . extract_type_name ( & ty , Some ( highlight) ) . 0 ;
394
401
395
402
debug ! (
396
403
"highlight_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}" ,
397
404
type_name, needle_fr
398
405
) ;
399
406
if type_name. find ( & format ! ( "'{}" , counter) ) . is_some ( ) {
400
407
// Only add a label if we can confirm that a region was labelled.
401
- let argument_index =
402
- self . regioncx . get_argument_index_for_region ( self . infcx . tcx , needle_fr) ?;
403
- let ( _, span) = self . regioncx . get_argument_name_and_span_for_region (
404
- & self . body ,
405
- & self . local_names ,
406
- argument_index,
407
- ) ;
408
408
409
409
Some ( RegionNameHighlight :: CannotMatchHirTy ( span, type_name) )
410
410
} else {
0 commit comments