]> git.lizzy.rs Git - rust.git/commitdiff
add ParamEnv to the trait_cache key
authorDouglas Campos <qmx@qmx.me>
Wed, 20 Sep 2017 02:39:00 +0000 (22:39 -0400)
committerDouglas Campos <qmx@qmx.me>
Mon, 25 Sep 2017 13:50:37 +0000 (09:50 -0400)
src/librustc/traits/trans/mod.rs

index 9c4a260b35d49a03cc213eb98f0e3928ca40a6eb..3bc8a65df1c1482d35553754533ff50c26e1be37 100644 (file)
@@ -38,17 +38,17 @@ pub fn trans_fulfill_obligation(self,
     {
         // Remove any references to regions; this helps improve caching.
         let trait_ref = self.erase_regions(&trait_ref);
+        let param_env = ty::ParamEnv::empty(Reveal::All);
 
-        self.trans_trait_caches.trait_cache.memoize(trait_ref, || {
+        self.trans_trait_caches.trait_cache.memoize((param_env, trait_ref), || {
             debug!("trans::fulfill_obligation(trait_ref={:?}, def_id={:?})",
-                   trait_ref, trait_ref.def_id());
+                   (param_env, trait_ref), trait_ref.def_id());
 
             // Do the initial selection for the obligation. This yields the
             // shallow result we are looking for -- that is, what specific impl.
             self.infer_ctxt().enter(|infcx| {
                 let mut selcx = SelectionContext::new(&infcx);
 
-                let param_env = ty::ParamEnv::empty(Reveal::All);
                 let obligation_cause = ObligationCause::misc(span,
                                                              ast::DUMMY_NODE_ID);
                 let obligation = Obligation::new(obligation_cause,
@@ -167,7 +167,7 @@ pub struct TraitSelectionCache<'tcx> {
 }
 
 impl<'tcx> DepTrackingMapConfig for TraitSelectionCache<'tcx> {
-    type Key = ty::PolyTraitRef<'tcx>;
+    type Key = (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>);
     type Value = Vtable<'tcx, ()>;
     fn to_dep_kind() -> DepKind {
         DepKind::TraitSelect