From 4f89846377a51b382ec418aa5661640c015561e0 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 22 Feb 2019 13:40:21 +0100 Subject: [PATCH] Fix #57979 by allowing a legitimate type error to take precedence over an ICE. --- src/librustc/infer/canonical/canonicalizer.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/librustc/infer/canonical/canonicalizer.rs b/src/librustc/infer/canonical/canonicalizer.rs index d06334c3ba643..7cd55951cdaf4 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 } } }