about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-02-25 14:48:29 +0000
committerbors <bors@rust-lang.org>2019-02-25 14:48:29 +0000
commitb57fe74a27590289fd657614b8ad1f3eac8a7ad2 (patch)
tree49b041b31d467bfd832a41ec6770f23883ecb5ae
parentda573206f87b5510de4b0ee1a9c044127e409bd3 (diff)
parent4f89846377a51b382ec418aa5661640c015561e0 (diff)
downloadrust-b57fe74a27590289fd657614b8ad1f3eac8a7ad2.tar.gz
rust-b57fe74a27590289fd657614b8ad1f3eac8a7ad2.zip
Auto merge of #58649 - pnkfelix:issue-57464-avoid-ice-when-region-sneaks-into-impl-trait, r=pnkfelix
avoid ICE when region sneaks into impl trait

Addresses non-NLL instances of #57464
-rw-r--r--src/librustc/infer/canonical/canonicalizer.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/librustc/infer/canonical/canonicalizer.rs b/src/librustc/infer/canonical/canonicalizer.rs
index d06334c3ba6..7cd55951cda 100644
--- a/src/librustc/infer/canonical/canonicalizer.rs
+++ b/src/librustc/infer/canonical/canonicalizer.rs
@@ -191,7 +191,16 @@ impl CanonicalizeRegionMode for CanonicalizeQueryResponse {
                 // response should be executing in a fully
                 // canonicalized environment, so there shouldn't be
                 // any other region names it can come up.
-                bug!("unexpected region in query response: `{:?}`", r)
+                //
+                // rust-lang/rust#57464: `impl Trait` can leak local
+                // scopes (in manner violating typeck). Therefore, use
+                // `delay_span_bug` to allow type error over an ICE.
+                ty::tls::with_context(|c| {
+                    c.tcx.sess.delay_span_bug(
+                        syntax_pos::DUMMY_SP,
+                        &format!("unexpected region in query response: `{:?}`", r));
+                });
+                r
             }
         }
     }