Skip to content

Commit a725436

Browse files
committed
return default UniverseInfo cause in RegionInferenceContext
Query canonicalization can create local super-universes without causes, creating ICEs when accessed during diagnostics.
1 parent 7659abc commit a725436

File tree

1 file changed

+8
-1
lines changed
  • compiler/rustc_borrowck/src/region_infer

1 file changed

+8
-1
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
22492249
}
22502250

22512251
pub(crate) fn universe_info(&self, universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
2252-
self.universe_causes[&universe].clone()
2252+
// Query canonicalization can create local superuniverses (for example in
2253+
// `InferCtx::query_response_substitution_guess`), but they don't have an associated
2254+
// `UniverseInfo` explaining why they were created.
2255+
// This can cause ICEs if these causes are accessed in diagnostics, for example in issue
2256+
// #114907 where this happens via liveness and dropck outlives results.
2257+
// Therefore, we return a default value in case that happens, which should at worst emit a
2258+
// suboptimal error, instead of the ICE.
2259+
self.universe_causes.get(&universe).cloned().unwrap_or_else(|| UniverseInfo::other())
22532260
}
22542261

22552262
/// Tries to find the terminator of the loop in which the region 'r' resides.

0 commit comments

Comments
 (0)