@@ -19,7 +19,7 @@ use std::cell::RefCell;
19
19
use std:: marker:: PhantomData ;
20
20
use syntax:: ast;
21
21
use syntax_pos:: Span ;
22
- use traits:: { FulfillmentContext , Obligation , ObligationCause , Reveal , SelectionContext , Vtable } ;
22
+ use traits:: { FulfillmentContext , Obligation , ObligationCause , SelectionContext , Vtable } ;
23
23
use ty:: { self , Ty , TyCtxt } ;
24
24
use ty:: subst:: { Subst , Substs } ;
25
25
use ty:: fold:: { TypeFoldable , TypeFolder } ;
@@ -31,24 +31,25 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
31
31
/// (necessarily) resolve all nested obligations on the impl. Note
32
32
/// that type check should guarantee to us that all nested
33
33
/// obligations *could be* resolved if we wanted to.
34
+ /// Assumes that this is run after the entire crate has been successfully type-checked.
34
35
pub fn trans_fulfill_obligation ( self ,
35
36
span : Span ,
37
+ param_env : ty:: ParamEnv < ' tcx > ,
36
38
trait_ref : ty:: PolyTraitRef < ' tcx > )
37
39
-> Vtable < ' tcx , ( ) >
38
40
{
39
41
// Remove any references to regions; this helps improve caching.
40
42
let trait_ref = self . erase_regions ( & trait_ref) ;
41
43
42
- self . trans_trait_caches . trait_cache . memoize ( trait_ref, || {
44
+ self . trans_trait_caches . trait_cache . memoize ( ( param_env , trait_ref) , || {
43
45
debug ! ( "trans::fulfill_obligation(trait_ref={:?}, def_id={:?})" ,
44
- trait_ref, trait_ref. def_id( ) ) ;
46
+ ( param_env , trait_ref) , trait_ref. def_id( ) ) ;
45
47
46
48
// Do the initial selection for the obligation. This yields the
47
49
// shallow result we are looking for -- that is, what specific impl.
48
50
self . infer_ctxt ( ) . enter ( |infcx| {
49
51
let mut selcx = SelectionContext :: new ( & infcx) ;
50
52
51
- let param_env = ty:: ParamEnv :: empty ( Reveal :: All ) ;
52
53
let obligation_cause = ObligationCause :: misc ( span,
53
54
ast:: DUMMY_NODE_ID ) ;
54
55
let obligation = Obligation :: new ( obligation_cause,
@@ -167,7 +168,7 @@ pub struct TraitSelectionCache<'tcx> {
167
168
}
168
169
169
170
impl < ' tcx > DepTrackingMapConfig for TraitSelectionCache < ' tcx > {
170
- type Key = ty:: PolyTraitRef < ' tcx > ;
171
+ type Key = ( ty:: ParamEnv < ' tcx > , ty :: PolyTraitRef < ' tcx > ) ;
171
172
type Value = Vtable < ' tcx , ( ) > ;
172
173
fn to_dep_kind ( ) -> DepKind {
173
174
DepKind :: TraitSelect
0 commit comments