Skip to content

Commit 4f89846

Browse files
committed
Fix #57979 by allowing a legitimate type error to take precedence over an ICE.
1 parent f47ec2a commit 4f89846

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/librustc/infer/canonical/canonicalizer.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,16 @@ impl CanonicalizeRegionMode for CanonicalizeQueryResponse {
191191
// response should be executing in a fully
192192
// canonicalized environment, so there shouldn't be
193193
// any other region names it can come up.
194-
bug!("unexpected region in query response: `{:?}`", r)
194+
//
195+
// rust-lang/rust#57464: `impl Trait` can leak local
196+
// scopes (in manner violating typeck). Therefore, use
197+
// `delay_span_bug` to allow type error over an ICE.
198+
ty::tls::with_context(|c| {
199+
c.tcx.sess.delay_span_bug(
200+
syntax_pos::DUMMY_SP,
201+
&format!("unexpected region in query response: `{:?}`", r));
202+
});
203+
r
195204
}
196205
}
197206
}

0 commit comments

Comments
 (0)