@@ -425,8 +425,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T {
425
425
substs : & [ GenericArg < ' tcx > ] ,
426
426
span : Option < Span > ,
427
427
) -> T {
428
- let mut folder =
429
- SubstFolder { tcx, substs, span, root_ty : None , ty_stack_depth : 0 , binders_passed : 0 } ;
428
+ let mut folder = SubstFolder { tcx, substs, span, binders_passed : 0 } ;
430
429
( * self ) . fold_with ( & mut folder)
431
430
}
432
431
}
@@ -441,12 +440,6 @@ struct SubstFolder<'a, 'tcx> {
441
440
/// The location for which the substitution is performed, if available.
442
441
span : Option < Span > ,
443
442
444
- /// The root type that is being substituted, if available.
445
- root_ty : Option < Ty < ' tcx > > ,
446
-
447
- /// Depth of type stack
448
- ty_stack_depth : usize ,
449
-
450
443
/// Number of region binders we have passed through while doing the substitution
451
444
binders_passed : u32 ,
452
445
}
@@ -478,9 +471,8 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
478
471
let span = self . span . unwrap_or ( DUMMY_SP ) ;
479
472
let msg = format ! (
480
473
"Region parameter out of range \
481
- when substituting in region {} (root type={:?}) \
482
- (index={})",
483
- data. name, self . root_ty, data. index
474
+ when substituting in region {} (index={})",
475
+ data. name, data. index
484
476
) ;
485
477
span_bug ! ( span, "{}" , msg) ;
486
478
}
@@ -495,25 +487,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
495
487
return t;
496
488
}
497
489
498
- // track the root type we were asked to substitute
499
- let depth = self . ty_stack_depth ;
500
- if depth == 0 {
501
- self . root_ty = Some ( t) ;
502
- }
503
- self . ty_stack_depth += 1 ;
504
-
505
- let t1 = match t. kind {
490
+ match t. kind {
506
491
ty:: Param ( p) => self . ty_for_param ( p, t) ,
507
492
_ => t. super_fold_with ( self ) ,
508
- } ;
509
-
510
- assert_eq ! ( depth + 1 , self . ty_stack_depth) ;
511
- self . ty_stack_depth -= 1 ;
512
- if depth == 0 {
513
- self . root_ty = None ;
514
493
}
515
-
516
- t1
517
494
}
518
495
519
496
fn fold_const ( & mut self , c : & ' tcx ty:: Const < ' tcx > ) -> & ' tcx ty:: Const < ' tcx > {
@@ -540,12 +517,11 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
540
517
span_bug ! (
541
518
span,
542
519
"expected type for `{:?}` ({:?}/{}) but found {:?} \
543
- when substituting (root type={:?}) substs={:?}",
520
+ when substituting, substs={:?}",
544
521
p,
545
522
source_ty,
546
523
p. index,
547
524
kind,
548
- self . root_ty,
549
525
self . substs,
550
526
) ;
551
527
}
@@ -554,11 +530,10 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
554
530
span_bug ! (
555
531
span,
556
532
"type parameter `{:?}` ({:?}/{}) out of range \
557
- when substituting (root type={:?}) substs={:?}",
533
+ when substituting, substs={:?}",
558
534
p,
559
535
source_ty,
560
536
p. index,
561
- self . root_ty,
562
537
self . substs,
563
538
) ;
564
539
}
0 commit comments