@@ -433,7 +433,7 @@ struct ReverseMapper<'tcx> {
433
433
434
434
key : ty:: OpaqueTypeKey < ' tcx > ,
435
435
map : FxHashMap < GenericArg < ' tcx > , GenericArg < ' tcx > > ,
436
- map_missing_regions_to_empty : bool ,
436
+ do_not_error : bool ,
437
437
438
438
/// initially `Some`, set to `None` once error has been reported
439
439
hidden_ty : Option < Ty < ' tcx > > ,
@@ -450,29 +450,19 @@ impl<'tcx> ReverseMapper<'tcx> {
450
450
hidden_ty : Ty < ' tcx > ,
451
451
span : Span ,
452
452
) -> Self {
453
- Self {
454
- tcx,
455
- key,
456
- map,
457
- map_missing_regions_to_empty : false ,
458
- hidden_ty : Some ( hidden_ty) ,
459
- span,
460
- }
453
+ Self { tcx, key, map, do_not_error : false , hidden_ty : Some ( hidden_ty) , span }
461
454
}
462
455
463
- fn fold_kind_mapping_missing_regions_to_empty (
464
- & mut self ,
465
- kind : GenericArg < ' tcx > ,
466
- ) -> GenericArg < ' tcx > {
467
- assert ! ( !self . map_missing_regions_to_empty) ;
468
- self . map_missing_regions_to_empty = true ;
456
+ fn fold_kind_no_missing_regions_error ( & mut self , kind : GenericArg < ' tcx > ) -> GenericArg < ' tcx > {
457
+ assert ! ( !self . do_not_error) ;
458
+ self . do_not_error = true ;
469
459
let kind = kind. fold_with ( self ) ;
470
- self . map_missing_regions_to_empty = false ;
460
+ self . do_not_error = false ;
471
461
kind
472
462
}
473
463
474
464
fn fold_kind_normally ( & mut self , kind : GenericArg < ' tcx > ) -> GenericArg < ' tcx > {
475
- assert ! ( !self . map_missing_regions_to_empty ) ;
465
+ assert ! ( !self . do_not_error ) ;
476
466
kind. fold_with ( self )
477
467
}
478
468
}
@@ -510,7 +500,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
510
500
match self . map . get ( & r. into ( ) ) . map ( |k| k. unpack ( ) ) {
511
501
Some ( GenericArgKind :: Lifetime ( r1) ) => r1,
512
502
Some ( u) => panic ! ( "region mapped to unexpected kind: {:?}" , u) ,
513
- None if self . map_missing_regions_to_empty => self . tcx . lifetimes . re_root_empty ,
503
+ None if self . do_not_error => self . tcx . lifetimes . re_static ,
514
504
None if generics. parent . is_some ( ) => {
515
505
if let Some ( hidden_ty) = self . hidden_ty . take ( ) {
516
506
unexpected_hidden_region_diagnostic (
@@ -522,7 +512,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
522
512
)
523
513
. emit ( ) ;
524
514
}
525
- self . tcx . lifetimes . re_root_empty
515
+ self . tcx . lifetimes . re_static
526
516
}
527
517
None => {
528
518
self . tcx
@@ -574,7 +564,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
574
564
let substs = self . tcx . mk_substs ( substs. iter ( ) . enumerate ( ) . map ( |( index, kind) | {
575
565
if index < generics. parent_count {
576
566
// Accommodate missing regions in the parent kinds...
577
- self . fold_kind_mapping_missing_regions_to_empty ( kind)
567
+ self . fold_kind_no_missing_regions_error ( kind)
578
568
} else {
579
569
// ...but not elsewhere.
580
570
self . fold_kind_normally ( kind)
@@ -589,7 +579,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
589
579
let substs = self . tcx . mk_substs ( substs. iter ( ) . enumerate ( ) . map ( |( index, kind) | {
590
580
if index < generics. parent_count {
591
581
// Accommodate missing regions in the parent kinds...
592
- self . fold_kind_mapping_missing_regions_to_empty ( kind)
582
+ self . fold_kind_no_missing_regions_error ( kind)
593
583
} else {
594
584
// ...but not elsewhere.
595
585
self . fold_kind_normally ( kind)
0 commit comments