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::{
// TypeOutlives predicates - these are normally used by regionck.
let outlives_predicates: Vec<_> = predicates
.drain_filter(|predicate| {
- matches!(predicate.kind().skip_binder(), ty::PredicateKind::TypeOutlives(..))
+ matches!(
+ predicate.kind().skip_binder(),
+ ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
+ )
})
.collect();
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)
+ fully_solve_obligations(infcx, [obligation])
}
/// Process a set of obligations (and any nested obligations that come from them)
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.
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 tcx = infcx.tcx;
+ let trait_ref = ty::TraitRef { def_id: bound, substs: tcx.mk_substs_trait(ty, []) };
+ let obligation = Obligation {
+ cause,
+ recursion_depth: 0,
+ param_env,
+ predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
+ };
+
+ fully_solve_obligation(infcx, obligation)
}
/// Normalizes the predicates and checks whether they hold in an empty environment. If this
// associated items.
if let Some(trait_def_id) = tcx.trait_of_item(key.0) {
let trait_ref = ty::TraitRef::from_method(tcx, trait_def_id, key.1);
- predicates.push(ty::Binder::dummy(trait_ref).to_poly_trait_predicate().to_predicate(tcx));
+ predicates.push(ty::Binder::dummy(trait_ref).to_predicate(tcx));
}
predicates.retain(|predicate| !predicate.needs_subst());
vtable_trait_upcasting_coercion_new_vptr_slot,
subst_and_check_impossible_predicates,
is_impossible_method,
- try_unify_abstract_consts: |tcx, param_env_and| {
- let (param_env, (a, b)) = param_env_and.into_parts();
- const_evaluatable::try_unify_abstract_consts(tcx, (a, b), param_env)
- },
..*providers
};
}