diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-06-11 10:03:14 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2018-06-26 10:59:40 -0400 |
| commit | 265552258048b2008975d98de75c7e536bc4f894 (patch) | |
| tree | 9bb3f8c89a6c623f739f6e7fd61ffb4ca7af66ed | |
| parent | 3b446b4b914945209d917a02572909717c6bd0b9 (diff) | |
| download | rust-265552258048b2008975d98de75c7e536bc4f894.tar.gz rust-265552258048b2008975d98de75c7e536bc4f894.zip | |
move `type_op` into `rustc`
| -rw-r--r-- | src/librustc/traits/query/mod.rs | 1 | ||||
| -rw-r--r-- | src/librustc/traits/query/type_op/custom.rs (renamed from src/librustc_mir/borrow_check/nll/type_check/type_op/custom.rs) | 10 | ||||
| -rw-r--r-- | src/librustc/traits/query/type_op/eq.rs (renamed from src/librustc_mir/borrow_check/nll/type_check/type_op/eq.rs) | 12 | ||||
| -rw-r--r-- | src/librustc/traits/query/type_op/mod.rs (renamed from src/librustc_mir/borrow_check/nll/type_check/type_op/mod.rs) | 30 | ||||
| -rw-r--r-- | src/librustc/traits/query/type_op/normalize.rs (renamed from src/librustc_mir/borrow_check/nll/type_check/type_op/normalize.rs) | 14 | ||||
| -rw-r--r-- | src/librustc/traits/query/type_op/outlives.rs (renamed from src/librustc_mir/borrow_check/nll/type_check/type_op/outlives.rs) | 14 | ||||
| -rw-r--r-- | src/librustc/traits/query/type_op/predicates.rs (renamed from src/librustc_mir/borrow_check/nll/type_check/type_op/predicates.rs) | 10 | ||||
| -rw-r--r-- | src/librustc/traits/query/type_op/subtype.rs (renamed from src/librustc_mir/borrow_check/nll/type_check/type_op/subtype.rs) | 10 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/type_check/input_output.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/type_check/liveness.rs | 4 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/type_check/mod.rs | 19 |
11 files changed, 61 insertions, 65 deletions
diff --git a/src/librustc/traits/query/mod.rs b/src/librustc/traits/query/mod.rs index 096633ddab2..7181a94acff 100644 --- a/src/librustc/traits/query/mod.rs +++ b/src/librustc/traits/query/mod.rs @@ -22,6 +22,7 @@ pub mod dropck_outlives; pub mod evaluate_obligation; pub mod normalize; pub mod normalize_erasing_regions; +pub mod type_op; pub type CanonicalProjectionGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::ProjectionTy<'tcx>>>; diff --git a/src/librustc_mir/borrow_check/nll/type_check/type_op/custom.rs b/src/librustc/traits/query/type_op/custom.rs index ce17cab8dcb..65b2ab31eba 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/type_op/custom.rs +++ b/src/librustc/traits/query/type_op/custom.rs @@ -8,17 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::infer::{InferCtxt, InferResult}; -use rustc::ty::TyCtxt; +use infer::{InferCtxt, InferResult}; +use ty::TyCtxt; use std::fmt; -crate struct CustomTypeOp<F, G> { +pub struct CustomTypeOp<F, G> { closure: F, description: G, } impl<F, G> CustomTypeOp<F, G> { - crate fn new<'gcx, 'tcx, R>(closure: F, description: G) -> Self + pub fn new<'gcx, 'tcx, R>(closure: F, description: G) -> Self where F: FnOnce(&InferCtxt<'_, 'gcx, 'tcx>) -> InferResult<'tcx, R>, G: Fn() -> String, @@ -32,7 +32,7 @@ impl<F, G> CustomTypeOp<F, G> { impl<'gcx, 'tcx, F, R, G> super::TypeOp<'gcx, 'tcx> for CustomTypeOp<F, G> where - F: FnOnce(&InferCtxt<'_, 'gcx, 'tcx>) -> InferResult<'tcx, R>, + F: for<'a, 'cx> FnOnce(&'a InferCtxt<'cx, 'gcx, 'tcx>) -> InferResult<'tcx, R>, G: Fn() -> String, { type Output = R; diff --git a/src/librustc_mir/borrow_check/nll/type_check/type_op/eq.rs b/src/librustc/traits/query/type_op/eq.rs index ca10f0e8cea..9dad9fa4e0a 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/type_op/eq.rs +++ b/src/librustc/traits/query/type_op/eq.rs @@ -8,21 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::infer::canonical::{CanonicalizedQueryResult, Canonical}; -use rustc::traits::query::NoSolution; -use rustc::traits::{FulfillmentContext, ObligationCause}; -use rustc::ty::{self, ParamEnv, Ty, TyCtxt}; +use infer::canonical::{CanonicalizedQueryResult, Canonical}; +use traits::query::NoSolution; +use traits::{FulfillmentContext, ObligationCause}; +use ty::{self, ParamEnv, Ty, TyCtxt}; use syntax::codemap::DUMMY_SP; #[derive(Copy, Clone, Debug)] -crate struct Eq<'tcx> { +pub struct Eq<'tcx> { param_env: ParamEnv<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>, } impl<'tcx> Eq<'tcx> { - crate fn new(param_env: ParamEnv<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> Self { + pub fn new(param_env: ParamEnv<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> Self { Self { param_env, a, b } } } diff --git a/src/librustc_mir/borrow_check/nll/type_check/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs index 4d9dd915f03..0028aaa4044 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/type_op/mod.rs +++ b/src/librustc/traits/query/type_op/mod.rs @@ -8,25 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::infer::canonical::query_result; -use rustc::infer::canonical::{Canonicalized, CanonicalizedQueryResult, QueryRegionConstraint}; -use rustc::infer::{InferCtxt, InferOk, InferResult}; -use rustc::traits::{ObligationCause, TraitEngine}; -use rustc::ty::error::TypeError; -use rustc::ty::fold::TypeFoldable; -use rustc::ty::{Lift, ParamEnv, TyCtxt}; +use infer::canonical::query_result; +use infer::canonical::{Canonicalized, CanonicalizedQueryResult, QueryRegionConstraint}; +use infer::{InferCtxt, InferOk, InferResult}; +use traits::{ObligationCause, TraitEngine}; +use ty::error::TypeError; +use ty::fold::TypeFoldable; +use ty::{Lift, ParamEnv, TyCtxt}; use std::fmt; use std::rc::Rc; use syntax::codemap::DUMMY_SP; -crate mod custom; -crate mod eq; -crate mod normalize; -crate mod outlives; -crate mod predicates; -crate mod subtype; +pub mod custom; +pub mod eq; +pub mod normalize; +pub mod outlives; +pub mod predicates; +pub mod subtype; -crate trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug { +pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug { type Output; /// Micro-optimization: returns `Ok(x)` if we can trivially @@ -100,7 +100,7 @@ crate trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug { type Lifted<'gcx, T> = <T as Lift<'gcx>>::Lifted; -crate trait QueryTypeOp<'gcx: 'tcx, 'tcx>: TypeFoldable<'tcx> + Lift<'gcx> { +pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: TypeFoldable<'tcx> + Lift<'gcx> { type QueryResult: TypeFoldable<'tcx> + Lift<'gcx>; /// Micro-optimization: returns `Ok(x)` if we can trivially diff --git a/src/librustc_mir/borrow_check/nll/type_check/type_op/normalize.rs b/src/librustc/traits/query/type_op/normalize.rs index 35242a5bc29..a363f6f213c 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/type_op/normalize.rs +++ b/src/librustc/traits/query/type_op/normalize.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::infer::{InferCtxt, InferOk, InferResult}; -use rustc::traits::query::NoSolution; -use rustc::traits::{Normalized, ObligationCause}; -use rustc::ty::fold::TypeFoldable; -use rustc::ty::{ParamEnv, TyCtxt}; +use infer::{InferCtxt, InferOk, InferResult}; +use traits::query::NoSolution; +use traits::{Normalized, ObligationCause}; +use ty::fold::TypeFoldable; +use ty::{ParamEnv, TyCtxt}; use std::fmt; #[derive(Debug)] -crate struct Normalize<'tcx, T> { +pub struct Normalize<'tcx, T> { param_env: ParamEnv<'tcx>, value: T, } @@ -25,7 +25,7 @@ impl<'tcx, T> Normalize<'tcx, T> where T: fmt::Debug + TypeFoldable<'tcx>, { - crate fn new(param_env: ParamEnv<'tcx>, value: T) -> Self { + pub fn new(param_env: ParamEnv<'tcx>, value: T) -> Self { Self { param_env, value } } } diff --git a/src/librustc_mir/borrow_check/nll/type_check/type_op/outlives.rs b/src/librustc/traits/query/type_op/outlives.rs index 655ede4793a..f6c60bcaf38 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/type_op/outlives.rs +++ b/src/librustc/traits/query/type_op/outlives.rs @@ -8,20 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::infer::{InferCtxt, InferResult}; -use rustc::traits::query::dropck_outlives::trivial_dropck_outlives; -use rustc::traits::ObligationCause; -use rustc::ty::subst::Kind; -use rustc::ty::{ParamEnv, Ty, TyCtxt}; +use infer::{InferCtxt, InferResult}; +use traits::query::dropck_outlives::trivial_dropck_outlives; +use traits::ObligationCause; +use ty::subst::Kind; +use ty::{ParamEnv, Ty, TyCtxt}; #[derive(Debug)] -crate struct DropckOutlives<'tcx> { +pub struct DropckOutlives<'tcx> { param_env: ParamEnv<'tcx>, dropped_ty: Ty<'tcx>, } impl<'tcx> DropckOutlives<'tcx> { - crate fn new(param_env: ParamEnv<'tcx>, dropped_ty: Ty<'tcx>) -> Self { + pub fn new(param_env: ParamEnv<'tcx>, dropped_ty: Ty<'tcx>) -> Self { DropckOutlives { param_env, dropped_ty, diff --git a/src/librustc_mir/borrow_check/nll/type_check/type_op/predicates.rs b/src/librustc/traits/query/type_op/predicates.rs index 18128d2234e..d729ce1e0eb 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/type_op/predicates.rs +++ b/src/librustc/traits/query/type_op/predicates.rs @@ -8,17 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::infer::{InferCtxt, InferOk, InferResult}; -use rustc::traits::{Obligation, ObligationCause, PredicateObligation}; -use rustc::ty::{ParamEnv, Predicate, TyCtxt}; +use infer::{InferCtxt, InferOk, InferResult}; +use traits::{Obligation, ObligationCause, PredicateObligation}; +use ty::{ParamEnv, Predicate, TyCtxt}; #[derive(Debug)] -crate struct ProvePredicates<'tcx> { +pub struct ProvePredicates<'tcx> { obligations: Vec<PredicateObligation<'tcx>>, } impl<'tcx> ProvePredicates<'tcx> { - crate fn new( + pub fn new( param_env: ParamEnv<'tcx>, predicates: impl IntoIterator<Item = Predicate<'tcx>>, ) -> Self { diff --git a/src/librustc_mir/borrow_check/nll/type_check/type_op/subtype.rs b/src/librustc/traits/query/type_op/subtype.rs index 83cc3c7d09b..e9adabc8b08 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/type_op/subtype.rs +++ b/src/librustc/traits/query/type_op/subtype.rs @@ -8,19 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::infer::{InferCtxt, InferResult}; -use rustc::traits::ObligationCause; -use rustc::ty::{ParamEnv, Ty, TyCtxt}; +use infer::{InferCtxt, InferResult}; +use traits::ObligationCause; +use ty::{ParamEnv, Ty, TyCtxt}; #[derive(Debug)] -crate struct Subtype<'tcx> { +pub struct Subtype<'tcx> { param_env: ParamEnv<'tcx>, sub: Ty<'tcx>, sup: Ty<'tcx>, } impl<'tcx> Subtype<'tcx> { - crate fn new(param_env: ParamEnv<'tcx>, sub: Ty<'tcx>, sup: Ty<'tcx>) -> Self { + pub fn new(param_env: ParamEnv<'tcx>, sub: Ty<'tcx>, sup: Ty<'tcx>) -> Self { Self { param_env, sub, diff --git a/src/librustc_mir/borrow_check/nll/type_check/input_output.rs b/src/librustc_mir/borrow_check/nll/type_check/input_output.rs index a127128818e..770a0614811 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/input_output.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/input_output.rs @@ -18,12 +18,12 @@ //! contain revealed `impl Trait` values). use borrow_check::nll::renumber; -use borrow_check::nll::type_check::type_op::custom::CustomTypeOp; use borrow_check::nll::universal_regions::UniversalRegions; use rustc::hir::def_id::DefId; use rustc::infer::InferOk; use rustc::mir::visit::TyContext; use rustc::mir::*; +use rustc::traits::query::type_op::custom::CustomTypeOp; use rustc::traits::{ObligationCause, PredicateObligations}; use rustc::ty::subst::Subst; use rustc::ty::Ty; diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs index 78026993091..b6cdbfa6181 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs @@ -9,8 +9,6 @@ // except according to those terms. use borrow_check::nll::region_infer::Cause; -use borrow_check::nll::type_check::type_op::TypeOp; -use borrow_check::nll::type_check::type_op::outlives::DropckOutlives; use borrow_check::nll::type_check::AtLocation; use dataflow::move_paths::{HasMoveData, MoveData}; use dataflow::MaybeInitializedPlaces; @@ -18,6 +16,8 @@ use dataflow::{FlowAtLocation, FlowsAtLocation}; use rustc::infer::canonical::QueryRegionConstraint; use rustc::mir::Local; use rustc::mir::{BasicBlock, Location, Mir}; +use rustc::traits::query::type_op::outlives::DropckOutlives; +use rustc::traits::query::type_op::TypeOp; use rustc::ty::subst::Kind; use rustc::ty::{Ty, TypeFoldable}; use rustc_data_structures::fx::FxHashMap; diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 4a507300f7c..865ee66cccf 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -27,6 +27,7 @@ use rustc::mir::interpret::EvalErrorKind::BoundsCheck; use rustc::mir::tcx::PlaceTy; use rustc::mir::visit::{PlaceContext, Visitor}; use rustc::mir::*; +use rustc::traits::query::type_op; use rustc::traits::ObligationCause; use rustc::ty::error::TypeError; use rustc::ty::fold::TypeFoldable; @@ -66,7 +67,6 @@ macro_rules! span_mirbug_and_err { mod constraint_conversion; mod input_output; mod liveness; -mod type_op; /// Type checks the given `mir` in the context of the inference /// context `infcx`. Returns any region constraints that have yet to @@ -776,7 +776,10 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { locations: Locations, ) -> UnitResult<'tcx> { let param_env = self.param_env; - self.fully_perform_op(locations, type_op::subtype::Subtype::new(param_env, sub, sup)) + self.fully_perform_op( + locations, + type_op::subtype::Subtype::new(param_env, sub, sup), + ) } fn eq_types(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, locations: Locations) -> UnitResult<'tcx> { @@ -1623,16 +1626,8 @@ impl MirPass for TypeckMir { } let param_env = tcx.param_env(def_id); tcx.infer_ctxt().enter(|infcx| { - let _ = type_check_internal( - &infcx, - def_id, - param_env, - mir, - &[], - None, - None, - &mut |_| (), - ); + let _ = + type_check_internal(&infcx, def_id, param_env, mir, &[], None, None, &mut |_| ()); // For verification purposes, we just ignore the resulting // region constraint sets. Not our problem. =) |
