//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/specialization.html
pub mod specialization_graph;
-use rustc_infer::traits::{TraitEngine, TraitEngineExt as _};
use specialization_graph::GraphExt;
use crate::errors::NegativePositiveConflict;
use crate::infer::{InferCtxt, InferOk, TyCtxtInferExt};
-use crate::traits::engine::TraitEngineExt as _;
use crate::traits::select::IntercrateAmbiguityCause;
-use crate::traits::{self, coherence, FutureCompatOverlapErrorKind, ObligationCause};
+use crate::traits::{
+ self, coherence, FutureCompatOverlapErrorKind, ObligationCause, ObligationCtxt,
+};
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{error_code, DelayDm, Diagnostic};
use rustc_hir::def_id::{DefId, LocalDefId};
// Needs to be `in_snapshot` because this function is used to rebase
// substitutions, which may happen inside of a select within a probe.
- let mut engine = <dyn TraitEngine<'tcx>>::new_in_snapshot(infcx.tcx);
+ let ocx = ObligationCtxt::new_in_snapshot(infcx);
// attempt to prove all of the predicates for impl2 given those for impl1
// (which are packed up in penv)
- engine.register_predicate_obligations(infcx, obligations.chain(more_obligations));
+ ocx.register_obligations(obligations.chain(more_obligations));
- let errors = engine.select_all_or_error(infcx);
+ let errors = ocx.select_all_or_error();
if !errors.is_empty() {
// no dice!
debug!(
Ok(infcx.resolve_vars_if_possible(target_substs))
}
-// Query provider for `specialization_graph_of`.
+/// Query provider for `specialization_graph_of`.
pub(super) fn specialization_graph_provider(
tcx: TyCtxt<'_>,
trait_id: DefId,
trait_pred
});
- p = tcx.mk_predicate(new_trait_pred.map_bound(ty::PredicateKind::Trait))
+ p = tcx.mk_predicate(
+ new_trait_pred.map_bound(|p| ty::PredicateKind::Clause(ty::Clause::Trait(p))),
+ )
}
}
pretty_predicates.push(p.to_string());