|
1 | | -use rustc_middle::traits::solve::{Certainty, Goal, MaybeCause}; |
| 1 | +use rustc_infer::traits::{TraitEngine, TraitEngineExt}; |
2 | 2 | use rustc_middle::ty; |
3 | 3 |
|
4 | 4 | use crate::infer::canonical::OriginalQueryValues; |
5 | 5 | use crate::infer::InferCtxt; |
6 | | -use crate::solve::InferCtxtEvalExt; |
7 | 6 | use crate::traits::{EvaluationResult, OverflowError, PredicateObligation, SelectionContext}; |
8 | 7 |
|
9 | 8 | pub trait InferCtxtExt<'tcx> { |
@@ -81,35 +80,20 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { |
81 | 80 |
|
82 | 81 | if self.tcx.trait_solver_next() { |
83 | 82 | self.probe(|snapshot| { |
84 | | - if let Ok((_, certainty, nested_goals)) = |
85 | | - self.evaluate_root_goal(Goal::new(self.tcx, param_env, obligation.predicate)) |
86 | | - { |
87 | | - match certainty { |
88 | | - // If we have nested obligations from instantiating the canonical |
89 | | - // response from this goal, just treat the response as ambiguous. |
90 | | - // |
91 | | - // FIXME(deferred_projection_equality): We need to process this |
92 | | - // in a loop probably... can't be worse than an ICE though |
93 | | - Certainty::Yes if !nested_goals.is_empty() => { |
94 | | - Ok(EvaluationResult::EvaluatedToAmbig) |
95 | | - } |
96 | | - Certainty::Yes => { |
97 | | - if self.opaque_types_added_in_snapshot(snapshot) { |
98 | | - Ok(EvaluationResult::EvaluatedToOkModuloOpaqueTypes) |
99 | | - } else if self.region_constraints_added_in_snapshot(snapshot).is_some() |
100 | | - { |
101 | | - Ok(EvaluationResult::EvaluatedToOkModuloRegions) |
102 | | - } else { |
103 | | - Ok(EvaluationResult::EvaluatedToOk) |
104 | | - } |
105 | | - } |
106 | | - Certainty::Maybe(MaybeCause::Ambiguity) => { |
107 | | - Ok(EvaluationResult::EvaluatedToAmbig) |
108 | | - } |
109 | | - Certainty::Maybe(MaybeCause::Overflow) => Err(OverflowError::Canonical), |
110 | | - } |
111 | | - } else { |
| 83 | + let mut fulfill_cx = crate::solve::FulfillmentCtxt::new(); |
| 84 | + fulfill_cx.register_predicate_obligation(self, obligation.clone()); |
| 85 | + // True errors |
| 86 | + // FIXME(-Ztrait-solver=next): Overflows are reported as ambig here, is that OK? |
| 87 | + if !fulfill_cx.select_where_possible(self).is_empty() { |
112 | 88 | Ok(EvaluationResult::EvaluatedToErr) |
| 89 | + } else if !fulfill_cx.select_all_or_error(self).is_empty() { |
| 90 | + Ok(EvaluationResult::EvaluatedToAmbig) |
| 91 | + } else if self.opaque_types_added_in_snapshot(snapshot) { |
| 92 | + Ok(EvaluationResult::EvaluatedToOkModuloOpaqueTypes) |
| 93 | + } else if self.region_constraints_added_in_snapshot(snapshot).is_some() { |
| 94 | + Ok(EvaluationResult::EvaluatedToOkModuloRegions) |
| 95 | + } else { |
| 96 | + Ok(EvaluationResult::EvaluatedToOk) |
113 | 97 | } |
114 | 98 | }) |
115 | 99 | } else { |
|
0 commit comments