Skip to content

Commit dbbb424

Browse files
EvaluateToAmbig if evaluate_root_obligation does inference
1 parent 077fc26 commit dbbb424

File tree

1 file changed

+10
-3
lines changed
  • compiler/rustc_trait_selection/src/traits/select

1 file changed

+10
-3
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,21 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
537537
obligation: &PredicateObligation<'tcx>,
538538
) -> Result<EvaluationResult, OverflowError> {
539539
self.evaluation_probe(|this| {
540-
if this.tcx().trait_solver_next() {
541-
this.evaluate_predicates_recursively_in_new_solver([obligation.clone()])
540+
let goal = infcx.resolve_vars_if_possible((obligation.predicate, obligation.param_env));
541+
let mut result = if this.tcx().trait_solver_next() {
542+
this.evaluate_predicates_recursively_in_new_solver([obligation.clone()])?
542543
} else {
543544
this.evaluate_predicate_recursively(
544545
TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
545546
obligation.clone(),
546-
)
547+
)?
548+
};
549+
// If the predicate has done any inference, then downgrade the
550+
// result to ambiguous.
551+
if this.infcx.shallow_resolve(goal) != goal {
552+
result = result.max(EvaluatedToAmbig);
547553
}
554+
Ok(result)
548555
})
549556
}
550557

0 commit comments

Comments
 (0)