diff options
| author | Michael Goulet <michael@errs.io> | 2022-10-26 18:00:18 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-10-27 15:43:33 +0000 |
| commit | d793d80cf7e60d1bdaefffb221dd45875ed9574a (patch) | |
| tree | a169efa7c83bd47738def9c5275db24e1ea33176 /compiler/rustc_trait_selection/src/traits/engine.rs | |
| parent | 0da281b6068a7d889ae89a9bd8991284cc9b7535 (diff) | |
| download | rust-d793d80cf7e60d1bdaefffb221dd45875ed9574a.tar.gz rust-d793d80cf7e60d1bdaefffb221dd45875ed9574a.zip | |
(almost) Always use ObligationCtxt when dealing with canonical queries
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/engine.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/engine.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index e0c8deec91a..18ad99b4935 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -1,14 +1,20 @@ use std::cell::RefCell; +use std::fmt::Debug; use super::TraitEngine; use super::{ChalkFulfillmentContext, FulfillmentContext}; use crate::infer::InferCtxtExt; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def_id::{DefId, LocalDefId}; +use rustc_infer::infer::canonical::{ + Canonical, CanonicalVarValues, CanonicalizedQueryResponse, QueryResponse, +}; use rustc_infer::infer::{InferCtxt, InferOk}; +use rustc_infer::traits::query::Fallible; use rustc_infer::traits::{ FulfillmentError, Obligation, ObligationCause, PredicateObligation, TraitEngineExt as _, }; +use rustc_middle::arena::ArenaAllocatable; use rustc_middle::ty::error::TypeError; use rustc_middle::ty::ToPredicate; use rustc_middle::ty::TypeFoldable; @@ -154,4 +160,20 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> { } implied_bounds } + + pub fn make_canonicalized_query_response<T>( + &self, + inference_vars: CanonicalVarValues<'tcx>, + answer: T, + ) -> Fallible<CanonicalizedQueryResponse<'tcx, T>> + where + T: Debug + TypeFoldable<'tcx>, + Canonical<'tcx, QueryResponse<'tcx, T>>: ArenaAllocatable<'tcx>, + { + self.infcx.make_canonicalized_query_response( + inference_vars, + answer, + &mut **self.engine.borrow_mut(), + ) + } } |
