1
Fork 0

Rollup merge of #133493 - lcnr:fulfill-fudge, r=compiler-errors

do not constrain infer vars in `find_best_leaf_obligation`

This ended up causing an ICE by making the following code path reachable by incorrectly constraining an inference variable while computing the best obligation for a preceding ambiguity. Closes #129444.

f2abf827c1/compiler/rustc_trait_selection/src/solve/fulfill.rs (L312-L314)

I have to be honest, I don't fully understand how that change removes all the additional diagnostics :3

r? `@compiler-errors`
This commit is contained in:
Matthias Krüger 2024-11-27 08:13:49 +01:00 committed by GitHub
commit 762a661705
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 114 additions and 138 deletions

View file

@ -346,12 +346,21 @@ fn find_best_leaf_obligation<'tcx>(
consider_ambiguities: bool,
) -> PredicateObligation<'tcx> {
let obligation = infcx.resolve_vars_if_possible(obligation.clone());
// FIXME: we use a probe here as the `BestObligation` visitor does not
// check whether it uses candidates which get shadowed by where-bounds.
//
// We should probably fix the visitor to not do so instead, as this also
// means the leaf obligation may be incorrect.
infcx
.visit_proof_tree(obligation.clone().into(), &mut BestObligation {
obligation: obligation.clone(),
consider_ambiguities,
.fudge_inference_if_ok(|| {
infcx
.visit_proof_tree(obligation.clone().into(), &mut BestObligation {
obligation: obligation.clone(),
consider_ambiguities,
})
.break_value()
.ok_or(())
})
.break_value()
.unwrap_or(obligation)
}