Auto merge of #110100 - compiler-errors:no-infer-pred-must-hold, r=jackh726
do not allow inference in `predicate_must_hold` (alternative approach) See the FCP description for more info, but tl;dr is that we should not return `EvaluatedToOkModuloRegions` if an obligation may hold only with some choice of inference vars being constrained. Attempts to solve this in the approach laid out by lcnr here: https://github.com/rust-lang/rust/pull/109558#discussion_r1147318134, rather than by eagerly replacing infer vars with placeholders which is a bit too restrictive. r? `@ghost`
This commit is contained in:
commit
19ca5692f6
4 changed files with 46 additions and 24 deletions
|
@ -537,14 +537,22 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation: &PredicateObligation<'tcx>,
|
||||
) -> Result<EvaluationResult, OverflowError> {
|
||||
self.evaluation_probe(|this| {
|
||||
if this.tcx().trait_solver_next() {
|
||||
this.evaluate_predicates_recursively_in_new_solver([obligation.clone()])
|
||||
let goal =
|
||||
this.infcx.resolve_vars_if_possible((obligation.predicate, obligation.param_env));
|
||||
let mut result = if this.tcx().trait_solver_next() {
|
||||
this.evaluate_predicates_recursively_in_new_solver([obligation.clone()])?
|
||||
} else {
|
||||
this.evaluate_predicate_recursively(
|
||||
TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
|
||||
obligation.clone(),
|
||||
)
|
||||
)?
|
||||
};
|
||||
// If the predicate has done any inference, then downgrade the
|
||||
// result to ambiguous.
|
||||
if this.infcx.shallow_resolve(goal) != goal {
|
||||
result = result.max(EvaluatedToAmbig);
|
||||
}
|
||||
Ok(result)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue