@@ -19,6 +19,7 @@ use self::EvaluationResult::*;
19
19
20
20
use super :: { DerivedObligationCause } ;
21
21
use super :: { project} ;
22
+ use super :: project:: Normalized ;
22
23
use super :: { PredicateObligation , Obligation , TraitObligation , ObligationCause } ;
23
24
use super :: { ObligationCauseCode , BuiltinDerivedObligation } ;
24
25
use super :: { SelectionError , Unimplemented , Overflow , OutputTypeParameterMismatch } ;
@@ -1160,7 +1161,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1160
1161
let impl_trait_ref =
1161
1162
ty:: impl_trait_ref ( self . tcx ( ) , impl_def_id) . unwrap ( ) ;
1162
1163
let impl_trait_ref =
1163
- impl_trait_ref. subst ( self . tcx ( ) , & impl_substs) ;
1164
+ impl_trait_ref. subst ( self . tcx ( ) , & impl_substs. value ) ;
1164
1165
let poly_impl_trait_ref =
1165
1166
ty:: Binder ( impl_trait_ref) ;
1166
1167
let origin =
@@ -1731,15 +1732,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1731
1732
let substs =
1732
1733
self . rematch_impl ( impl_def_id, obligation,
1733
1734
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 ( ) ) ) ;
1735
1736
Ok ( self . vtable_impl ( impl_def_id, substs, obligation. cause . clone ( ) ,
1736
1737
obligation. recursion_depth + 1 , skol_map, snapshot) )
1737
1738
} )
1738
1739
}
1739
1740
1740
1741
fn vtable_impl ( & mut self ,
1741
1742
impl_def_id : ast:: DefId ,
1742
- substs : Substs < ' tcx > ,
1743
+ substs : Normalized < ' tcx , Substs < ' tcx > > ,
1743
1744
cause : ObligationCause < ' tcx > ,
1744
1745
recursion_depth : uint ,
1745
1746
skol_map : infer:: SkolemizationMap ,
@@ -1752,21 +1753,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1752
1753
recursion_depth,
1753
1754
skol_map. repr( self . tcx( ) ) ) ;
1754
1755
1755
- let impl_predicates =
1756
- self . impl_predicates ( cause,
1756
+ let mut impl_obligations =
1757
+ self . impl_obligations ( cause,
1757
1758
recursion_depth,
1758
1759
impl_def_id,
1759
- & substs,
1760
+ & substs. value ,
1760
1761
skol_map,
1761
1762
snapshot) ;
1762
1763
1763
- debug ! ( "vtable_impl: impl_def_id={} impl_predicates ={}" ,
1764
+ debug ! ( "vtable_impl: impl_def_id={} impl_obligations ={}" ,
1764
1765
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 ( ) ) ;
1766
1769
1767
1770
VtableImplData { impl_def_id : impl_def_id,
1768
- substs : substs,
1769
- nested : impl_predicates }
1771
+ substs : substs. value ,
1772
+ nested : impl_obligations }
1770
1773
}
1771
1774
1772
1775
fn confirm_object_candidate ( & mut self ,
@@ -1950,7 +1953,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1950
1953
snapshot : & infer:: CombinedSnapshot ,
1951
1954
skol_map : & infer:: SkolemizationMap ,
1952
1955
skol_obligation_trait_ref : Rc < ty:: TraitRef < ' tcx > > )
1953
- -> Substs < ' tcx >
1956
+ -> Normalized < ' tcx , Substs < ' tcx > >
1954
1957
{
1955
1958
match self . match_impl ( impl_def_id, obligation, snapshot,
1956
1959
skol_map, skol_obligation_trait_ref) {
@@ -1972,7 +1975,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1972
1975
snapshot : & infer:: CombinedSnapshot ,
1973
1976
skol_map : & infer:: SkolemizationMap ,
1974
1977
skol_obligation_trait_ref : Rc < ty:: TraitRef < ' tcx > > )
1975
- -> Result < Substs < ' tcx > , ( ) >
1978
+ -> Result < Normalized < ' tcx , Substs < ' tcx > > , ( ) >
1976
1979
{
1977
1980
let impl_trait_ref = ty:: impl_trait_ref ( self . tcx ( ) , impl_def_id) . unwrap ( ) ;
1978
1981
@@ -1990,6 +1993,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1990
1993
let impl_trait_ref = impl_trait_ref. subst ( self . tcx ( ) ,
1991
1994
& impl_substs) ;
1992
1995
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
+
1993
2002
debug ! ( "match_impl(impl_def_id={}, obligation={}, \
1994
2003
impl_trait_ref={}, skol_obligation_trait_ref={})",
1995
2004
impl_def_id. repr( self . tcx( ) ) ,
@@ -2000,7 +2009,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2000
2009
let origin = infer:: RelateOutputImplTypes ( obligation. cause . span ) ;
2001
2010
match self . infcx . sub_trait_refs ( false ,
2002
2011
origin,
2003
- impl_trait_ref,
2012
+ impl_trait_ref. value . clone ( ) ,
2004
2013
skol_obligation_trait_ref) {
2005
2014
Ok ( ( ) ) => { }
2006
2015
Err ( e) => {
@@ -2020,7 +2029,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2020
2029
}
2021
2030
2022
2031
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 } )
2024
2034
}
2025
2035
2026
2036
fn fast_reject_trait_refs ( & mut self ,
@@ -2161,14 +2171,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2161
2171
}
2162
2172
}
2163
2173
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 > >
2172
2182
{
2173
2183
let impl_generics = ty:: lookup_item_type ( self . tcx ( ) , impl_def_id) . generics ;
2174
2184
let bounds = impl_generics. to_bounds ( self . tcx ( ) , impl_substs) ;
@@ -2181,9 +2191,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2181
2191
cause,
2182
2192
recursion_depth,
2183
2193
& 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 ( ) ) ;
2187
2195
impl_obligations
2188
2196
}
2189
2197
0 commit comments