X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_trait_selection%2Fsrc%2Ftraits%2Fengine.rs;h=c028e89e4ea2963f093b48240a8f98ca613199d3;hb=ee6533d7408f1447c028025c883a34c904d25ba4;hp=3a05708aebc6c53c33416ea4a2e882fb503521c2;hpb=3539cf9344d3efb853751a17b520af35dcd5030b;p=rust.git diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index 3a05708aebc..c028e89e4ea 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -3,7 +3,7 @@ use super::TraitEngine; use super::{ChalkFulfillmentContext, FulfillmentContext}; -use crate::infer::InferCtxtExt; +use crate::traits::NormalizeExt; use rustc_data_structures::fx::FxIndexSet; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_infer::infer::at::ToTrace; @@ -104,14 +104,32 @@ pub fn register_bound( pub fn normalize>( &self, - cause: ObligationCause<'tcx>, + cause: &ObligationCause<'tcx>, param_env: ty::ParamEnv<'tcx>, value: T, ) -> T { - let infer_ok = self.infcx.partially_normalize_associated_types_in(cause, param_env, value); + let infer_ok = self.infcx.at(&cause, param_env).normalize(value); self.register_infer_ok_obligations(infer_ok) } + /// Makes `expected <: actual`. + pub fn eq_exp( + &self, + cause: &ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + a_is_expected: bool, + a: T, + b: T, + ) -> Result<(), TypeError<'tcx>> + where + T: ToTrace<'tcx>, + { + self.infcx + .at(cause, param_env) + .eq_exp(a_is_expected, a, b) + .map(|infer_ok| self.register_infer_ok_obligations(infer_ok)) + } + pub fn eq>( &self, cause: &ObligationCause<'tcx>, @@ -185,7 +203,7 @@ pub fn assumed_wf_types( // sound and then uncomment this line again. // implied_bounds.insert(ty); - let normalized = self.normalize(cause.clone(), param_env, ty); + let normalized = self.normalize(&cause, param_env, ty); implied_bounds.insert(normalized); } implied_bounds