about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/infer.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-11-01 12:15:10 +0000
committerbors <bors@rust-lang.org>2022-11-01 12:15:10 +0000
commite70cbef0c5db81079f4b5643380d6047ccd34a10 (patch)
tree6123ac4c7d8880a04e10a9e75f291b19001caa3c /compiler/rustc_trait_selection/src/infer.rs
parentc493bae0d8efd75723460ce5c371f726efa93f15 (diff)
parent2f9794b84a4ae882edd428c1c3764eec99cdebff (diff)
downloadrust-e70cbef0c5db81079f4b5643380d6047ccd34a10.tar.gz
rust-e70cbef0c5db81079f4b5643380d6047ccd34a10.zip
Auto merge of #103590 - compiler-errors:ocx-more, r=lcnr
(almost) Always use `ObligationCtxt` when dealing with canonical queries

Hope this is a step in the right direction. cc rust-lang/types-team#50.

r? `@lcnr`
Diffstat (limited to 'compiler/rustc_trait_selection/src/infer.rs')
-rw-r--r--compiler/rustc_trait_selection/src/infer.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_trait_selection/src/infer.rs b/compiler/rustc_trait_selection/src/infer.rs
index a335f8e06bc..96ac4e9c129 100644
--- a/compiler/rustc_trait_selection/src/infer.rs
+++ b/compiler/rustc_trait_selection/src/infer.rs
@@ -1,5 +1,5 @@
 use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
-use crate::traits::{self, TraitEngine, TraitEngineExt};
+use crate::traits::{self, ObligationCtxt};
 
 use rustc_hir::def_id::DefId;
 use rustc_hir::lang_items::LangItem;
@@ -142,7 +142,7 @@ pub trait InferCtxtBuilderExt<'tcx> {
     fn enter_canonical_trait_query<K, R>(
         &mut self,
         canonical_key: &Canonical<'tcx, K>,
-        operation: impl FnOnce(&InferCtxt<'tcx>, &mut dyn TraitEngine<'tcx>, K) -> Fallible<R>,
+        operation: impl FnOnce(&ObligationCtxt<'_, 'tcx>, K) -> Fallible<R>,
     ) -> Fallible<CanonicalizedQueryResponse<'tcx, R>>
     where
         K: TypeFoldable<'tcx>,
@@ -170,17 +170,17 @@ impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> {
     fn enter_canonical_trait_query<K, R>(
         &mut self,
         canonical_key: &Canonical<'tcx, K>,
-        operation: impl FnOnce(&InferCtxt<'tcx>, &mut dyn TraitEngine<'tcx>, K) -> Fallible<R>,
+        operation: impl FnOnce(&ObligationCtxt<'_, 'tcx>, K) -> Fallible<R>,
     ) -> Fallible<CanonicalizedQueryResponse<'tcx, R>>
     where
         K: TypeFoldable<'tcx>,
         R: Debug + TypeFoldable<'tcx>,
         Canonical<'tcx, QueryResponse<'tcx, R>>: ArenaAllocatable<'tcx>,
     {
-        let (ref infcx, key, canonical_inference_vars) =
+        let (infcx, key, canonical_inference_vars) =
             self.build_with_canonical(DUMMY_SP, canonical_key);
-        let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
-        let value = operation(infcx, &mut *fulfill_cx, key)?;
-        infcx.make_canonicalized_query_response(canonical_inference_vars, value, &mut *fulfill_cx)
+        let ocx = ObligationCtxt::new(&infcx);
+        let value = operation(&ocx, key)?;
+        ocx.make_canonicalized_query_response(canonical_inference_vars, value)
     }
 }