@@ -10,7 +10,7 @@ use rustc_data_structures::intern::{Interned, WithStableHash};
10
10
use rustc_hir:: def_id:: DefId ;
11
11
use rustc_macros:: HashStable ;
12
12
use rustc_serialize:: { self , Decodable , Encodable } ;
13
- use rustc_span:: { Span , DUMMY_SP } ;
13
+ use rustc_span:: DUMMY_SP ;
14
14
use smallvec:: SmallVec ;
15
15
16
16
use core:: intrinsics;
@@ -498,34 +498,14 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<Ty<'tcx>> {
498
498
}
499
499
}
500
500
501
- ///////////////////////////////////////////////////////////////////////////
502
- // Public trait `Subst`
503
- //
504
- // Just call `foo.subst(tcx, substs)` to perform a substitution across
505
- // `foo`. Or use `foo.subst_spanned(tcx, substs, Some(span))` when
506
- // there is more information available (for better errors).
507
-
501
+ // Just call `foo.subst(tcx, substs)` to perform a substitution across `foo`.
508
502
pub trait Subst < ' tcx > : Sized {
509
- fn subst ( self , tcx : TyCtxt < ' tcx > , substs : & [ GenericArg < ' tcx > ] ) -> Self {
510
- self . subst_spanned ( tcx, substs, None )
511
- }
512
-
513
- fn subst_spanned (
514
- self ,
515
- tcx : TyCtxt < ' tcx > ,
516
- substs : & [ GenericArg < ' tcx > ] ,
517
- span : Option < Span > ,
518
- ) -> Self ;
503
+ fn subst ( self , tcx : TyCtxt < ' tcx > , substs : & [ GenericArg < ' tcx > ] ) -> Self ;
519
504
}
520
505
521
506
impl < ' tcx , T : TypeFoldable < ' tcx > > Subst < ' tcx > for T {
522
- fn subst_spanned (
523
- self ,
524
- tcx : TyCtxt < ' tcx > ,
525
- substs : & [ GenericArg < ' tcx > ] ,
526
- span : Option < Span > ,
527
- ) -> T {
528
- let mut folder = SubstFolder { tcx, substs, span, binders_passed : 0 } ;
507
+ fn subst ( self , tcx : TyCtxt < ' tcx > , substs : & [ GenericArg < ' tcx > ] ) -> T {
508
+ let mut folder = SubstFolder { tcx, substs, binders_passed : 0 } ;
529
509
self . fold_with ( & mut folder)
530
510
}
531
511
}
@@ -537,9 +517,6 @@ struct SubstFolder<'a, 'tcx> {
537
517
tcx : TyCtxt < ' tcx > ,
538
518
substs : & ' a [ GenericArg < ' tcx > ] ,
539
519
540
- /// The location for which the substitution is performed, if available.
541
- span : Option < Span > ,
542
-
543
520
/// Number of region binders we have passed through while doing the substitution
544
521
binders_passed : u32 ,
545
522
}
@@ -571,13 +548,12 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
571
548
match rk {
572
549
Some ( GenericArgKind :: Lifetime ( lt) ) => self . shift_region_through_binders ( lt) ,
573
550
_ => {
574
- let span = self . span . unwrap_or ( DUMMY_SP ) ;
575
551
let msg = format ! (
576
552
"Region parameter out of range \
577
553
when substituting in region {} (index={})",
578
554
data. name, data. index
579
555
) ;
580
- span_bug ! ( span , "{}" , msg) ;
556
+ span_bug ! ( DUMMY_SP , "{}" , msg) ;
581
557
}
582
558
}
583
559
}
@@ -617,9 +593,8 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
617
593
let ty = match opt_ty {
618
594
Some ( GenericArgKind :: Type ( ty) ) => ty,
619
595
Some ( kind) => {
620
- let span = self . span . unwrap_or ( DUMMY_SP ) ;
621
596
span_bug ! (
622
- span ,
597
+ DUMMY_SP ,
623
598
"expected type for `{:?}` ({:?}/{}) but found {:?} \
624
599
when substituting, substs={:?}",
625
600
p,
@@ -630,9 +605,8 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
630
605
) ;
631
606
}
632
607
None => {
633
- let span = self . span . unwrap_or ( DUMMY_SP ) ;
634
608
span_bug ! (
635
- span ,
609
+ DUMMY_SP ,
636
610
"type parameter `{:?}` ({:?}/{}) out of range \
637
611
when substituting, substs={:?}",
638
612
p,
@@ -652,9 +626,8 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
652
626
let ct = match opt_ct {
653
627
Some ( GenericArgKind :: Const ( ct) ) => ct,
654
628
Some ( kind) => {
655
- let span = self . span . unwrap_or ( DUMMY_SP ) ;
656
629
span_bug ! (
657
- span ,
630
+ DUMMY_SP ,
658
631
"expected const for `{:?}` ({:?}/{}) but found {:?} \
659
632
when substituting substs={:?}",
660
633
p,
@@ -665,9 +638,8 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
665
638
) ;
666
639
}
667
640
None => {
668
- let span = self . span . unwrap_or ( DUMMY_SP ) ;
669
641
span_bug ! (
670
- span ,
642
+ DUMMY_SP ,
671
643
"const parameter `{:?}` ({:?}/{}) out of range \
672
644
when substituting substs={:?}",
673
645
p,
0 commit comments