@@ -336,27 +336,18 @@ 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
- if let Some ( highlight) =
340
- self . highlight_if_we_can_match_hir_ty_from_argument ( fr, arg_ty, argument_index)
341
- {
342
- return Some ( RegionName {
343
- name : self . synthesize_region_name ( ) ,
344
- source : RegionNameSource :: AnonRegionFromArgument ( highlight) ,
345
- } ) ;
346
- }
347
-
348
- let counter = * self . next_region_name . try_borrow ( ) . unwrap ( ) ;
349
- if let Some ( highlight) = self . highlight_if_we_cannot_match_hir_ty ( fr, arg_ty, counter) {
350
- Some ( RegionName {
351
- // This counter value will already have been used, so this function will increment
352
- // it so the next value will be used next and return the region name that would
353
- // have been used.
339
+ self . highlight_if_we_can_match_hir_ty_from_argument ( fr, arg_ty, argument_index)
340
+ . or_else ( || {
341
+ // `highlight_if_we_cannot_match_hir_ty` needs to know the number we will give to
342
+ // the anonymous region. If it succeeds, the `synthesize_region_name` call below
343
+ // will increment the counter, "reserving" the number we just used.
344
+ let counter = * self . next_region_name . try_borrow ( ) . unwrap ( ) ;
345
+ self . highlight_if_we_cannot_match_hir_ty ( fr, arg_ty, counter)
346
+ } )
347
+ . map ( |highlight| RegionName {
354
348
name : self . synthesize_region_name ( ) ,
355
349
source : RegionNameSource :: AnonRegionFromArgument ( highlight) ,
356
350
} )
357
- } else {
358
- None
359
- }
360
351
}
361
352
362
353
fn highlight_if_we_can_match_hir_ty_from_argument (
0 commit comments