@@ -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 } ;
@@ -1160,7 +1161,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11601161 let impl_trait_ref =
11611162 ty:: impl_trait_ref ( self . tcx ( ) , impl_def_id) . unwrap ( ) ;
11621163 let impl_trait_ref =
1163- impl_trait_ref. subst ( self . tcx ( ) , & impl_substs) ;
1164+ impl_trait_ref. subst ( self . tcx ( ) , & impl_substs. value ) ;
11641165 let poly_impl_trait_ref =
11651166 ty:: Binder ( impl_trait_ref) ;
11661167 let origin =
@@ -1731,15 +1732,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17311732 let substs =
17321733 self . rematch_impl ( impl_def_id, obligation,
17331734 snapshot, & skol_map, skol_obligation_trait_ref. trait_ref ) ;
1734- debug ! ( "confirm_impl_candidate substs={:? }" , substs) ;
1735+ debug ! ( "confirm_impl_candidate substs={}" , substs. repr ( self . tcx ( ) ) ) ;
17351736 Ok ( self . vtable_impl ( impl_def_id, substs, obligation. cause . clone ( ) ,
17361737 obligation. recursion_depth + 1 , skol_map, snapshot) )
17371738 } )
17381739 }
17391740
17401741 fn vtable_impl ( & mut self ,
17411742 impl_def_id : ast:: DefId ,
1742- substs : Substs < ' tcx > ,
1743+ substs : Normalized < ' tcx , Substs < ' tcx > > ,
17431744 cause : ObligationCause < ' tcx > ,
17441745 recursion_depth : uint ,
17451746 skol_map : infer:: SkolemizationMap ,
@@ -1752,21 +1753,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17521753 recursion_depth,
17531754 skol_map. repr( self . tcx( ) ) ) ;
17541755
1755- let impl_predicates =
1756- self . impl_predicates ( cause,
1756+ let mut impl_obligations =
1757+ self . impl_obligations ( cause,
17571758 recursion_depth,
17581759 impl_def_id,
1759- & substs,
1760+ & substs. value ,
17601761 skol_map,
17611762 snapshot) ;
17621763
1763- debug ! ( "vtable_impl: impl_def_id={} impl_predicates ={}" ,
1764+ debug ! ( "vtable_impl: impl_def_id={} impl_obligations ={}" ,
17641765 impl_def_id. repr( self . tcx( ) ) ,
1765- impl_predicates. repr( self . tcx( ) ) ) ;
1766+ impl_obligations. repr( self . tcx( ) ) ) ;
1767+
1768+ impl_obligations. extend ( TypeSpace , substs. obligations . into_iter ( ) ) ;
17661769
17671770 VtableImplData { impl_def_id : impl_def_id,
1768- substs : substs,
1769- nested : impl_predicates }
1771+ substs : substs. value ,
1772+ nested : impl_obligations }
17701773 }
17711774
17721775 fn confirm_object_candidate ( & mut self ,
@@ -1950,7 +1953,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19501953 snapshot : & infer:: CombinedSnapshot ,
19511954 skol_map : & infer:: SkolemizationMap ,
19521955 skol_obligation_trait_ref : Rc < ty:: TraitRef < ' tcx > > )
1953- -> Substs < ' tcx >
1956+ -> Normalized < ' tcx , Substs < ' tcx > >
19541957 {
19551958 match self . match_impl ( impl_def_id, obligation, snapshot,
19561959 skol_map, skol_obligation_trait_ref) {
@@ -1972,7 +1975,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19721975 snapshot : & infer:: CombinedSnapshot ,
19731976 skol_map : & infer:: SkolemizationMap ,
19741977 skol_obligation_trait_ref : Rc < ty:: TraitRef < ' tcx > > )
1975- -> Result < Substs < ' tcx > , ( ) >
1978+ -> Result < Normalized < ' tcx , Substs < ' tcx > > , ( ) >
19761979 {
19771980 let impl_trait_ref = ty:: impl_trait_ref ( self . tcx ( ) , impl_def_id) . unwrap ( ) ;
19781981
@@ -1990,6 +1993,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19901993 let impl_trait_ref = impl_trait_ref. subst ( self . tcx ( ) ,
19911994 & impl_substs) ;
19921995
1996+ let impl_trait_ref =
1997+ project:: normalize_with_depth ( self ,
1998+ obligation. cause . clone ( ) ,
1999+ obligation. recursion_depth + 1 ,
2000+ & impl_trait_ref) ;
2001+
19932002 debug ! ( "match_impl(impl_def_id={}, obligation={}, \
19942003 impl_trait_ref={}, skol_obligation_trait_ref={})",
19952004 impl_def_id. repr( self . tcx( ) ) ,
@@ -2000,7 +2009,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
20002009 let origin = infer:: RelateOutputImplTypes ( obligation. cause . span ) ;
20012010 match self . infcx . sub_trait_refs ( false ,
20022011 origin,
2003- impl_trait_ref,
2012+ impl_trait_ref. value . clone ( ) ,
20042013 skol_obligation_trait_ref) {
20052014 Ok ( ( ) ) => { }
20062015 Err ( e) => {
@@ -2020,7 +2029,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
20202029 }
20212030
20222031 debug ! ( "match_impl: success impl_substs={}" , impl_substs. repr( self . tcx( ) ) ) ;
2023- Ok ( impl_substs)
2032+ Ok ( Normalized { value : impl_substs,
2033+ obligations : impl_trait_ref. obligations } )
20242034 }
20252035
20262036 fn fast_reject_trait_refs ( & mut self ,
@@ -2161,14 +2171,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
21612171 }
21622172 }
21632173
2164- fn impl_predicates ( & mut self ,
2165- cause : ObligationCause < ' tcx > ,
2166- recursion_depth : uint ,
2167- impl_def_id : ast:: DefId ,
2168- impl_substs : & Substs < ' tcx > ,
2169- skol_map : infer:: SkolemizationMap ,
2170- snapshot : & infer:: CombinedSnapshot )
2171- -> VecPerParamSpace < PredicateObligation < ' tcx > >
2174+ fn impl_obligations ( & mut self ,
2175+ cause : ObligationCause < ' tcx > ,
2176+ recursion_depth : uint ,
2177+ impl_def_id : ast:: DefId ,
2178+ impl_substs : & Substs < ' tcx > ,
2179+ skol_map : infer:: SkolemizationMap ,
2180+ snapshot : & infer:: CombinedSnapshot )
2181+ -> VecPerParamSpace < PredicateObligation < ' tcx > >
21722182 {
21732183 let impl_generics = ty:: lookup_item_type ( self . tcx ( ) , impl_def_id) . generics ;
21742184 let bounds = impl_generics. to_bounds ( self . tcx ( ) , impl_substs) ;
@@ -2181,9 +2191,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
21812191 cause,
21822192 recursion_depth,
21832193 & normalized_bounds. value ) ;
2184- for obligation in normalized_bounds. obligations . into_iter ( ) {
2185- impl_obligations. push ( TypeSpace , obligation) ;
2186- }
2194+ impl_obligations. extend ( TypeSpace , normalized_bounds. obligations . into_iter ( ) ) ;
21872195 impl_obligations
21882196 }
21892197
0 commit comments