Use ObligationCtxt intead of dyn TraitEngine

This commit is contained in:
Santiago Pastorino 2022-11-16 15:58:48 -03:00
parent 3f2b2eee8f
commit ad094cdceb
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
5 changed files with 30 additions and 47 deletions

View file

@ -31,7 +31,6 @@ use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem;
use rustc_infer::traits::TraitEngineExt as _;
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::visit::TypeVisitable;
use rustc_middle::ty::{
@ -403,9 +402,9 @@ pub fn fully_solve_obligation<'tcx>(
infcx: &InferCtxt<'tcx>,
obligation: PredicateObligation<'tcx>,
) -> Vec<FulfillmentError<'tcx>> {
let mut engine = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
engine.register_predicate_obligation(infcx, obligation);
engine.select_all_or_error(infcx)
let ocx = ObligationCtxt::new(infcx);
ocx.register_obligation(obligation);
ocx.select_all_or_error()
}
/// Process a set of obligations (and any nested obligations that come from them)
@ -414,9 +413,9 @@ pub fn fully_solve_obligations<'tcx>(
infcx: &InferCtxt<'tcx>,
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
) -> Vec<FulfillmentError<'tcx>> {
let mut engine = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
engine.register_predicate_obligations(infcx, obligations);
engine.select_all_or_error(infcx)
let ocx = ObligationCtxt::new(infcx);
ocx.register_obligations(obligations);
ocx.select_all_or_error()
}
/// Process a bound (and any nested obligations that come from it) to completion.
@ -429,9 +428,9 @@ pub fn fully_solve_bound<'tcx>(
ty: Ty<'tcx>,
bound: DefId,
) -> Vec<FulfillmentError<'tcx>> {
let mut engine = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
engine.register_bound(infcx, param_env, ty, bound, cause);
engine.select_all_or_error(infcx)
let ocx = ObligationCtxt::new(infcx);
ocx.register_bound(cause, param_env, ty, bound);
ocx.select_all_or_error()
}
/// Normalizes the predicates and checks whether they hold in an empty environment. If this