pub use self::freshen::TypeFreshener;
pub use self::region_inference::{GenericKind, VerifyBound};
+use middle::def_id::DefId;
+use rustc_front::hir;
use middle::free_region::FreeRegionMap;
use middle::mem_categorization as mc;
use middle::mem_categorization::McResult;
use middle::subst::Subst;
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::adjustment;
+use middle::ty::{TyVid, IntVid, FloatVid, RegionVid};
+use middle::ty::{self, Ty, HasTypeFlags};
+use middle::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
+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;
/// See `error_reporting.rs` for more details
#[derive(Clone, Debug)]
pub enum ValuePairs<'tcx> {
- Types(ty::ExpectedFound<Ty<'tcx>>),
- TraitRefs(ty::ExpectedFound<ty::TraitRef<'tcx>>),
- PolyTraitRefs(ty::ExpectedFound<ty::PolyTraitRef<'tcx>>),
+ Types(ExpectedFound<Ty<'tcx>>),
+ TraitRefs(ExpectedFound<ty::TraitRef<'tcx>>),
+ PolyTraitRefs(ExpectedFound<ty::PolyTraitRef<'tcx>>),
}
/// The trace designates the path through inference that we took to
fn expected_found<T>(a_is_expected: bool,
a: T,
b: T)
- -> ty::ExpectedFound<T>
+ -> ExpectedFound<T>
{
if a_is_expected {
- ty::ExpectedFound {expected: a, found: b}
+ ExpectedFound {expected: a, found: b}
} else {
- ty::ExpectedFound {expected: b, found: a}
+ ExpectedFound {expected: b, found: a}
}
}
/// 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>
{
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;
}
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 {
}
pub fn type_is_unconstrained_numeric(&'a self, ty: Ty) -> UnconstrainedNumeric {
- use middle::ty::UnconstrainedNumeric::{Neither, UnconstrainedInt, UnconstrainedFloat};
+ use middle::ty::error::UnconstrainedNumeric::Neither;
+ use middle::ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat};
match ty.sty {
ty::TyInfer(ty::IntVar(vid)) => {
if self.int_unification_table.borrow_mut().has_value(vid) {
})
}
- pub fn construct_skolemized_subst(&self,
- generics: &ty::Generics<'tcx>,
- snapshot: &CombinedSnapshot)
- -> (subst::Substs<'tcx>, SkolemizationMap) {
- /*! See `higher_ranked::construct_skolemized_subst` */
-
- higher_ranked::construct_skolemized_substs(self, generics, snapshot)
- }
-
pub fn skolemize_late_bound_regions<T>(&self,
value: &ty::Binder<T>,
snapshot: &CombinedSnapshot)
}
pub fn next_region_var(&self, origin: RegionVariableOrigin) -> ty::Region {
- ty::ReInfer(ty::ReVar(self.region_vars.new_region_var(origin)))
+ ty::ReVar(self.region_vars.new_region_var(origin))
}
pub fn region_vars_for_defs(&self,
/// Apply `adjustment` to the type of `expr`
pub fn adjust_expr_ty(&self,
- expr: &ast::Expr,
- adjustment: Option<&ty::AutoAdjustment<'tcx>>)
+ expr: &hir::Expr,
+ adjustment: Option<&adjustment::AutoAdjustment<'tcx>>)
-> Ty<'tcx>
{
let raw_ty = self.expr_ty(expr);
}
}
- pub fn expr_ty(&self, ex: &ast::Expr) -> Ty<'tcx> {
+ pub fn expr_ty(&self, ex: &hir::Expr) -> Ty<'tcx> {
match self.tables.borrow().node_types.get(&ex.id) {
Some(&t) => t,
None => {
sp: Span,
mk_msg: M,
actual_ty: String,
- err: Option<&ty::TypeError<'tcx>>) where
+ err: Option<&TypeError<'tcx>>) where
M: FnOnce(Option<String>, String) -> String,
{
self.type_error_message_str_with_expected(sp, mk_msg, None, actual_ty, err)
mk_msg: M,
expected_ty: Option<Ty<'tcx>>,
actual_ty: String,
- err: Option<&ty::TypeError<'tcx>>) where
+ err: Option<&TypeError<'tcx>>) where
M: FnOnce(Option<String>, String) -> String,
{
debug!("hi! expected_ty = {:?}, actual_ty = {}", expected_ty, actual_ty);
sp: Span,
mk_msg: M,
actual_ty: Ty<'tcx>,
- err: Option<&ty::TypeError<'tcx>>) where
+ err: Option<&TypeError<'tcx>>) where
M: FnOnce(String) -> String,
{
let actual_ty = self.resolve_type_vars_if_possible(&actual_ty);
span: Span,
expected: Ty<'tcx>,
actual: Ty<'tcx>,
- err: &ty::TypeError<'tcx>) {
+ err: &TypeError<'tcx>) {
let trace = TypeTrace {
origin: Misc(span),
- values: Types(ty::ExpectedFound {
+ values: Types(ExpectedFound {
expected: expected,
found: actual
})
actual: type_variable::Default<'tcx>) {
let trace = TypeTrace {
origin: Misc(span),
- values: Types(ty::ExpectedFound {
+ values: Types(ExpectedFound {
expected: expected.ty,
found: actual.ty
})
};
self.report_and_explain_type_error(trace,
- &TypeError::TyParamDefaultMismatch(ty::ExpectedFound {
+ &TypeError::TyParamDefaultMismatch(ExpectedFound {
expected: expected,
found: actual
}));
-> (T, FnvHashMap<ty::BoundRegion,ty::Region>)
where T : TypeFoldable<'tcx>
{
- ty_fold::replace_late_bound_regions(
- self.tcx,
+ self.tcx.replace_late_bound_regions(
value,
|br| self.next_region_var(LateBoundRegion(span, br, lbrct)))
}
self.resolve_type_vars_or_error(&ty)
}
- pub fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult<Ty<'tcx>> {
+ pub fn expr_ty_adjusted(&self, expr: &hir::Expr) -> McResult<Ty<'tcx>> {
let ty = self.adjust_expr_ty(expr, self.tables.borrow().adjustments.get(&expr.id));
self.resolve_type_vars_or_error(&ty)
}
}
pub fn node_method_id(&self, method_call: ty::MethodCall)
- -> Option<ast::DefId> {
+ -> Option<DefId> {
self.tables
.borrow()
.method_map
.map(|method| method.def_id)
}
- pub fn adjustments(&self) -> Ref<NodeMap<ty::AutoAdjustment<'tcx>>> {
+ pub fn adjustments(&self) -> Ref<NodeMap<adjustment::AutoAdjustment<'tcx>>> {
fn project_adjustments<'a, 'tcx>(tables: &'a ty::Tables<'tcx>)
- -> &'a NodeMap<ty::AutoAdjustment<'tcx>> {
+ -> &'a NodeMap<adjustment::AutoAdjustment<'tcx>> {
&tables.adjustments
}
}
pub fn closure_kind(&self,
- def_id: ast::DefId)
+ def_id: DefId)
-> Option<ty::ClosureKind>
{
self.tables.borrow().closure_kinds.get(&def_id).cloned()
}
pub fn closure_type(&self,
- def_id: ast::DefId,
+ def_id: DefId,
substs: &ty::ClosureSubsts<'tcx>)
-> ty::ClosureTy<'tcx>
{
pub fn dummy(tcx: &ty::ctxt<'tcx>) -> TypeTrace<'tcx> {
TypeTrace {
origin: Misc(codemap::DUMMY_SP),
- values: Types(ty::ExpectedFound {
+ values: Types(ExpectedFound {
expected: tcx.types.err,
found: tcx.types.err,
})