@@ -19,7 +19,7 @@ use std::cell::RefCell;
1919use std:: marker:: PhantomData ;
2020use syntax:: ast;
2121use syntax_pos:: Span ;
22- use traits:: { FulfillmentContext , Obligation , ObligationCause , Reveal , SelectionContext , Vtable } ;
22+ use traits:: { FulfillmentContext , Obligation , ObligationCause , SelectionContext , Vtable } ;
2323use ty:: { self , Ty , TyCtxt } ;
2424use ty:: subst:: { Subst , Substs } ;
2525use ty:: fold:: { TypeFoldable , TypeFolder } ;
@@ -31,24 +31,25 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
3131 /// (necessarily) resolve all nested obligations on the impl. Note
3232 /// that type check should guarantee to us that all nested
3333 /// obligations *could be* resolved if we wanted to.
34+ /// Assumes that this is run after the entire crate has been successfully type-checked.
3435 pub fn trans_fulfill_obligation ( self ,
3536 span : Span ,
37+ param_env : ty:: ParamEnv < ' tcx > ,
3638 trait_ref : ty:: PolyTraitRef < ' tcx > )
3739 -> Vtable < ' tcx , ( ) >
3840 {
3941 // Remove any references to regions; this helps improve caching.
4042 let trait_ref = self . erase_regions ( & trait_ref) ;
4143
42- self . trans_trait_caches . trait_cache . memoize ( trait_ref, || {
44+ self . trans_trait_caches . trait_cache . memoize ( ( param_env , trait_ref) , || {
4345 debug ! ( "trans::fulfill_obligation(trait_ref={:?}, def_id={:?})" ,
44- trait_ref, trait_ref. def_id( ) ) ;
46+ ( param_env , trait_ref) , trait_ref. def_id( ) ) ;
4547
4648 // Do the initial selection for the obligation. This yields the
4749 // shallow result we are looking for -- that is, what specific impl.
4850 self . infer_ctxt ( ) . enter ( |infcx| {
4951 let mut selcx = SelectionContext :: new ( & infcx) ;
5052
51- let param_env = ty:: ParamEnv :: empty ( Reveal :: All ) ;
5253 let obligation_cause = ObligationCause :: misc ( span,
5354 ast:: DUMMY_NODE_ID ) ;
5455 let obligation = Obligation :: new ( obligation_cause,
@@ -167,7 +168,7 @@ pub struct TraitSelectionCache<'tcx> {
167168}
168169
169170impl < ' tcx > DepTrackingMapConfig for TraitSelectionCache < ' tcx > {
170- type Key = ty:: PolyTraitRef < ' tcx > ;
171+ type Key = ( ty:: ParamEnv < ' tcx > , ty :: PolyTraitRef < ' tcx > ) ;
171172 type Value = Vtable < ' tcx , ( ) > ;
172173 fn to_dep_kind ( ) -> DepKind {
173174 DepKind :: TraitSelect
0 commit comments