move into provide methods

This commit is contained in:
Niko Matsakis 2018-06-27 09:42:00 -04:00
parent c3f7e02fb6
commit b2e899f843
7 changed files with 73 additions and 29 deletions

View File

@ -13,13 +13,22 @@
use rustc::traits::query::dropck_outlives::{DropckOutlivesResult, DtorckConstraint};
use rustc::traits::query::{CanonicalTyGoal, NoSolution};
use rustc::traits::{FulfillmentContext, Normalized, ObligationCause};
use rustc::ty::query::Providers;
use rustc::ty::subst::{Subst, Substs};
use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
use rustc::util::nodemap::FxHashSet;
use rustc_data_structures::sync::Lrc;
use syntax::codemap::{Span, DUMMY_SP};
crate fn dropck_outlives<'tcx>(
crate fn provide(p: &mut Providers) {
*p = Providers {
dropck_outlives,
adt_dtorck_constraint,
..*p
};
}
fn dropck_outlives<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
goal: CanonicalTyGoal<'tcx>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, DropckOutlivesResult<'tcx>>>>, NoSolution> {

View File

@ -11,10 +11,18 @@
use rustc::traits::{EvaluationResult, Obligation, ObligationCause,
OverflowError, SelectionContext, TraitQueryMode};
use rustc::traits::query::CanonicalPredicateGoal;
use rustc::ty::query::Providers;
use rustc::ty::{ParamEnvAnd, TyCtxt};
use syntax::codemap::DUMMY_SP;
crate fn evaluate_obligation<'tcx>(
crate fn provide(p: &mut Providers) {
*p = Providers {
evaluate_obligation,
..*p
};
}
fn evaluate_obligation<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
goal: CanonicalPredicateGoal<'tcx>,
) -> Result<EvaluationResult, OverflowError> {

View File

@ -39,22 +39,10 @@
use rustc::ty::query::Providers;
pub fn provide(p: &mut Providers) {
*p = Providers {
dropck_outlives: dropck_outlives::dropck_outlives,
adt_dtorck_constraint: dropck_outlives::adt_dtorck_constraint,
normalize_projection_ty: normalize_projection_ty::normalize_projection_ty,
normalize_ty_after_erasing_regions:
normalize_erasing_regions::normalize_ty_after_erasing_regions,
program_clauses_for: lowering::program_clauses_for,
program_clauses_for_env: lowering::program_clauses_for_env,
evaluate_obligation: evaluate_obligation::evaluate_obligation,
type_op_eq: type_op::type_op_eq,
type_op_prove_predicate: type_op::type_op_prove_predicate,
type_op_subtype: type_op::type_op_subtype,
type_op_normalize_ty: type_op::type_op_normalize_ty,
type_op_normalize_predicate: type_op::type_op_normalize_predicate,
type_op_normalize_fn_sig: type_op::type_op_normalize_fn_sig,
type_op_normalize_poly_fn_sig: type_op::type_op_normalize_poly_fn_sig,
..*p
};
dropck_outlives::provide(p);
evaluate_obligation::provide(p);
lowering::provide(p);
normalize_projection_ty::provide(p);
normalize_erasing_regions::provide(p);
type_op::provide(p);
}

View File

@ -14,6 +14,7 @@
use rustc::hir::{self, ImplPolarity};
use rustc::traits::{Clause, Clauses, DomainGoal, Goal, PolyDomainGoal, ProgramClause,
WhereClause, FromEnv, WellFormed};
use rustc::ty::query::Providers;
use rustc::ty::subst::Substs;
use rustc::ty::{self, Slice, TyCtxt};
use rustc_data_structures::fx::FxHashSet;
@ -22,6 +23,14 @@
use std::iter;
crate fn provide(p: &mut Providers) {
*p = Providers {
program_clauses_for,
program_clauses_for_env,
..*p
};
}
crate trait Lower<T> {
/// Lower a rustc construct (e.g. `ty::TraitPredicate`) to a chalk-like type.
fn lower(&self) -> T;

View File

@ -10,10 +10,18 @@
use rustc::traits::{Normalized, ObligationCause};
use rustc::traits::query::NoSolution;
use rustc::ty::query::Providers;
use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
use std::sync::atomic::Ordering;
crate fn normalize_ty_after_erasing_regions<'tcx>(
crate fn provide(p: &mut Providers) {
*p = Providers {
normalize_ty_after_erasing_regions,
..*p
};
}
fn normalize_ty_after_erasing_regions<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
goal: ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> Ty<'tcx> {

View File

@ -12,13 +12,21 @@
use rustc::infer::InferOk;
use rustc::traits::query::{normalize::NormalizationResult, CanonicalProjectionGoal, NoSolution};
use rustc::traits::{self, ObligationCause, SelectionContext};
use rustc::ty::query::Providers;
use rustc::ty::{ParamEnvAnd, TyCtxt};
use rustc_data_structures::sync::Lrc;
use std::sync::atomic::Ordering;
use syntax::ast::DUMMY_NODE_ID;
use syntax_pos::DUMMY_SP;
crate fn normalize_projection_ty<'tcx>(
crate fn provide(p: &mut Providers) {
*p = Providers {
normalize_projection_ty,
..*p
};
}
fn normalize_projection_ty<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
goal: CanonicalProjectionGoal<'tcx>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, NormalizationResult<'tcx>>>>, NoSolution> {

View File

@ -16,11 +16,25 @@
use rustc::traits::query::type_op::subtype::Subtype;
use rustc::traits::query::{Fallible, NoSolution};
use rustc::traits::{Obligation, Normalized, ObligationCause};
use rustc::ty::query::Providers;
use rustc::ty::{FnSig, Lift, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable};
use rustc_data_structures::sync::Lrc;
use std::fmt;
crate fn type_op_eq<'tcx>(
crate fn provide(p: &mut Providers) {
*p = Providers {
type_op_eq,
type_op_prove_predicate,
type_op_subtype,
type_op_normalize_ty,
type_op_normalize_predicate,
type_op_normalize_fn_sig,
type_op_normalize_poly_fn_sig,
..*p
};
}
fn type_op_eq<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
canonicalized: Canonical<'tcx, Eq<'tcx>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
@ -44,7 +58,7 @@ fn type_op_normalize<T>(
Ok(InferOk { value, obligations }) // ugh we should merge these two structs
}
crate fn type_op_normalize_ty(
fn type_op_normalize_ty(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
canonicalized: Canonical<'tcx, Normalize<'tcx, Ty<'tcx>>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, Ty<'tcx>>>>, NoSolution> {
@ -52,7 +66,7 @@ fn type_op_normalize<T>(
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
}
crate fn type_op_normalize_predicate(
fn type_op_normalize_predicate(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
canonicalized: Canonical<'tcx, Normalize<'tcx, Predicate<'tcx>>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, Predicate<'tcx>>>>, NoSolution> {
@ -60,7 +74,7 @@ fn type_op_normalize<T>(
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
}
crate fn type_op_normalize_fn_sig(
fn type_op_normalize_fn_sig(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
canonicalized: Canonical<'tcx, Normalize<'tcx, FnSig<'tcx>>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, FnSig<'tcx>>>>, NoSolution> {
@ -68,7 +82,7 @@ fn type_op_normalize<T>(
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
}
crate fn type_op_normalize_poly_fn_sig(
fn type_op_normalize_poly_fn_sig(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
canonicalized: Canonical<'tcx, Normalize<'tcx, PolyFnSig<'tcx>>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, PolyFnSig<'tcx>>>>, NoSolution> {
@ -76,7 +90,7 @@ fn type_op_normalize<T>(
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
}
crate fn type_op_subtype<'tcx>(
fn type_op_subtype<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
canonicalized: Canonical<'tcx, Subtype<'tcx>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
@ -95,7 +109,7 @@ fn type_op_normalize<T>(
)
}
crate fn type_op_prove_predicate<'tcx>(
fn type_op_prove_predicate<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
canonicalized: Canonical<'tcx, ProvePredicate<'tcx>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {