@@ -10,7 +10,7 @@ use rustc_data_structures::intern::{Interned, WithStableHash};
1010use rustc_hir:: def_id:: DefId ;
1111use rustc_macros:: HashStable ;
1212use rustc_serialize:: { self , Decodable , Encodable } ;
13- use rustc_span:: { Span , DUMMY_SP } ;
13+ use rustc_span:: DUMMY_SP ;
1414use smallvec:: SmallVec ;
1515
1616use core:: intrinsics;
@@ -498,34 +498,14 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<Ty<'tcx>> {
498498 }
499499}
500500
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`.
508502pub 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 ;
519504}
520505
521506impl < ' 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 } ;
529509 self . fold_with ( & mut folder)
530510 }
531511}
@@ -537,9 +517,6 @@ struct SubstFolder<'a, 'tcx> {
537517 tcx : TyCtxt < ' tcx > ,
538518 substs : & ' a [ GenericArg < ' tcx > ] ,
539519
540- /// The location for which the substitution is performed, if available.
541- span : Option < Span > ,
542-
543520 /// Number of region binders we have passed through while doing the substitution
544521 binders_passed : u32 ,
545522}
@@ -571,13 +548,12 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
571548 match rk {
572549 Some ( GenericArgKind :: Lifetime ( lt) ) => self . shift_region_through_binders ( lt) ,
573550 _ => {
574- let span = self . span . unwrap_or ( DUMMY_SP ) ;
575551 let msg = format ! (
576552 "Region parameter out of range \
577553 when substituting in region {} (index={})",
578554 data. name, data. index
579555 ) ;
580- span_bug ! ( span , "{}" , msg) ;
556+ span_bug ! ( DUMMY_SP , "{}" , msg) ;
581557 }
582558 }
583559 }
@@ -617,9 +593,8 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
617593 let ty = match opt_ty {
618594 Some ( GenericArgKind :: Type ( ty) ) => ty,
619595 Some ( kind) => {
620- let span = self . span . unwrap_or ( DUMMY_SP ) ;
621596 span_bug ! (
622- span ,
597+ DUMMY_SP ,
623598 "expected type for `{:?}` ({:?}/{}) but found {:?} \
624599 when substituting, substs={:?}",
625600 p,
@@ -630,9 +605,8 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
630605 ) ;
631606 }
632607 None => {
633- let span = self . span . unwrap_or ( DUMMY_SP ) ;
634608 span_bug ! (
635- span ,
609+ DUMMY_SP ,
636610 "type parameter `{:?}` ({:?}/{}) out of range \
637611 when substituting, substs={:?}",
638612 p,
@@ -652,9 +626,8 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
652626 let ct = match opt_ct {
653627 Some ( GenericArgKind :: Const ( ct) ) => ct,
654628 Some ( kind) => {
655- let span = self . span . unwrap_or ( DUMMY_SP ) ;
656629 span_bug ! (
657- span ,
630+ DUMMY_SP ,
658631 "expected const for `{:?}` ({:?}/{}) but found {:?} \
659632 when substituting substs={:?}",
660633 p,
@@ -665,9 +638,8 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
665638 ) ;
666639 }
667640 None => {
668- let span = self . span . unwrap_or ( DUMMY_SP ) ;
669641 span_bug ! (
670- span ,
642+ DUMMY_SP ,
671643 "const parameter `{:?}` ({:?}/{}) out of range \
672644 when substituting substs={:?}",
673645 p,
0 commit comments