1 use rustc::infer::canonical::{Canonical, QueryResponse};
2 use rustc::traits::query::{normalize::NormalizationResult, CanonicalProjectionGoal, NoSolution};
3 use rustc::traits::{self, ObligationCause, SelectionContext, TraitEngineExt};
4 use rustc::ty::query::Providers;
5 use rustc::ty::{ParamEnvAnd, TyCtxt};
6 use rustc_data_structures::sync::Lrc;
7 use std::sync::atomic::Ordering;
8 use syntax::ast::DUMMY_NODE_ID;
9 use syntax_pos::DUMMY_SP;
11 crate fn provide(p: &mut Providers) {
13 normalize_projection_ty,
18 fn normalize_projection_ty<'tcx>(
19 tcx: TyCtxt<'_, 'tcx, 'tcx>,
20 goal: CanonicalProjectionGoal<'tcx>,
21 ) -> Result<Lrc<Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>>, NoSolution> {
22 debug!("normalize_provider(goal={:#?})", goal);
26 .normalize_projection_ty
27 .fetch_add(1, Ordering::Relaxed);
28 tcx.infer_ctxt().enter_canonical_trait_query(
36 let selcx = &mut SelectionContext::new(infcx);
37 let cause = ObligationCause::misc(DUMMY_SP, DUMMY_NODE_ID);
38 let mut obligations = vec![];
39 let answer = traits::normalize_projection_type(
47 fulfill_cx.register_predicate_obligations(infcx, obligations);
48 Ok(NormalizationResult {
49 normalized_ty: answer,