]> git.lizzy.rs Git - rust.git/commitdiff
don't cache overflow results globally
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 13 Sep 2018 17:40:25 +0000 (13:40 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 13 Sep 2018 17:40:33 +0000 (13:40 -0400)
src/librustc/traits/select.rs

index 69bdeec6eea230099bd209572893ea8542b7753a..c5adec2c6d2636f5d00ebd5869efd5378f4adad1 100644 (file)
@@ -1376,7 +1376,10 @@ fn insert_candidate_cache(&mut self,
         let tcx = self.tcx();
         let trait_ref = cache_fresh_trait_pred.skip_binder().trait_ref;
         if self.can_use_global_caches(param_env) {
-            if let Some(trait_ref) = tcx.lift_to_global(&trait_ref) {
+            if let Err(Overflow) = candidate {
+                // Don't cache overflow globally; we only produce this
+                // in certain modes.
+            } else if let Some(trait_ref) = tcx.lift_to_global(&trait_ref) {
                 if let Some(candidate) = tcx.lift_to_global(&candidate) {
                     debug!(
                         "insert_candidate_cache(trait_ref={:?}, candidate={:?}) global",