@@ -20,7 +20,6 @@ use middle::subst;
2020use middle:: ty:: { self , HasProjectionTypes , Ty } ;
2121use middle:: ty_fold:: TypeFoldable ;
2222use middle:: infer:: { self , fixup_err_to_string, InferCtxt } ;
23- use std:: slice:: Iter ;
2423use std:: rc:: Rc ;
2524use syntax:: ast;
2625use syntax:: codemap:: { Span , DUMMY_SP } ;
@@ -146,9 +145,9 @@ pub struct DerivedObligationCause<'tcx> {
146145 parent_code : Rc < ObligationCauseCode < ' tcx > >
147146}
148147
149- pub type Obligations < ' tcx , O > = subst :: VecPerParamSpace < Obligation < ' tcx , O > > ;
150- pub type PredicateObligations < ' tcx > = subst :: VecPerParamSpace < PredicateObligation < ' tcx > > ;
151- pub type TraitObligations < ' tcx > = subst :: VecPerParamSpace < TraitObligation < ' tcx > > ;
148+ pub type Obligations < ' tcx , O > = Vec < Obligation < ' tcx , O > > ;
149+ pub type PredicateObligations < ' tcx > = Vec < PredicateObligation < ' tcx > > ;
150+ pub type TraitObligations < ' tcx > = Vec < TraitObligation < ' tcx > > ;
152151
153152pub type Selection < ' tcx > = Vtable < ' tcx , PredicateObligation < ' tcx > > ;
154153
@@ -266,7 +265,7 @@ pub enum Vtable<'tcx, N> {
266265pub struct VtableImplData < ' tcx , N > {
267266 pub impl_def_id : ast:: DefId ,
268267 pub substs : subst:: Substs < ' tcx > ,
269- pub nested : subst :: VecPerParamSpace < N >
268+ pub nested : Vec < N >
270269}
271270
272271#[ derive( Debug , Clone ) ]
@@ -277,7 +276,7 @@ pub struct VtableDefaultImplData<N> {
277276
278277#[ derive( Debug , Clone ) ]
279278pub struct VtableBuiltinData < N > {
280- pub nested : subst :: VecPerParamSpace < N >
279+ pub nested : Vec < N >
281280}
282281
283282/// A vtable for some object-safe trait `Foo` automatically derived
@@ -525,114 +524,35 @@ impl<'tcx> ObligationCause<'tcx> {
525524}
526525
527526impl < ' tcx , N > Vtable < ' tcx , N > {
528- pub fn iter_nested ( & self ) -> Iter < N > {
529- match * self {
530- VtableImpl ( ref i) => i. iter_nested ( ) ,
531- VtableParam ( ref n) => n. iter ( ) ,
532- VtableBuiltin ( ref i) => i. iter_nested ( ) ,
533- VtableObject ( _) |
534- VtableDefaultImpl ( ..) | VtableFnPointer ( ..) |
535- VtableClosure ( ..) => ( & [ ] ) . iter ( ) ,
536- }
537- }
538-
539- pub fn map_nested < M , F > ( & self , op : F ) -> Vtable < ' tcx , M > where
540- F : FnMut ( & N ) -> M ,
541- {
542- match * self {
543- VtableImpl ( ref i) => VtableImpl ( i. map_nested ( op) ) ,
544- VtableDefaultImpl ( ref t) => VtableDefaultImpl ( t. map_nested ( op) ) ,
545- VtableFnPointer ( ref sig) => VtableFnPointer ( ( * sig) . clone ( ) ) ,
546- VtableClosure ( d, ref s) => VtableClosure ( d, s. clone ( ) ) ,
547- VtableParam ( ref n) => VtableParam ( n. iter ( ) . map ( op) . collect ( ) ) ,
548- VtableObject ( ref p) => VtableObject ( p. clone ( ) ) ,
549- VtableBuiltin ( ref b) => VtableBuiltin ( b. map_nested ( op) ) ,
527+ pub fn nested_obligations ( self ) -> Vec < N > {
528+ match self {
529+ VtableImpl ( i) => i. nested ,
530+ VtableParam ( n) => n,
531+ VtableBuiltin ( i) => i. nested ,
532+ VtableDefaultImpl ( d) => d. nested ,
533+ VtableObject ( _) | VtableFnPointer ( ..) |
534+ VtableClosure ( ..) => vec ! [ ]
550535 }
551536 }
552537
553- pub fn map_move_nested < M , F > ( self , op : F ) -> Vtable < ' tcx , M > where
554- F : FnMut ( N ) -> M ,
555- {
538+ pub fn map < M , F > ( self , f : F ) -> Vtable < ' tcx , M > where F : FnMut ( N ) -> M {
556539 match self {
557- VtableImpl ( i) => VtableImpl ( i. map_move_nested ( op) ) ,
558- VtableFnPointer ( sig) => VtableFnPointer ( sig) ,
540+ VtableImpl ( i) => VtableImpl ( VtableImplData {
541+ impl_def_id : i. impl_def_id ,
542+ substs : i. substs ,
543+ nested : i. nested . into_iter ( ) . map ( f) . collect ( )
544+ } ) ,
545+ VtableParam ( n) => VtableParam ( n. into_iter ( ) . map ( f) . collect ( ) ) ,
546+ VtableBuiltin ( i) => VtableBuiltin ( VtableBuiltinData {
547+ nested : i. nested . into_iter ( ) . map ( f) . collect ( )
548+ } ) ,
549+ VtableObject ( o) => VtableObject ( o) ,
550+ VtableDefaultImpl ( d) => VtableDefaultImpl ( VtableDefaultImplData {
551+ trait_def_id : d. trait_def_id ,
552+ nested : d. nested . into_iter ( ) . map ( f) . collect ( )
553+ } ) ,
554+ VtableFnPointer ( f) => VtableFnPointer ( f) ,
559555 VtableClosure ( d, s) => VtableClosure ( d, s) ,
560- VtableDefaultImpl ( t) => VtableDefaultImpl ( t. map_move_nested ( op) ) ,
561- VtableParam ( n) => VtableParam ( n. into_iter ( ) . map ( op) . collect ( ) ) ,
562- VtableObject ( p) => VtableObject ( p) ,
563- VtableBuiltin ( no) => VtableBuiltin ( no. map_move_nested ( op) ) ,
564- }
565- }
566- }
567-
568- impl < ' tcx , N > VtableImplData < ' tcx , N > {
569- pub fn iter_nested ( & self ) -> Iter < N > {
570- self . nested . iter ( )
571- }
572-
573- pub fn map_nested < M , F > ( & self , op : F ) -> VtableImplData < ' tcx , M > where
574- F : FnMut ( & N ) -> M ,
575- {
576- VtableImplData {
577- impl_def_id : self . impl_def_id ,
578- substs : self . substs . clone ( ) ,
579- nested : self . nested . map ( op)
580- }
581- }
582-
583- pub fn map_move_nested < M , F > ( self , op : F ) -> VtableImplData < ' tcx , M > where
584- F : FnMut ( N ) -> M ,
585- {
586- let VtableImplData { impl_def_id, substs, nested } = self ;
587- VtableImplData {
588- impl_def_id : impl_def_id,
589- substs : substs,
590- nested : nested. map_move ( op)
591- }
592- }
593- }
594-
595- impl < N > VtableDefaultImplData < N > {
596- pub fn iter_nested ( & self ) -> Iter < N > {
597- self . nested . iter ( )
598- }
599-
600- pub fn map_nested < M , F > ( & self , op : F ) -> VtableDefaultImplData < M > where
601- F : FnMut ( & N ) -> M ,
602- {
603- VtableDefaultImplData {
604- trait_def_id : self . trait_def_id ,
605- nested : self . nested . iter ( ) . map ( op) . collect ( )
606- }
607- }
608-
609- pub fn map_move_nested < M , F > ( self , op : F ) -> VtableDefaultImplData < M > where
610- F : FnMut ( N ) -> M ,
611- {
612- let VtableDefaultImplData { trait_def_id, nested } = self ;
613- VtableDefaultImplData {
614- trait_def_id : trait_def_id,
615- nested : nested. into_iter ( ) . map ( op) . collect ( )
616- }
617- }
618- }
619-
620- impl < N > VtableBuiltinData < N > {
621- pub fn iter_nested ( & self ) -> Iter < N > {
622- self . nested . iter ( )
623- }
624-
625- pub fn map_nested < M , F > ( & self , op : F ) -> VtableBuiltinData < M > where F : FnMut ( & N ) -> M {
626- VtableBuiltinData {
627- nested : self . nested . map ( op)
628- }
629- }
630-
631- pub fn map_move_nested < M , F > ( self , op : F ) -> VtableBuiltinData < M > where
632- F : FnMut ( N ) -> M ,
633- {
634- VtableBuiltinData {
635- nested : self . nested . map_move ( op)
636556 }
637557 }
638558}
0 commit comments