@@ -19,6 +19,7 @@ use self::EvaluationResult::*;
1919
2020use super :: { DerivedObligationCause } ;
2121use super :: { project} ;
22+ use super :: project:: Normalized ;
2223use super :: { PredicateObligation , Obligation , TraitObligation , ObligationCause } ;
2324use super :: { ObligationCauseCode , BuiltinDerivedObligation } ;
2425use super :: { SelectionError , Unimplemented , Overflow , OutputTypeParameterMismatch } ;
@@ -1155,7 +1156,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11551156 let impl_trait_ref =
11561157 ty:: impl_trait_ref ( self . tcx ( ) , impl_def_id) . unwrap ( ) ;
11571158 let impl_trait_ref =
1158- impl_trait_ref. subst ( self . tcx ( ) , & impl_substs) ;
1159+ impl_trait_ref. subst ( self . tcx ( ) , & impl_substs. value ) ;
11591160 let poly_impl_trait_ref =
11601161 ty:: Binder ( impl_trait_ref) ;
11611162 let origin =
@@ -1712,15 +1713,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17121713 let substs =
17131714 self . rematch_impl ( impl_def_id, obligation,
17141715 snapshot, & skol_map, skol_obligation_trait_ref. trait_ref ) ;
1715- debug ! ( "confirm_impl_candidate substs={:? }" , substs) ;
1716+ debug ! ( "confirm_impl_candidate substs={}" , substs. repr ( self . tcx ( ) ) ) ;
17161717 Ok ( self . vtable_impl ( impl_def_id, substs, obligation. cause . clone ( ) ,
17171718 obligation. recursion_depth + 1 , skol_map, snapshot) )
17181719 } )
17191720 }
17201721
17211722 fn vtable_impl ( & mut self ,
17221723 impl_def_id : ast:: DefId ,
1723- substs : Substs < ' tcx > ,
1724+ substs : Normalized < ' tcx , Substs < ' tcx > > ,
17241725 cause : ObligationCause < ' tcx > ,
17251726 recursion_depth : uint ,
17261727 skol_map : infer:: SkolemizationMap ,
@@ -1733,21 +1734,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17331734 recursion_depth,
17341735 skol_map. repr( self . tcx( ) ) ) ;
17351736
1736- let impl_predicates =
1737- self . impl_predicates ( cause,
1737+ let mut impl_obligations =
1738+ self . impl_obligations ( cause,
17381739 recursion_depth,
17391740 impl_def_id,
1740- & substs,
1741+ & substs. value ,
17411742 skol_map,
17421743 snapshot) ;
17431744
1744- debug ! ( "vtable_impl: impl_def_id={} impl_predicates ={}" ,
1745+ debug ! ( "vtable_impl: impl_def_id={} impl_obligations ={}" ,
17451746 impl_def_id. repr( self . tcx( ) ) ,
1746- impl_predicates. repr( self . tcx( ) ) ) ;
1747+ impl_obligations. repr( self . tcx( ) ) ) ;
1748+
1749+ impl_obligations. extend ( TypeSpace , substs. obligations . into_iter ( ) ) ;
17471750
17481751 VtableImplData { impl_def_id : impl_def_id,
1749- substs : substs,
1750- nested : impl_predicates }
1752+ substs : substs. value ,
1753+ nested : impl_obligations }
17511754 }
17521755
17531756 fn confirm_object_candidate ( & mut self ,
@@ -1931,7 +1934,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19311934 snapshot : & infer:: CombinedSnapshot ,
19321935 skol_map : & infer:: SkolemizationMap ,
19331936 skol_obligation_trait_ref : Rc < ty:: TraitRef < ' tcx > > )
1934- -> Substs < ' tcx >
1937+ -> Normalized < ' tcx , Substs < ' tcx > >
19351938 {
19361939 match self . match_impl ( impl_def_id, obligation, snapshot,
19371940 skol_map, skol_obligation_trait_ref) {
@@ -1953,7 +1956,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19531956 snapshot : & infer:: CombinedSnapshot ,
19541957 skol_map : & infer:: SkolemizationMap ,
19551958 skol_obligation_trait_ref : Rc < ty:: TraitRef < ' tcx > > )
1956- -> Result < Substs < ' tcx > , ( ) >
1959+ -> Result < Normalized < ' tcx , Substs < ' tcx > > , ( ) >
19571960 {
19581961 let impl_trait_ref = ty:: impl_trait_ref ( self . tcx ( ) , impl_def_id) . unwrap ( ) ;
19591962
@@ -1971,6 +1974,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19711974 let impl_trait_ref = impl_trait_ref. subst ( self . tcx ( ) ,
19721975 & impl_substs) ;
19731976
1977+ let impl_trait_ref =
1978+ project:: normalize_with_depth ( self ,
1979+ obligation. cause . clone ( ) ,
1980+ obligation. recursion_depth + 1 ,
1981+ & impl_trait_ref) ;
1982+
19741983 debug ! ( "match_impl(impl_def_id={}, obligation={}, \
19751984 impl_trait_ref={}, skol_obligation_trait_ref={})",
19761985 impl_def_id. repr( self . tcx( ) ) ,
@@ -1981,7 +1990,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19811990 let origin = infer:: RelateOutputImplTypes ( obligation. cause . span ) ;
19821991 match self . infcx . sub_trait_refs ( false ,
19831992 origin,
1984- impl_trait_ref,
1993+ impl_trait_ref. value . clone ( ) ,
19851994 skol_obligation_trait_ref) {
19861995 Ok ( ( ) ) => { }
19871996 Err ( e) => {
@@ -2001,7 +2010,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
20012010 }
20022011
20032012 debug ! ( "match_impl: success impl_substs={}" , impl_substs. repr( self . tcx( ) ) ) ;
2004- Ok ( impl_substs)
2013+ Ok ( Normalized { value : impl_substs,
2014+ obligations : impl_trait_ref. obligations } )
20052015 }
20062016
20072017 fn fast_reject_trait_refs ( & mut self ,
@@ -2142,14 +2152,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
21422152 }
21432153 }
21442154
2145- fn impl_predicates ( & mut self ,
2146- cause : ObligationCause < ' tcx > ,
2147- recursion_depth : uint ,
2148- impl_def_id : ast:: DefId ,
2149- impl_substs : & Substs < ' tcx > ,
2150- skol_map : infer:: SkolemizationMap ,
2151- snapshot : & infer:: CombinedSnapshot )
2152- -> VecPerParamSpace < PredicateObligation < ' tcx > >
2155+ fn impl_obligations ( & mut self ,
2156+ cause : ObligationCause < ' tcx > ,
2157+ recursion_depth : uint ,
2158+ impl_def_id : ast:: DefId ,
2159+ impl_substs : & Substs < ' tcx > ,
2160+ skol_map : infer:: SkolemizationMap ,
2161+ snapshot : & infer:: CombinedSnapshot )
2162+ -> VecPerParamSpace < PredicateObligation < ' tcx > >
21532163 {
21542164 let impl_generics = ty:: lookup_item_type ( self . tcx ( ) , impl_def_id) . generics ;
21552165 let bounds = impl_generics. to_bounds ( self . tcx ( ) , impl_substs) ;
@@ -2162,9 +2172,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
21622172 cause,
21632173 recursion_depth,
21642174 & normalized_bounds. value ) ;
2165- for obligation in normalized_bounds. obligations . into_iter ( ) {
2166- impl_obligations. push ( TypeSpace , obligation) ;
2167- }
2175+ impl_obligations. extend ( TypeSpace , normalized_bounds. obligations . into_iter ( ) ) ;
21682176 impl_obligations
21692177 }
21702178
0 commit comments