|
1 | 1 | use rustc_macros::extension; |
2 | 2 | use rustc_middle::span_bug; |
| 3 | +use rustc_next_trait_solver::solve::{Certainty, GenerateProofTree, SolverDelegateEvalExt}; |
| 4 | +use rustc_span::DUMMY_SP; |
3 | 5 |
|
4 | 6 | use crate::infer::InferCtxt; |
5 | 7 | use crate::infer::canonical::OriginalQueryValues; |
6 | | -use crate::traits::{ |
7 | | - EvaluationResult, ObligationCtxt, OverflowError, PredicateObligation, SelectionContext, |
8 | | -}; |
| 8 | +use crate::solve::SolverDelegate; |
| 9 | +use crate::traits::{EvaluationResult, OverflowError, PredicateObligation, SelectionContext}; |
9 | 10 |
|
10 | 11 | #[extension(pub trait InferCtxtExt<'tcx>)] |
11 | 12 | impl<'tcx> InferCtxt<'tcx> { |
@@ -69,16 +70,14 @@ impl<'tcx> InferCtxt<'tcx> { |
69 | 70 |
|
70 | 71 | if self.next_trait_solver() { |
71 | 72 | self.probe(|snapshot| { |
72 | | - let ocx = ObligationCtxt::new(self); |
73 | | - ocx.register_obligation(obligation.clone()); |
74 | | - let mut result = EvaluationResult::EvaluatedToOk; |
75 | | - for error in ocx.select_all_or_error() { |
76 | | - if error.is_true_error() { |
77 | | - return Ok(EvaluationResult::EvaluatedToErr); |
78 | | - } else { |
79 | | - result = result.max(EvaluationResult::EvaluatedToAmbig); |
80 | | - } |
81 | | - } |
| 73 | + let mut result = match <&SolverDelegate<'tcx>>::from(self) |
| 74 | + .evaluate_root_goal(obligation.as_goal(), GenerateProofTree::No, DUMMY_SP) |
| 75 | + .0 |
| 76 | + { |
| 77 | + Ok((_, Certainty::Yes)) => EvaluationResult::EvaluatedToOk, |
| 78 | + Ok((_, Certainty::Maybe(_))) => EvaluationResult::EvaluatedToAmbig, |
| 79 | + Err(_) => EvaluationResult::EvaluatedToErr, |
| 80 | + }; |
82 | 81 | if self.opaque_types_added_in_snapshot(snapshot) { |
83 | 82 | result = result.max(EvaluationResult::EvaluatedToOkModuloOpaqueTypes); |
84 | 83 | } else if self.region_constraints_added_in_snapshot(snapshot) { |
|
0 commit comments