move middle::ty and related modules to middle/ty/

This commit is contained in:
Ariel Ben-Yehuda 2015-09-06 18:32:34 +03:00 committed by Ariel Ben-Yehuda
parent 009f2cf7dd
commit caa10c3bde
52 changed files with 140 additions and 154 deletions

View File

@ -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;
}

View File

@ -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};

View File

@ -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;

View File

@ -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)]

View File

@ -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;

View File

@ -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>

View File

@ -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<ty_relate::Cause>,
pub cause: Option<ty::relate::Cause>,
}
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))
}

View File

@ -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>

View File

@ -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)
}
}
}

View File

@ -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> {

View File

@ -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(|&region_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) => {

View File

@ -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>;

View File

@ -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(())
}
}

View File

@ -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<ty::BoundRegion,ty::Region>)
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)))

View File

@ -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};

View File

@ -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<FixupError>,
}
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)
}
}
}

View File

@ -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)

View File

@ -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)
}
}

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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() => { // (*)

View File

@ -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()
}

View File

@ -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)
}
}
}

View File

@ -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<Bar<i32>, u32>` yields the sequence `[Bar<i32>, u32]`
/// (but not `i32`, like `walk`).
pub fn walk_shallow(&'tcx self) -> IntoIter<Ty<'tcx>> {
ty_walk::walk_shallow(self)
walk::walk_shallow(self)
}
pub fn as_opt_param_ty(&self) -> Option<ty::ParamTy> {
@ -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<T>(&self, value: &Binder<T>) -> 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)

View File

@ -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;

View File

@ -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)
}

View File

@ -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<ty::ProjectionPredicate<'tcx>>);
impl<'tcx> TypeFoldable<'tcx> for TraitAndProjections<'tcx> {
fn fold_with<F:ty_fold::TypeFolder<'tcx>>(&self, folder: &mut F)
fn fold_with<F: fold::TypeFolder<'tcx>>(&self, folder: &mut F)
-> TraitAndProjections<'tcx> {
TraitAndProjections(self.0.fold_with(folder), self.1.fold_with(folder))
}

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -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={:?}", &regions, input_type, have_bound_regions);
@ -2249,7 +2248,7 @@ impl<'tcx> Bounds<'tcx> {
for &region_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());
}

View File

@ -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;

View File

@ -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<CastKind, CastError> {
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)) {

View File

@ -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;

View File

@ -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};

View File

@ -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;

View File

@ -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<Vec<CandidateStep<'tcx>>>,
opt_simplified_steps: Option<Vec<fast_reject::SimplifiedType>>,
opt_simplified_steps: Option<Vec<ty::fast_reject::SimplifiedType>>,
inherent_candidates: Vec<Candidate<'tcx>>,
extension_candidates: Vec<Candidate<'tcx>>,
impl_dups: HashSet<DefId>,
@ -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<CandidateStep<'tcx>>,
opt_simplified_steps: Option<Vec<fast_reject::SimplifiedType>>)
opt_simplified_steps: Option<Vec<ty::fast_reject::SimplifiedType>>)
-> 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; }
};

View File

@ -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;

View File

@ -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<outlives::Component<'tcx>>,
components: Vec<ty::outlives::Component<'tcx>>,
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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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<ty::Region> {
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)
}