|
1 | 1 | use crate::traits::{specialization_graph, translate_substs}; |
2 | 2 |
|
3 | 3 | use super::assembly::{self, Candidate, CandidateSource}; |
| 4 | +use super::infcx_ext::InferCtxtExt; |
4 | 5 | use super::{Certainty, EvalCtxt, Goal, QueryResult}; |
5 | 6 | use rustc_errors::ErrorGuaranteed; |
6 | 7 | use rustc_hir::def::DefKind; |
7 | 8 | use rustc_hir::def_id::DefId; |
8 | | -use rustc_infer::infer::{InferCtxt, InferOk}; |
| 9 | +use rustc_infer::infer::InferCtxt; |
9 | 10 | use rustc_infer::traits::query::NoSolution; |
10 | 11 | use rustc_infer::traits::specialization_graph::LeafDef; |
11 | | -use rustc_infer::traits::{ObligationCause, Reveal}; |
| 12 | +use rustc_infer::traits::Reveal; |
12 | 13 | use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams}; |
13 | 14 | use rustc_middle::ty::ProjectionPredicate; |
14 | 15 | use rustc_middle::ty::TypeVisitable; |
@@ -112,23 +113,15 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> { |
112 | 113 | let impl_substs = ecx.infcx.fresh_substs_for_item(DUMMY_SP, impl_def_id); |
113 | 114 | let impl_trait_ref = impl_trait_ref.subst(tcx, impl_substs); |
114 | 115 |
|
115 | | - let Ok(InferOk { obligations, .. }) = ecx.infcx |
116 | | - .at(&ObligationCause::dummy(), goal.param_env) |
117 | | - .define_opaque_types(false) |
118 | | - .eq(goal_trait_ref, impl_trait_ref) |
119 | | - .map_err(|e| debug!("failed to equate trait refs: {e:?}")) |
120 | | - else { |
121 | | - return Err(NoSolution) |
122 | | - }; |
| 116 | + let mut nested_goals = ecx.infcx.eq(goal.param_env, goal_trait_ref, impl_trait_ref)?; |
123 | 117 | let where_clause_bounds = tcx |
124 | 118 | .predicates_of(impl_def_id) |
125 | 119 | .instantiate(tcx, impl_substs) |
126 | 120 | .predicates |
127 | 121 | .into_iter() |
128 | 122 | .map(|pred| goal.with(tcx, pred)); |
129 | 123 |
|
130 | | - let nested_goals = |
131 | | - obligations.into_iter().map(|o| o.into()).chain(where_clause_bounds).collect(); |
| 124 | + nested_goals.extend(where_clause_bounds); |
132 | 125 | let trait_ref_certainty = ecx.evaluate_all(nested_goals)?; |
133 | 126 |
|
134 | 127 | let Some(assoc_def) = fetch_eligible_assoc_item_def( |
@@ -185,16 +178,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> { |
185 | 178 | ty.map_bound(|ty| ty.into()) |
186 | 179 | }; |
187 | 180 |
|
188 | | - let Ok(InferOk { obligations, .. }) = ecx.infcx |
189 | | - .at(&ObligationCause::dummy(), goal.param_env) |
190 | | - .define_opaque_types(false) |
191 | | - .eq(goal.predicate.term, term.subst(tcx, substs)) |
192 | | - .map_err(|e| debug!("failed to equate trait refs: {e:?}")) |
193 | | - else { |
194 | | - return Err(NoSolution); |
195 | | - }; |
196 | | - |
197 | | - let nested_goals = obligations.into_iter().map(|o| o.into()).collect(); |
| 181 | + let nested_goals = |
| 182 | + ecx.infcx.eq(goal.param_env, goal.predicate.term, term.subst(tcx, substs))?; |
198 | 183 | let rhs_certainty = ecx.evaluate_all(nested_goals)?; |
199 | 184 |
|
200 | 185 | Ok(trait_ref_certainty.unify_and(rhs_certainty)) |
|
0 commit comments