From caa10c3bde60ce0d9b5401771c443bff51d2a8e2 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sun, 6 Sep 2015 18:32:34 +0300 Subject: [PATCH] move middle::ty and related modules to middle/ty/ --- src/librustc/lib.rs | 8 ------ src/librustc/middle/astencode.rs | 2 +- src/librustc/middle/check_const.rs | 2 +- src/librustc/middle/free_region.rs | 2 +- src/librustc/middle/implicator.rs | 2 +- src/librustc/middle/infer/bivariate.rs | 2 +- src/librustc/middle/infer/combine.rs | 19 +++++++------ src/librustc/middle/infer/equate.rs | 2 +- src/librustc/middle/infer/freshen.rs | 7 +++-- src/librustc/middle/infer/glb.rs | 2 +- .../middle/infer/higher_ranked/mod.rs | 12 ++++----- src/librustc/middle/infer/lattice.rs | 2 +- src/librustc/middle/infer/lub.rs | 3 +-- src/librustc/middle/infer/mod.rs | 12 ++++----- .../middle/infer/region_inference/mod.rs | 2 +- src/librustc/middle/infer/resolve.rs | 10 +++---- src/librustc/middle/infer/sub.rs | 2 +- src/librustc/middle/subst.rs | 8 +++--- src/librustc/middle/traits/error_reporting.rs | 2 +- src/librustc/middle/traits/fulfill.rs | 5 ++-- src/librustc/middle/traits/mod.rs | 2 +- src/librustc/middle/traits/project.rs | 4 +-- src/librustc/middle/traits/select.rs | 20 +++++++------- .../middle/{ty_match.rs => ty/_match.rs} | 6 ++--- src/librustc/middle/{ => ty}/cast.rs | 0 src/librustc/middle/{ => ty}/fast_reject.rs | 0 .../middle/{ty_fold.rs => ty/fold.rs} | 0 src/librustc/middle/{ty.rs => ty/mod.rs} | 27 ++++++++++++------- src/librustc/middle/{ => ty}/outlives.rs | 0 .../middle/{ty_relate/mod.rs => ty/relate.rs} | 2 +- .../middle/{ty_walk.rs => ty/walk.rs} | 0 src/librustc/middle/{ => ty}/wf.rs | 3 +-- src/librustc/util/ppaux.rs | 6 ++--- src/librustc_driver/test.rs | 2 +- src/librustc_trans/trans/common.rs | 9 +++---- src/librustc_trans/trans/consts.rs | 2 +- src/librustc_trans/trans/expr.rs | 6 ++--- src/librustc_trans/trans/monomorphize.rs | 2 +- src/librustc_typeck/astconv.rs | 11 ++++---- src/librustc_typeck/check/assoc.rs | 2 +- src/librustc_typeck/check/cast.rs | 6 ++--- src/librustc_typeck/check/coercion.rs | 2 +- src/librustc_typeck/check/intrinsic.rs | 2 +- src/librustc_typeck/check/method/confirm.rs | 2 +- src/librustc_typeck/check/method/probe.rs | 11 ++++---- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/check/regionck.rs | 21 +++++++-------- src/librustc_typeck/check/wf.rs | 2 +- src/librustc_typeck/check/wfcheck.rs | 23 ++++++++-------- src/librustc_typeck/check/writeback.rs | 2 +- src/librustc_typeck/collect.rs | 4 +-- src/librustc_typeck/rscope.rs | 7 +++-- 52 files changed, 140 insertions(+), 154 deletions(-) rename src/librustc/middle/{ty_match.rs => ty/_match.rs} (94%) rename src/librustc/middle/{ => ty}/cast.rs (100%) rename src/librustc/middle/{ => ty}/fast_reject.rs (100%) rename src/librustc/middle/{ty_fold.rs => ty/fold.rs} (100%) rename src/librustc/middle/{ty.rs => ty/mod.rs} (99%) rename src/librustc/middle/{ => ty}/outlives.rs (100%) rename src/librustc/middle/{ty_relate/mod.rs => ty/relate.rs} (99%) rename src/librustc/middle/{ty_walk.rs => ty/walk.rs} (100%) rename src/librustc/middle/{ => ty}/wf.rs (99%) diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index b11bf6f80fb..cfeab976e24 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -107,7 +107,6 @@ pub mod front { pub mod middle { pub mod astconv_util; pub mod astencode; - pub mod cast; pub mod cfg; pub mod check_const; pub mod check_static_recursion; @@ -124,7 +123,6 @@ pub mod middle { pub mod effect; pub mod entry; pub mod expr_use_visitor; - pub mod fast_reject; pub mod free_region; pub mod intrinsicck; pub mod infer; @@ -132,7 +130,6 @@ pub mod middle { pub mod lang_items; pub mod liveness; pub mod mem_categorization; - pub mod outlives; pub mod pat_util; pub mod privacy; pub mod reachable; @@ -143,11 +140,6 @@ pub mod middle { pub mod subst; pub mod traits; pub mod ty; - pub mod ty_fold; - pub mod ty_match; - pub mod ty_relate; - pub mod ty_walk; - pub mod wf; pub mod weak_lang_items; } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index abf2d5f3625..ac2dd545982 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -27,7 +27,7 @@ use metadata::tydecode; use metadata::tydecode::{DefIdSource, NominalType, TypeWithId}; use metadata::tydecode::{RegionParameter, ClosureSource}; use metadata::tyencode; -use middle::cast; +use middle::ty::cast; use middle::check_const::ConstQualif; use middle::def; use middle::def_id::{DefId, LOCAL_CRATE}; diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 37e14428176..48c8cca76b0 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -24,7 +24,7 @@ // - It's not possible to take the address of a static item with unsafe interior. This is enforced // by borrowck::gather_loans -use middle::cast::{CastKind}; +use middle::ty::cast::{CastKind}; use middle::const_eval; use middle::const_eval::EvalHint::ExprTypeChecked; use middle::def; diff --git a/src/librustc/middle/free_region.rs b/src/librustc/middle/free_region.rs index c39c3fd3027..2e9e5fafb1d 100644 --- a/src/librustc/middle/free_region.rs +++ b/src/librustc/middle/free_region.rs @@ -16,7 +16,7 @@ //! region outlives another and so forth. use middle::ty::{self, FreeRegion, Region}; -use middle::wf::ImpliedBound; +use middle::ty::wf::ImpliedBound; use rustc_data_structures::transitive_relation::TransitiveRelation; #[derive(Clone)] diff --git a/src/librustc/middle/implicator.rs b/src/librustc/middle/implicator.rs index b1a4e0270c2..9f33c4df03d 100644 --- a/src/librustc/middle/implicator.rs +++ b/src/librustc/middle/implicator.rs @@ -15,7 +15,7 @@ use middle::infer::{InferCtxt, GenericKind}; use middle::subst::Substs; use middle::traits; use middle::ty::{self, RegionEscape, ToPredicate, Ty}; -use middle::ty_fold::{TypeFoldable, TypeFolder}; +use middle::ty::fold::{TypeFoldable, TypeFolder}; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc/middle/infer/bivariate.rs b/src/librustc/middle/infer/bivariate.rs index d2268894b20..2d9432b75e7 100644 --- a/src/librustc/middle/infer/bivariate.rs +++ b/src/librustc/middle/infer/bivariate.rs @@ -30,7 +30,7 @@ use super::type_variable::{BiTo}; use middle::ty::{self, Ty}; use middle::ty::TyVar; -use middle::ty_relate::{Relate, RelateResult, TypeRelation}; +use middle::ty::relate::{Relate, RelateResult, TypeRelation}; pub struct Bivariate<'a, 'tcx: 'a> { fields: CombineFields<'a, 'tcx> diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index 00edd054aa5..3a29fdfae23 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -44,9 +44,8 @@ use super::type_variable::{RelationDir, BiTo, EqTo, SubtypeOf, SupertypeOf}; use middle::ty::{TyVar}; use middle::ty::{IntType, UintType}; use middle::ty::{self, Ty, TypeError}; -use middle::ty_fold; -use middle::ty_fold::{TypeFolder, TypeFoldable}; -use middle::ty_relate::{self, Relate, RelateResult, TypeRelation}; +use middle::ty::fold::{TypeFolder, TypeFoldable}; +use middle::ty::relate::{Relate, RelateResult, TypeRelation}; use syntax::codemap::Span; use rustc_front::hir; @@ -56,7 +55,7 @@ pub struct CombineFields<'a, 'tcx: 'a> { pub infcx: &'a InferCtxt<'a, 'tcx>, pub a_is_expected: bool, pub trace: TypeTrace<'tcx>, - pub cause: Option, + pub cause: Option, } pub fn super_combine_tys<'a,'tcx:'a,R>(infcx: &InferCtxt<'a, 'tcx>, @@ -108,12 +107,12 @@ pub fn super_combine_tys<'a,'tcx:'a,R>(infcx: &InferCtxt<'a, 'tcx>, // All other cases of inference are errors (&ty::TyInfer(_), _) | (_, &ty::TyInfer(_)) => { - Err(TypeError::Sorts(ty_relate::expected_found(relation, &a, &b))) + Err(TypeError::Sorts(ty::relate::expected_found(relation, &a, &b))) } _ => { - ty_relate::super_relate_tys(relation, a, b) + ty::relate::super_relate_tys(relation, a, b) } } } @@ -293,7 +292,7 @@ struct Generalizer<'cx, 'tcx:'cx> { cycle_detected: bool, } -impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> { +impl<'cx, 'tcx> ty::fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> { fn tcx(&self) -> &ty::ctxt<'tcx> { self.infcx.tcx } @@ -319,7 +318,7 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> { } } _ => { - ty_fold::super_fold_ty(self, t) + ty::fold::super_fold_ty(self, t) } } } @@ -384,7 +383,7 @@ fn int_unification_error<'tcx>(a_is_expected: bool, v: (ty::IntVarValue, ty::Int -> ty::TypeError<'tcx> { let (a, b) = v; - TypeError::IntMismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b)) + TypeError::IntMismatch(ty::relate::expected_found_bool(a_is_expected, &a, &b)) } fn float_unification_error<'tcx>(a_is_expected: bool, @@ -392,5 +391,5 @@ fn float_unification_error<'tcx>(a_is_expected: bool, -> ty::TypeError<'tcx> { let (a, b) = v; - TypeError::FloatMismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b)) + TypeError::FloatMismatch(ty::relate::expected_found_bool(a_is_expected, &a, &b)) } diff --git a/src/librustc/middle/infer/equate.rs b/src/librustc/middle/infer/equate.rs index cbbf73d9420..07ce4688c06 100644 --- a/src/librustc/middle/infer/equate.rs +++ b/src/librustc/middle/infer/equate.rs @@ -15,7 +15,7 @@ use super::type_variable::{EqTo}; use middle::ty::{self, Ty}; use middle::ty::TyVar; -use middle::ty_relate::{Relate, RelateResult, TypeRelation}; +use middle::ty::relate::{Relate, RelateResult, TypeRelation}; pub struct Equate<'a, 'tcx: 'a> { fields: CombineFields<'a, 'tcx> diff --git a/src/librustc/middle/infer/freshen.rs b/src/librustc/middle/infer/freshen.rs index c72a4fc0db3..0bae3cd2d86 100644 --- a/src/librustc/middle/infer/freshen.rs +++ b/src/librustc/middle/infer/freshen.rs @@ -31,9 +31,8 @@ //! inferencer knows "so far". use middle::ty::{self, Ty, HasTypeFlags}; -use middle::ty_fold; -use middle::ty_fold::TypeFoldable; -use middle::ty_fold::TypeFolder; +use middle::ty::fold::TypeFoldable; +use middle::ty::fold::TypeFolder; use std::collections::hash_map::{self, Entry}; use super::InferCtxt; @@ -170,7 +169,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> { ty::TyTuple(..) | ty::TyProjection(..) | ty::TyParam(..) => { - ty_fold::super_fold_ty(self, t) + ty::fold::super_fold_ty(self, t) } } } diff --git a/src/librustc/middle/infer/glb.rs b/src/librustc/middle/infer/glb.rs index d6b03266b1f..0035f31e8db 100644 --- a/src/librustc/middle/infer/glb.rs +++ b/src/librustc/middle/infer/glb.rs @@ -15,7 +15,7 @@ use super::lattice::{self, LatticeDir}; use super::Subtype; use middle::ty::{self, Ty}; -use middle::ty_relate::{Relate, RelateResult, TypeRelation}; +use middle::ty::relate::{Relate, RelateResult, TypeRelation}; /// "Greatest lower bound" (common subtype) pub struct Glb<'a, 'tcx: 'a> { diff --git a/src/librustc/middle/infer/higher_ranked/mod.rs b/src/librustc/middle/infer/higher_ranked/mod.rs index 0c539a5d0e0..10a31f0e657 100644 --- a/src/librustc/middle/infer/higher_ranked/mod.rs +++ b/src/librustc/middle/infer/higher_ranked/mod.rs @@ -15,8 +15,8 @@ use super::{CombinedSnapshot, InferCtxt, HigherRankedType, SkolemizationMap}; use super::combine::CombineFields; use middle::ty::{self, TypeError, Binder}; -use middle::ty_fold::{self, TypeFoldable}; -use middle::ty_relate::{Relate, RelateResult, TypeRelation}; +use middle::ty::fold::TypeFoldable; +use middle::ty::relate::{Relate, RelateResult, TypeRelation}; use syntax::codemap::Span; use util::nodemap::{FnvHashMap, FnvHashSet}; @@ -358,7 +358,7 @@ fn fold_regions_in<'tcx, T, F>(tcx: &ty::ctxt<'tcx>, where T: TypeFoldable<'tcx>, F: FnMut(ty::Region, ty::DebruijnIndex) -> ty::Region, { - ty_fold::fold_regions(tcx, unbound_value, &mut false, |region, current_depth| { + ty::fold::fold_regions(tcx, unbound_value, &mut false, |region, current_depth| { // we should only be encountering "escaping" late-bound regions here, // because the ones at the current level should have been replaced // with fresh variables @@ -438,7 +438,7 @@ impl<'a,'tcx> InferCtxtExt for InferCtxt<'a,'tcx> { let mut escaping_region_vars = FnvHashSet(); for ty in &escaping_types { - ty_fold::collect_regions(self.tcx, ty, &mut escaping_region_vars); + ty::fold::collect_regions(self.tcx, ty, &mut escaping_region_vars); } region_vars.retain(|®ion_vid| { @@ -468,7 +468,7 @@ pub fn skolemize_late_bound_regions<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, * details. */ - let (result, map) = ty_fold::replace_late_bound_regions(infcx.tcx, binder, |br| { + let (result, map) = ty::fold::replace_late_bound_regions(infcx.tcx, binder, |br| { infcx.region_vars.new_skolemized(br, &snapshot.region_vars_snapshot) }); @@ -590,7 +590,7 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, // binder is that we encountered in `value`. The caller is // responsible for ensuring that (a) `value` contains at least one // binder and (b) that binder is the one we want to use. - let result = ty_fold::fold_regions(infcx.tcx, &value, &mut false, |r, current_depth| { + let result = ty::fold::fold_regions(infcx.tcx, &value, &mut false, |r, current_depth| { match inv_skol_map.get(&r) { None => r, Some(br) => { diff --git a/src/librustc/middle/infer/lattice.rs b/src/librustc/middle/infer/lattice.rs index 7b34fda2406..2a560ec8a1d 100644 --- a/src/librustc/middle/infer/lattice.rs +++ b/src/librustc/middle/infer/lattice.rs @@ -34,7 +34,7 @@ use super::InferCtxt; use middle::ty::TyVar; use middle::ty::{self, Ty}; -use middle::ty_relate::{RelateResult, TypeRelation}; +use middle::ty::relate::{RelateResult, TypeRelation}; pub trait LatticeDir<'f,'tcx> : TypeRelation<'f,'tcx> { fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>; diff --git a/src/librustc/middle/infer/lub.rs b/src/librustc/middle/infer/lub.rs index 9d993ead5ca..238dad65ef0 100644 --- a/src/librustc/middle/infer/lub.rs +++ b/src/librustc/middle/infer/lub.rs @@ -15,7 +15,7 @@ use super::lattice::{self, LatticeDir}; use super::Subtype; use middle::ty::{self, Ty}; -use middle::ty_relate::{Relate, RelateResult, TypeRelation}; +use middle::ty::relate::{Relate, RelateResult, TypeRelation}; /// "Least upper bound" (common supertype) pub struct Lub<'a, 'tcx: 'a> { @@ -83,4 +83,3 @@ impl<'a, 'tcx> LatticeDir<'a,'tcx> for Lub<'a, 'tcx> { Ok(()) } } - diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index 4ef96c0f3b4..5b94f5311fd 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -32,8 +32,8 @@ use middle::traits::{self, FulfillmentContext, Normalized, SelectionContext, ObligationCause}; use middle::ty::{TyVid, IntVid, FloatVid, RegionVid, UnconstrainedNumeric}; use middle::ty::{self, Ty, TypeError, HasTypeFlags}; -use middle::ty_fold::{self, TypeFolder, TypeFoldable}; -use middle::ty_relate::{Relate, RelateResult, TypeRelation}; +use middle::ty::fold::{TypeFolder, TypeFoldable}; +use middle::ty::relate::{Relate, RelateResult, TypeRelation}; use rustc_data_structures::unify::{self, UnificationTable}; use std::cell::{RefCell, Ref}; use std::fmt; @@ -583,7 +583,7 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, /// Returns an equivalent value with all free regions removed (note /// that late-bound regions remain, because they are important for /// subtyping, but they are anonymized and normalized as well). This -/// is a stronger, caching version of `ty_fold::erase_regions`. +/// is a stronger, caching version of `ty::fold::erase_regions`. pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T where T : TypeFoldable<'tcx> { @@ -603,7 +603,7 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T Some(u) => return u } - let t_norm = ty_fold::super_fold_ty(self, ty); + let t_norm = ty::fold::super_fold_ty(self, ty); self.tcx().normalized_cache.borrow_mut().insert(ty, t_norm); return t_norm; } @@ -612,7 +612,7 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T where T : TypeFoldable<'tcx> { let u = self.tcx().anonymize_late_bound_regions(t); - ty_fold::super_fold_binder(self, &u) + ty::fold::super_fold_binder(self, &u) } fn fold_region(&mut self, r: ty::Region) -> ty::Region { @@ -1406,7 +1406,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { -> (T, FnvHashMap) where T : TypeFoldable<'tcx> { - ty_fold::replace_late_bound_regions( + ty::fold::replace_late_bound_regions( self.tcx, value, |br| self.next_region_var(LateBoundRegion(span, br, lbrct))) diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index d81f8e0ae90..a62fd8890ba 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -27,7 +27,7 @@ use middle::ty::{self, Ty, TypeError}; use middle::ty::{BoundRegion, FreeRegion, Region, RegionVid}; use middle::ty::{ReEmpty, ReStatic, ReFree, ReEarlyBound}; use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh}; -use middle::ty_relate::RelateResult; +use middle::ty::relate::RelateResult; use util::common::indenter; use util::nodemap::{FnvHashMap, FnvHashSet}; diff --git a/src/librustc/middle/infer/resolve.rs b/src/librustc/middle/infer/resolve.rs index 9cc9f148ce1..4bcceade775 100644 --- a/src/librustc/middle/infer/resolve.rs +++ b/src/librustc/middle/infer/resolve.rs @@ -10,7 +10,7 @@ use super::{InferCtxt, FixupError, FixupResult}; use middle::ty::{self, Ty, HasTypeFlags}; -use middle::ty_fold::{self, TypeFoldable}; +use middle::ty::fold::{TypeFoldable}; /////////////////////////////////////////////////////////////////////////// // OPPORTUNISTIC TYPE RESOLVER @@ -30,7 +30,7 @@ impl<'a, 'tcx> OpportunisticTypeResolver<'a, 'tcx> { } } -impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for OpportunisticTypeResolver<'a, 'tcx> { +impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeResolver<'a, 'tcx> { fn tcx(&self) -> &ty::ctxt<'tcx> { self.infcx.tcx } @@ -40,7 +40,7 @@ impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for OpportunisticTypeResolver<'a, 'tcx> t // micro-optimize -- if there is nothing in this type that this fold affects... } else { let t0 = self.infcx.shallow_resolve(t); - ty_fold::super_fold_ty(self, t0) + ty::fold::super_fold_ty(self, t0) } } } @@ -69,7 +69,7 @@ struct FullTypeResolver<'a, 'tcx:'a> { err: Option, } -impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> { +impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> { fn tcx(&self) -> &ty::ctxt<'tcx> { self.infcx.tcx } @@ -98,7 +98,7 @@ impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> { t)); } _ => { - ty_fold::super_fold_ty(self, t) + ty::fold::super_fold_ty(self, t) } } } diff --git a/src/librustc/middle/infer/sub.rs b/src/librustc/middle/infer/sub.rs index 4d76d613392..155f5f44002 100644 --- a/src/librustc/middle/infer/sub.rs +++ b/src/librustc/middle/infer/sub.rs @@ -15,7 +15,7 @@ use super::type_variable::{SubtypeOf, SupertypeOf}; use middle::ty::{self, Ty}; use middle::ty::TyVar; -use middle::ty_relate::{Cause, Relate, RelateResult, TypeRelation}; +use middle::ty::relate::{Cause, Relate, RelateResult, TypeRelation}; use std::mem; /// "Greatest lower bound" (common subtype) diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 7d8a20c42e3..c44891de0a0 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -14,7 +14,7 @@ pub use self::ParamSpace::*; pub use self::RegionSubsts::*; use middle::ty::{self, Ty, HasTypeFlags, RegionEscape}; -use middle::ty_fold::{self, TypeFoldable, TypeFolder}; +use middle::ty::fold::{TypeFoldable, TypeFolder}; use std::fmt; use std::iter::IntoIterator; @@ -643,7 +643,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> { self.ty_for_param(p, t) } _ => { - ty_fold::super_fold_ty(self, t) + ty::fold::super_fold_ty(self, t) } }; @@ -731,13 +731,13 @@ impl<'a,'tcx> SubstFolder<'a,'tcx> { return ty; } - let result = ty_fold::shift_regions(self.tcx(), self.region_binders_passed, &ty); + let result = ty::fold::shift_regions(self.tcx(), self.region_binders_passed, &ty); debug!("shift_regions: shifted result = {:?}", result); result } fn shift_region_through_binders(&self, region: ty::Region) -> ty::Region { - ty_fold::shift_region(region, self.region_binders_passed) + ty::fold::shift_region(region, self.region_binders_passed) } } diff --git a/src/librustc/middle/traits/error_reporting.rs b/src/librustc/middle/traits/error_reporting.rs index a3a903c3393..5322a571ed9 100644 --- a/src/librustc/middle/traits/error_reporting.rs +++ b/src/librustc/middle/traits/error_reporting.rs @@ -27,7 +27,7 @@ use fmt_macros::{Parser, Piece, Position}; use middle::def_id::DefId; use middle::infer::InferCtxt; use middle::ty::{self, ToPredicate, HasTypeFlags, ToPolyTraitRef, TraitRef, Ty}; -use middle::ty_fold::TypeFoldable; +use middle::ty::fold::TypeFoldable; use std::collections::HashMap; use std::fmt; use syntax::codemap::Span; diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/middle/traits/fulfill.rs index 99e12b7428d..6271dd21166 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/middle/traits/fulfill.rs @@ -10,7 +10,6 @@ use middle::infer::InferCtxt; use middle::ty::{self, RegionEscape, Ty, HasTypeFlags}; -use middle::wf; use std::fmt; use syntax::ast; @@ -496,8 +495,8 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, ObligationCauseCode::RFC1214(_) => true, _ => false, }; - match wf::obligations(selcx.infcx(), obligation.cause.body_id, - ty, obligation.cause.span, rfc1214) { + match ty::wf::obligations(selcx.infcx(), obligation.cause.body_id, + ty, obligation.cause.span, rfc1214) { Some(obligations) => { new_obligations.extend(obligations); true diff --git a/src/librustc/middle/traits/mod.rs b/src/librustc/middle/traits/mod.rs index 667cad8fc88..6c581a701a2 100644 --- a/src/librustc/middle/traits/mod.rs +++ b/src/librustc/middle/traits/mod.rs @@ -19,7 +19,7 @@ use middle::def_id::DefId; use middle::free_region::FreeRegionMap; use middle::subst; use middle::ty::{self, HasTypeFlags, Ty}; -use middle::ty_fold::TypeFoldable; +use middle::ty::fold::TypeFoldable; use middle::infer::{self, fixup_err_to_string, InferCtxt}; use std::rc::Rc; use syntax::ast; diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs index cacefbb1a85..0d320989cbc 100644 --- a/src/librustc/middle/traits/project.rs +++ b/src/librustc/middle/traits/project.rs @@ -24,7 +24,7 @@ use super::util; use middle::infer; use middle::subst::Subst; use middle::ty::{self, ToPredicate, RegionEscape, HasTypeFlags, ToPolyTraitRef, Ty}; -use middle::ty_fold::{self, TypeFoldable, TypeFolder}; +use middle::ty::fold::{TypeFoldable, TypeFolder}; use syntax::parse::token; use util::common::FN_OUTPUT_NAME; @@ -265,7 +265,7 @@ impl<'a,'b,'tcx> TypeFolder<'tcx> for AssociatedTypeNormalizer<'a,'b,'tcx> { // normalize it when we instantiate those bound regions (which // should occur eventually). - let ty = ty_fold::super_fold_ty(self, ty); + let ty = ty::fold::super_fold_ty(self, ty); match ty.sty { ty::TyProjection(ref data) if !data.has_escaping_regions() => { // (*) diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index ccdb271d43f..6f422018c13 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -38,15 +38,13 @@ use super::object_safety; use super::util; use middle::def_id::{DefId, LOCAL_CRATE}; -use middle::fast_reject; -use middle::subst::{Subst, Substs, TypeSpace}; -use middle::ty::{self, ToPredicate, RegionEscape, ToPolyTraitRef, Ty, HasTypeFlags}; use middle::infer; use middle::infer::{InferCtxt, TypeFreshener}; -use middle::ty_fold::TypeFoldable; -use middle::ty_match; -use middle::ty_relate::TypeRelation; -use middle::wf; +use middle::subst::{Subst, Substs, TypeSpace}; +use middle::ty::{self, ToPredicate, RegionEscape, ToPolyTraitRef, Ty, HasTypeFlags}; +use middle::ty::fast_reject; +use middle::ty::fold::TypeFoldable; +use middle::ty::relate::TypeRelation; use std::cell::RefCell; use std::fmt; @@ -471,9 +469,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } ty::Predicate::WellFormed(ty) => { - match wf::obligations(self.infcx, obligation.cause.body_id, - ty, obligation.cause.span, - obligation.cause.code.is_rfc1214()) { + match ty::wf::obligations(self.infcx, obligation.cause.body_id, + ty, obligation.cause.span, + obligation.cause.code.is_rfc1214()) { Some(obligations) => self.evaluate_predicates_recursively(previous_stack, obligations.iter()), None => @@ -2824,7 +2822,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { current: &ty::PolyTraitRef<'tcx>) -> bool { - let mut matcher = ty_match::Match::new(self.tcx()); + let mut matcher = ty::_match::Match::new(self.tcx()); matcher.relate(previous, current).is_ok() } diff --git a/src/librustc/middle/ty_match.rs b/src/librustc/middle/ty/_match.rs similarity index 94% rename from src/librustc/middle/ty_match.rs rename to src/librustc/middle/ty/_match.rs index 4aa0e553a7a..2ebb23369bd 100644 --- a/src/librustc/middle/ty_match.rs +++ b/src/librustc/middle/ty/_match.rs @@ -9,7 +9,7 @@ // except according to those terms. use middle::ty::{self, Ty}; -use middle::ty_relate::{self, Relate, TypeRelation, RelateResult}; +use middle::ty::relate::{self, Relate, TypeRelation, RelateResult}; /// A type "A" *matches* "B" if the fresh types in B could be /// substituted with values so as to make it equal to A. Matching is @@ -73,7 +73,7 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx> { (&ty::TyInfer(_), _) | (_, &ty::TyInfer(_)) => { - Err(ty::TypeError::Sorts(ty_relate::expected_found(self, &a, &b))) + Err(ty::TypeError::Sorts(relate::expected_found(self, &a, &b))) } (&ty::TyError, _) | (_, &ty::TyError) => { @@ -81,7 +81,7 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx> { } _ => { - ty_relate::super_relate_tys(self, a, b) + relate::super_relate_tys(self, a, b) } } } diff --git a/src/librustc/middle/cast.rs b/src/librustc/middle/ty/cast.rs similarity index 100% rename from src/librustc/middle/cast.rs rename to src/librustc/middle/ty/cast.rs diff --git a/src/librustc/middle/fast_reject.rs b/src/librustc/middle/ty/fast_reject.rs similarity index 100% rename from src/librustc/middle/fast_reject.rs rename to src/librustc/middle/ty/fast_reject.rs diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty/fold.rs similarity index 100% rename from src/librustc/middle/ty_fold.rs rename to src/librustc/middle/ty/fold.rs diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty/mod.rs similarity index 99% rename from src/librustc/middle/ty.rs rename to src/librustc/middle/ty/mod.rs index 7f61526a8f9..21f068ca887 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty/mod.rs @@ -43,13 +43,11 @@ use front::map as ast_map; use front::map::LinkedPath; use metadata::csearch; use middle; -use middle::cast; use middle::check_const; use middle::const_eval::{self, ConstVal, ErrKind}; use middle::const_eval::EvalHint::UncheckedExprHint; use middle::def::{self, DefMap, ExportMap}; use middle::def_id::{DefId, LOCAL_CRATE}; -use middle::fast_reject; use middle::free_region::FreeRegionMap; use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem}; use middle::region; @@ -62,8 +60,8 @@ use middle::stability; use middle::subst::{self, ParamSpace, Subst, Substs, VecPerParamSpace}; use middle::traits; use middle::ty; -use middle::ty_fold::{self, TypeFoldable, TypeFolder}; -use middle::ty_walk::{self, TypeWalker}; +use middle::ty::fold::{TypeFoldable, TypeFolder}; +use middle::ty::walk::{TypeWalker}; use util::common::{memoized, ErrorReported}; use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet}; use util::nodemap::FnvHashMap; @@ -96,6 +94,15 @@ use rustc_front::hir::{ItemImpl, ItemTrait}; use rustc_front::hir::{MutImmutable, MutMutable, Visibility}; use rustc_front::attr::{self, AttrMetaMethods, SignedInt, UnsignedInt}; +pub mod cast; +pub mod fast_reject; +pub mod fold; +pub mod _match; +pub mod outlives; +pub mod relate; +pub mod walk; +pub mod wf; + pub type Disr = u64; pub const INITIAL_DISCRIMINANT_VALUE: Disr = 0; @@ -4252,7 +4259,7 @@ impl<'tcx> TyS<'tcx> { /// `Foo, u32>` yields the sequence `[Bar, u32]` /// (but not `i32`, like `walk`). pub fn walk_shallow(&'tcx self) -> IntoIter> { - ty_walk::walk_shallow(self) + walk::walk_shallow(self) } pub fn as_opt_param_ty(&self) -> Option { @@ -6879,7 +6886,7 @@ impl<'tcx> ctxt<'tcx> { -> T where T : TypeFoldable<'tcx> { - ty_fold::replace_late_bound_regions( + fold::replace_late_bound_regions( self, value, |br| ty::ReFree(ty::FreeRegion{scope: all_outlive_scope, bound_region: br})).0 } @@ -6891,8 +6898,8 @@ impl<'tcx> ctxt<'tcx> { where T: TypeFoldable<'tcx> { let bound0_value = bound2_value.skip_binder().skip_binder(); - let value = ty_fold::fold_regions(self, bound0_value, &mut false, - |region, current_depth| { + let value = fold::fold_regions(self, bound0_value, &mut false, + |region, current_depth| { match region { ty::ReLateBound(debruijn, br) if debruijn.depth >= current_depth => { // should be true if no escaping regions from bound2_value @@ -6922,7 +6929,7 @@ impl<'tcx> ctxt<'tcx> { pub fn erase_late_bound_regions(&self, value: &Binder) -> T where T : TypeFoldable<'tcx> { - ty_fold::replace_late_bound_regions(self, value, |_| ty::ReStatic).0 + fold::replace_late_bound_regions(self, value, |_| ty::ReStatic).0 } /// Rewrite any late-bound regions so that they are anonymous. Region numbers are @@ -6937,7 +6944,7 @@ impl<'tcx> ctxt<'tcx> { where T : TypeFoldable<'tcx>, { let mut counter = 0; - ty::Binder(ty_fold::replace_late_bound_regions(self, sig, |_| { + ty::Binder(fold::replace_late_bound_regions(self, sig, |_| { counter += 1; ReLateBound(ty::DebruijnIndex::new(1), BrAnon(counter)) }).0) diff --git a/src/librustc/middle/outlives.rs b/src/librustc/middle/ty/outlives.rs similarity index 100% rename from src/librustc/middle/outlives.rs rename to src/librustc/middle/ty/outlives.rs diff --git a/src/librustc/middle/ty_relate/mod.rs b/src/librustc/middle/ty/relate.rs similarity index 99% rename from src/librustc/middle/ty_relate/mod.rs rename to src/librustc/middle/ty/relate.rs index d2d612ece6f..7baf075cc69 100644 --- a/src/librustc/middle/ty_relate/mod.rs +++ b/src/librustc/middle/ty/relate.rs @@ -16,7 +16,7 @@ use middle::def_id::DefId; use middle::subst::{ErasedRegions, NonerasedRegions, ParamSpace, Substs}; use middle::ty::{self, HasTypeFlags, Ty, TypeError}; -use middle::ty_fold::TypeFoldable; +use middle::ty::fold::TypeFoldable; use std::rc::Rc; use syntax::abi; use rustc_front::hir as ast; diff --git a/src/librustc/middle/ty_walk.rs b/src/librustc/middle/ty/walk.rs similarity index 100% rename from src/librustc/middle/ty_walk.rs rename to src/librustc/middle/ty/walk.rs diff --git a/src/librustc/middle/wf.rs b/src/librustc/middle/ty/wf.rs similarity index 99% rename from src/librustc/middle/wf.rs rename to src/librustc/middle/ty/wf.rs index 96942756b98..20534f72666 100644 --- a/src/librustc/middle/wf.rs +++ b/src/librustc/middle/ty/wf.rs @@ -10,7 +10,7 @@ use middle::def_id::DefId; use middle::infer::InferCtxt; -use middle::outlives::{self, Component}; +use middle::ty::outlives::{self, Component}; use middle::subst::Substs; use middle::traits; use middle::ty::{self, RegionEscape, ToPredicate, Ty}; @@ -544,4 +544,3 @@ pub fn object_region_bounds<'tcx>( tcx.required_region_bounds(open_ty, predicates) } - diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index a0701d852bc..222de426432 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -21,7 +21,7 @@ use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple}; use middle::ty::TyClosure; use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer}; use middle::ty::{self, TypeAndMut, Ty, HasTypeFlags}; -use middle::ty_fold::{self, TypeFoldable}; +use middle::ty::fold::{self, TypeFoldable}; use std::fmt; use syntax::abi; @@ -219,7 +219,7 @@ fn in_binder<'tcx, T, U>(f: &mut fmt::Formatter, } }; - let new_value = ty_fold::replace_late_bound_regions(tcx, &value, |br| { + let new_value = fold::replace_late_bound_regions(tcx, &value, |br| { let _ = start_or_continue(f, "for<", ", "); ty::ReLateBound(ty::DebruijnIndex::new(1), match br { ty::BrNamed(_, name) => { @@ -255,7 +255,7 @@ fn in_binder<'tcx, T, U>(f: &mut fmt::Formatter, struct TraitAndProjections<'tcx>(ty::TraitRef<'tcx>, Vec>); impl<'tcx> TypeFoldable<'tcx> for TraitAndProjections<'tcx> { - fn fold_with>(&self, folder: &mut F) + fn fold_with>(&self, folder: &mut F) -> TraitAndProjections<'tcx> { TraitAndProjections(self.0.fold_with(folder), self.1.fold_with(folder)) } diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index c96495fcfc9..96d9572b485 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -24,7 +24,7 @@ use rustc_typeck::middle::stability; use rustc_typeck::middle::subst; use rustc_typeck::middle::subst::Subst; use rustc_typeck::middle::ty::{self, Ty, RegionEscape}; -use rustc_typeck::middle::ty_relate::TypeRelation; +use rustc_typeck::middle::ty::relate::TypeRelation; use rustc_typeck::middle::infer; use rustc_typeck::middle::infer::lub::Lub; use rustc_typeck::middle::infer::glb::Glb; diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 6843e4cab83..044e96db04d 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -38,8 +38,7 @@ use trans::type_::Type; use trans::type_of; use middle::traits; use middle::ty::{self, HasTypeFlags, Ty}; -use middle::ty_fold; -use middle::ty_fold::{TypeFolder, TypeFoldable}; +use middle::ty::fold::{TypeFolder, TypeFoldable}; use rustc::front::map::{PathElem, PathName}; use rustc_front::hir; use util::nodemap::{FnvHashMap, NodeMap}; @@ -60,7 +59,7 @@ pub use trans::context::CrateContext; /// Returns an equivalent value with all free regions removed (note /// that late-bound regions remain, because they are important for /// subtyping, but they are anonymized and normalized as well). This -/// is a stronger, caching version of `ty_fold::erase_regions`. +/// is a stronger, caching version of `ty::fold::erase_regions`. pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T where T : TypeFoldable<'tcx> { @@ -80,7 +79,7 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T Some(u) => return u } - let t_norm = ty_fold::super_fold_ty(self, ty); + let t_norm = ty::fold::super_fold_ty(self, ty); self.tcx().normalized_cache.borrow_mut().insert(ty, t_norm); return t_norm; } @@ -89,7 +88,7 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T where T : TypeFoldable<'tcx> { let u = self.tcx().anonymize_late_bound_regions(t); - ty_fold::super_fold_binder(self, &u) + ty::fold::super_fold_binder(self, &u) } fn fold_region(&mut self, r: ty::Region) -> ty::Region { diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index a3ba174a6e5..c98760ce02a 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -33,9 +33,9 @@ use trans::declare; use trans::monomorphize; use trans::type_::Type; use trans::type_of; -use middle::cast::{CastTy,IntTy}; use middle::subst::Substs; use middle::ty::{self, Ty}; +use middle::ty::cast::{CastTy,IntTy}; use util::nodemap::NodeMap; use rustc_front::hir; diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index 3a7fa040e4f..59040b9cafe 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -71,10 +71,10 @@ use trans::machine; use trans::meth; use trans::tvec; use trans::type_of; -use middle::cast::{CastKind, CastTy}; use middle::ty::{AdjustDerefRef, AdjustReifyFnPointer, AdjustUnsafeFnPointer}; use middle::ty::{self, Ty}; use middle::ty::MethodCall; +use middle::ty::cast::{CastKind, CastTy}; use util::common::indenter; use trans::machine::{llsize_of, llsize_of_alloc}; use trans::type_::Type; @@ -2045,8 +2045,8 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, id: ast::NodeId) -> DatumBlock<'blk, 'tcx, Expr> { - use middle::cast::CastTy::*; - use middle::cast::IntTy::*; + use middle::ty::cast::CastTy::*; + use middle::ty::cast::IntTy::*; fn int_cast(bcx: Block, lldsttype: Type, diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs index ae425f29132..1ef9981a0a4 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -17,7 +17,7 @@ use middle::infer; use middle::subst; use middle::subst::{Subst, Substs}; use middle::traits; -use middle::ty_fold::{TypeFolder, TypeFoldable}; +use middle::ty::fold::{TypeFolder, TypeFoldable}; use trans::attributes; use trans::base::{trans_enum_variant, push_ctxt, get_item_val}; use trans::base::trans_fn; diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index fb61f1ef42d..e6f9b1f9d6d 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -53,13 +53,12 @@ use middle::const_eval::{self, ConstVal}; use middle::const_eval::EvalHint::UncheckedExprHint; use middle::def; use middle::def_id::{DefId, LOCAL_CRATE}; -use middle::wf::object_region_bounds; use middle::resolve_lifetime as rl; use middle::privacy::{AllPublic, LastMod}; use middle::subst::{FnSpace, TypeSpace, SelfSpace, Subst, Substs, ParamSpace}; use middle::traits; use middle::ty::{self, RegionEscape, Ty, ToPredicate, HasTypeFlags}; -use middle::ty_fold; +use middle::ty::wf::object_region_bounds; use require_c_abi_if_variadic; use rscope::{self, UnelidableRscope, RegionScope, ElidableRscope, ObjectLifetimeDefaultRscope, ShiftedRscope, BindingRscope, @@ -535,9 +534,9 @@ fn find_implied_output_region<'tcx>(tcx: &ty::ctxt<'tcx>, for (input_type, input_pat) in input_tys.iter().zip(input_pats) { let mut regions = FnvHashSet(); - let have_bound_regions = ty_fold::collect_regions(tcx, - input_type, - &mut regions); + let have_bound_regions = ty::fold::collect_regions(tcx, + input_type, + &mut regions); debug!("find_implied_output_regions: collected {:?} from {:?} \ have_bound_regions={:?}", ®ions, input_type, have_bound_regions); @@ -2249,7 +2248,7 @@ impl<'tcx> Bounds<'tcx> { for ®ion_bound in &self.region_bounds { // account for the binder being introduced below; no need to shift `param_ty` // because, at present at least, it can only refer to early-bound regions - let region_bound = ty_fold::shift_region(region_bound, 1); + let region_bound = ty::fold::shift_region(region_bound, 1); vec.push(ty::Binder(ty::OutlivesPredicate(param_ty, region_bound)).to_predicate()); } diff --git a/src/librustc_typeck/check/assoc.rs b/src/librustc_typeck/check/assoc.rs index c80c48a9692..8dc95562e44 100644 --- a/src/librustc_typeck/check/assoc.rs +++ b/src/librustc_typeck/check/assoc.rs @@ -12,7 +12,7 @@ use middle::infer::InferCtxt; use middle::traits::{self, FulfillmentContext, Normalized, MiscObligation, SelectionContext, ObligationCause}; use middle::ty::HasTypeFlags; -use middle::ty_fold::TypeFoldable; +use middle::ty::fold::TypeFoldable; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 799a3e86a75..98c8c0a3199 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -44,9 +44,9 @@ use super::FnCtxt; use super::structurally_resolved_type; use lint; -use middle::cast::{CastKind, CastTy}; use middle::def_id::DefId; use middle::ty::{self, Ty, HasTypeFlags}; +use middle::ty::cast::{CastKind, CastTy}; use syntax::codemap::Span; use rustc_front::hir; use rustc_front::hir::UintTy::TyU8; @@ -226,8 +226,8 @@ impl<'tcx> CastCheck<'tcx> { /// can return Ok and create type errors in the fcx rather than returning /// directly. coercion-cast is handled in check instead of here. fn do_check<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result { - use middle::cast::IntTy::*; - use middle::cast::CastTy::*; + use middle::ty::cast::IntTy::*; + use middle::ty::cast::CastTy::*; let (t_from, t_cast) = match (CastTy::from_ty(self.expr_ty), CastTy::from_ty(self.cast_ty)) { diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 65409afa52d..d3a292676c5 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -67,7 +67,7 @@ use middle::traits::{self, ObligationCause}; use middle::traits::{predicate_for_trait_def, report_selection_error}; use middle::ty::{AutoDerefRef, AdjustDerefRef}; use middle::ty::{self, LvaluePreference, TypeAndMut, Ty, TypeError}; -use middle::ty_relate::RelateResult; +use middle::ty::relate::RelateResult; use util::common::indent; use std::cell::RefCell; diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index d1f898d82fd..e7c7b5831d0 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -17,7 +17,7 @@ use middle::def_id::DefId; use middle::subst; use middle::ty::FnSig; use middle::ty::{self, Ty}; -use middle::ty_fold::TypeFolder; +use middle::ty::fold::TypeFolder; use {CrateCtxt, require_same_types}; use std::collections::{HashMap}; diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 040e644a94d..048a2b62bca 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -16,7 +16,7 @@ use middle::def_id::DefId; use middle::subst::{self}; use middle::traits; use middle::ty::{self, NoPreference, PreferMutLvalue, Ty}; -use middle::ty_fold::TypeFoldable; +use middle::ty::fold::TypeFoldable; use middle::infer; use middle::infer::InferCtxt; use syntax::codemap::Span; diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index b04899f5ecd..f65602d9aac 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -16,13 +16,12 @@ use super::suggest; use check; use check::{FnCtxt, UnresolvedTypeAction}; use middle::def_id::DefId; -use middle::fast_reject; use middle::subst; use middle::subst::Subst; use middle::traits; use middle::ty::{self, NoPreference, RegionEscape, Ty, ToPolyTraitRef, TraitRef}; use middle::ty::HasTypeFlags; -use middle::ty_fold::TypeFoldable; +use middle::ty::fold::TypeFoldable; use middle::infer; use middle::infer::InferCtxt; use syntax::ast; @@ -41,7 +40,7 @@ struct ProbeContext<'a, 'tcx:'a> { mode: Mode, item_name: ast::Name, steps: Rc>>, - opt_simplified_steps: Option>, + opt_simplified_steps: Option>, inherent_candidates: Vec>, extension_candidates: Vec>, impl_dups: HashSet, @@ -163,7 +162,7 @@ pub fn probe<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, // Create a list of simplified self types, if we can. let mut simplified_steps = Vec::new(); for step in &steps { - match fast_reject::simplify_type(fcx.tcx(), step.self_ty, true) { + match ty::fast_reject::simplify_type(fcx.tcx(), step.self_ty, true) { None => { break; } Some(simplified_type) => { simplified_steps.push(simplified_type); } } @@ -236,7 +235,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { mode: Mode, item_name: ast::Name, steps: Vec>, - opt_simplified_steps: Option>) + opt_simplified_steps: Option>) -> ProbeContext<'a,'tcx> { ProbeContext { @@ -684,7 +683,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { let impl_type = self.tcx().lookup_item_type(impl_def_id); let impl_simplified_type = - match fast_reject::simplify_type(self.tcx(), impl_type.ty, false) { + match ty::fast_reject::simplify_type(self.tcx(), impl_type.ty, false) { Some(simplified_type) => simplified_type, None => { return true; } }; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b1fbf97d1a7..dc433786ae4 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -97,7 +97,7 @@ use middle::ty::{Disr, ParamTy, ParameterEnvironment}; use middle::ty::{LvaluePreference, NoPreference, PreferMutLvalue}; use middle::ty::{self, HasTypeFlags, RegionEscape, ToPolyTraitRef, Ty}; use middle::ty::{MethodCall, MethodCallee}; -use middle::ty_fold::{TypeFolder, TypeFoldable}; +use middle::ty::fold::{TypeFolder, TypeFoldable}; use require_c_abi_if_variadic; use rscope::{ElisionFailureInfo, RegionScope}; use session::Session; diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 844e143b9fa..b6ff7b529c5 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -88,14 +88,13 @@ use check::FnCtxt; use middle::free_region::FreeRegionMap; use middle::implicator::{self, Implication}; use middle::mem_categorization as mc; -use middle::outlives; use middle::region::CodeExtent; use middle::subst::Substs; use middle::traits; use middle::ty::{self, RegionEscape, ReScope, Ty, MethodCall, HasTypeFlags}; use middle::infer::{self, GenericKind, InferCtxt, SubregionOrigin, VerifyBound}; use middle::pat_util; -use middle::wf::{self, ImpliedBound}; +use middle::ty::wf::ImpliedBound; use std::mem; use std::rc::Rc; @@ -420,7 +419,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { for &ty in fn_sig_tys { let ty = self.resolve_type(ty); debug!("relate_free_regions(t={:?})", ty); - let implied_bounds = wf::implied_bounds(self.fcx.infcx(), body_id, ty, span); + let implied_bounds = ty::wf::implied_bounds(self.fcx.infcx(), body_id, ty, span); // Record any relations between free regions that we observe into the free-region-map. self.free_region_map.relate_free_regions_from_implied_bounds(&implied_bounds); @@ -1527,31 +1526,31 @@ pub fn type_must_outlive<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, assert!(!ty.has_escaping_regions()); - let components = outlives::components(rcx.infcx(), ty); + let components = ty::outlives::components(rcx.infcx(), ty); components_must_outlive(rcx, origin, components, region); } fn components_must_outlive<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, origin: infer::SubregionOrigin<'tcx>, - components: Vec>, + components: Vec>, region: ty::Region) { for component in components { let origin = origin.clone(); match component { - outlives::Component::Region(region1) => { + ty::outlives::Component::Region(region1) => { rcx.fcx.mk_subr(origin, region, region1); } - outlives::Component::Param(param_ty) => { + ty::outlives::Component::Param(param_ty) => { param_ty_must_outlive(rcx, origin, region, param_ty); } - outlives::Component::Projection(projection_ty) => { + ty::outlives::Component::Projection(projection_ty) => { projection_must_outlive(rcx, origin, region, projection_ty); } - outlives::Component::EscapingProjection(subcomponents) => { + ty::outlives::Component::EscapingProjection(subcomponents) => { components_must_outlive(rcx, origin, subcomponents, region); } - outlives::Component::UnresolvedInferenceVariable(v) => { + ty::outlives::Component::UnresolvedInferenceVariable(v) => { // ignore this, we presume it will yield an error // later, since if a type variable is not resolved by // this point it never will be @@ -1559,7 +1558,7 @@ fn components_must_outlive<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, origin.span(), &format!("unresolved inference variable in outlives: {:?}", v)); } - outlives::Component::RFC1214(subcomponents) => { + ty::outlives::Component::RFC1214(subcomponents) => { let suborigin = infer::RFC1214Subregion(Rc::new(origin)); components_must_outlive(rcx, suborigin, subcomponents, region); } diff --git a/src/librustc_typeck/check/wf.rs b/src/librustc_typeck/check/wf.rs index 99cb1281307..2c931e7830d 100644 --- a/src/librustc_typeck/check/wf.rs +++ b/src/librustc_typeck/check/wf.rs @@ -17,7 +17,7 @@ use middle::region; use middle::subst::{self, TypeSpace, FnSpace, ParamSpace, SelfSpace}; use middle::traits; use middle::ty::{self, Ty}; -use middle::ty_fold::{TypeFolder, TypeFoldable, super_fold_ty}; +use middle::ty::fold::{TypeFolder, TypeFoldable, super_fold_ty}; use std::cell::RefCell; use std::collections::HashSet; diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index a53f15ce2aa..06dd80c57ad 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -16,8 +16,7 @@ use middle::def_id::DefId; use middle::subst::{self, TypeSpace, FnSpace, ParamSpace, SelfSpace}; use middle::traits; use middle::ty::{self, Ty}; -use middle::ty_fold::{TypeFolder}; -use middle::wf; +use middle::ty::fold::{TypeFolder}; use std::cell::RefCell; use std::collections::HashSet; @@ -309,11 +308,11 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> { fcx.instantiate_type_scheme( ast_trait_ref.path.span, free_substs, &trait_ref); let obligations = - wf::trait_obligations(fcx.infcx(), - fcx.body_id, - &trait_ref, - ast_trait_ref.path.span, - true); + ty::wf::trait_obligations(fcx.infcx(), + fcx.body_id, + &trait_ref, + ast_trait_ref.path.span, + true); for obligation in obligations { fcx.register_predicate(obligation); } @@ -341,11 +340,11 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> { let obligations = predicates.predicates .iter() - .flat_map(|p| wf::predicate_obligations(fcx.infcx(), - fcx.body_id, - p, - span, - true)); + .flat_map(|p| ty::wf::predicate_obligations(fcx.infcx(), + fcx.body_id, + p, + span, + true)); for obligation in obligations { fcx.register_predicate(obligation); diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 94c01eb70e8..de841a0cc00 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -18,7 +18,7 @@ use check::FnCtxt; use middle::def_id::DefId; use middle::pat_util; use middle::ty::{self, Ty, MethodCall, MethodCallee}; -use middle::ty_fold::{TypeFolder,TypeFoldable}; +use middle::ty::fold::{TypeFolder,TypeFoldable}; use middle::infer; use write_substs_to_tcx; use write_ty_to_tcx; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index f0b68e5e902..930eb431f49 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -78,7 +78,7 @@ use middle::subst::{Substs, FnSpace, ParamSpace, SelfSpace, TypeSpace, VecPerPar use middle::ty::{ToPredicate, ImplContainer, ImplOrTraitItemContainer, TraitContainer}; use middle::ty::{self, RegionEscape, ToPolyTraitRef, Ty, TypeScheme, IntTypeExt}; use middle::ty::{VariantKind}; -use middle::ty_fold::{self, TypeFolder, TypeFoldable}; +use middle::ty::fold::{TypeFolder, TypeFoldable}; use middle::infer; use rscope::*; use rustc::front::map as hir_map; @@ -2374,7 +2374,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>( * before we really have a `ParameterEnvironment` to check. */ - ty_fold::fold_regions(tcx, value, &mut false, |region, _| { + ty::fold::fold_regions(tcx, value, &mut false, |region, _| { match region { ty::ReEarlyBound(data) => { let def_id = DefId::local(data.param_id); diff --git a/src/librustc_typeck/rscope.rs b/src/librustc_typeck/rscope.rs index 28403ab2282..1b02c736dce 100644 --- a/src/librustc_typeck/rscope.rs +++ b/src/librustc_typeck/rscope.rs @@ -10,7 +10,6 @@ use middle::ty; -use middle::ty_fold; use std::cell::Cell; use syntax::codemap::Span; @@ -239,11 +238,11 @@ impl<'r> ShiftedRscope<'r> { impl<'r> RegionScope for ShiftedRscope<'r> { fn object_lifetime_default(&self, span: Span) -> Option { self.base_scope.object_lifetime_default(span) - .map(|r| ty_fold::shift_region(r, 1)) + .map(|r| ty::fold::shift_region(r, 1)) } fn base_object_lifetime_default(&self, span: Span) -> ty::Region { - ty_fold::shift_region(self.base_scope.base_object_lifetime_default(span), 1) + ty::fold::shift_region(self.base_scope.base_object_lifetime_default(span), 1) } fn anon_regions(&self, @@ -254,7 +253,7 @@ impl<'r> RegionScope for ShiftedRscope<'r> { match self.base_scope.anon_regions(span, count) { Ok(mut v) => { for r in &mut v { - *r = ty_fold::shift_region(*r, 1); + *r = ty::fold::shift_region(*r, 1); } Ok(v) }