Rollup merge of #140021 - compiler-errors:no-deep-norm-ice, r=lcnr

Don't ICE on pending obligations from deep normalization in a loop

See the comment I left inline in `compiler/rustc_trait_selection/src/traits/normalize.rs`.

Fixes https://github.com/rust-lang/rust/issues/133868

r? lcnr
This commit is contained in:
Chris Denton 2025-04-21 15:55:58 +00:00 committed by GitHub
commit f79eef91df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 163 additions and 14 deletions

View file

@ -77,7 +77,15 @@ impl<'tcx> At<'_, 'tcx> {
.into_value_registering_obligations(self.infcx, &mut *fulfill_cx);
let errors = fulfill_cx.select_all_or_error(self.infcx);
let value = self.infcx.resolve_vars_if_possible(value);
if errors.is_empty() { Ok(value) } else { Err(errors) }
if errors.is_empty() {
Ok(value)
} else {
// Drop pending obligations, since deep normalization may happen
// in a loop and we don't want to trigger the assertion on the next
// iteration due to pending ambiguous obligations we've left over.
let _ = fulfill_cx.collect_remaining_errors(self.infcx);
Err(errors)
}
}
}
}