Remove pub use of TypeError in ty.rs

This commit is contained in:
Jared Roesch 2015-07-10 15:40:04 -07:00
parent 754aaea88c
commit fe30f6251a
10 changed files with 45 additions and 41 deletions

View file

@ -43,7 +43,7 @@ use super::type_variable::{RelationDir, BiTo, EqTo, SubtypeOf, SupertypeOf};
use middle::ty::{TyVar};
use middle::ty::{IntType, UintType};
use middle::ty::{self, Ty};
use middle::ty::{self, Ty, TypeError};
use middle::ty_fold;
use middle::ty_fold::{TypeFolder, TypeFoldable};
use middle::ty_relate::{self, Relate, RelateResult, TypeRelation};
@ -108,7 +108,7 @@ 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(ty::Sorts(ty_relate::expected_found(relation, &a, &b)))
Err(TypeError::Sorts(ty_relate::expected_found(relation, &a, &b)))
}
@ -278,7 +278,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
};
let u = ty.fold_with(&mut generalize);
if generalize.cycle_detected {
Err(ty::CyclicTy)
Err(TypeError::CyclicTy)
} else {
Ok(u)
}
@ -384,7 +384,7 @@ fn int_unification_error<'tcx>(a_is_expected: bool, v: (ty::IntVarValue, ty::Int
-> ty::TypeError<'tcx>
{
let (a, b) = v;
ty::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 +392,5 @@ fn float_unification_error<'tcx>(a_is_expected: bool,
-> ty::TypeError<'tcx>
{
let (a, b) = v;
ty::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

@ -77,7 +77,7 @@ use middle::def;
use middle::infer;
use middle::region;
use middle::subst;
use middle::ty::{self, Ty, HasTypeFlags};
use middle::ty::{self, Ty, TypeError, HasTypeFlags};
use middle::ty::{Region, ReFree};
use std::cell::{Cell, RefCell};
@ -351,8 +351,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
match free_regions_from_same_fn(self.tcx, sub, sup) {
Some(ref same_frs) if trace.is_some() => {
let trace = trace.unwrap();
let terr = ty::RegionsDoesNotOutlive(sup,
sub);
let terr = TypeError::RegionsDoesNotOutlive(sup,
sub);
trace_origins.push((trace, terr));
append_to_same_regions(&mut same_regions, same_frs);
}
@ -595,7 +595,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
match origin {
infer::Subtype(trace) |
infer::DefaultExistentialBound(trace) => {
let terr = ty::RegionsDoesNotOutlive(sup, sub);
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
self.report_and_explain_type_error(trace, &terr);
}
infer::Reborrow(span) => {

View file

@ -15,7 +15,7 @@ use super::{CombinedSnapshot, InferCtxt, HigherRankedType, SkolemizationMap};
use super::combine::CombineFields;
use middle::subst;
use middle::ty::{self, Binder};
use middle::ty::{self, TypeError, Binder};
use middle::ty_fold::{self, TypeFoldable};
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
use syntax::codemap::Span;
@ -85,11 +85,11 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
Err((skol_br, tainted_region)) => {
if self.a_is_expected {
debug!("Not as polymorphic!");
return Err(ty::RegionsInsufficientlyPolymorphic(skol_br,
return Err(TypeError::RegionsInsufficientlyPolymorphic(skol_br,
tainted_region));
} else {
debug!("Overly polymorphic!");
return Err(ty::RegionsOverlyPolymorphic(skol_br,
return Err(TypeError::RegionsOverlyPolymorphic(skol_br,
tainted_region));
}
}

View file

@ -32,7 +32,7 @@ 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, HasTypeFlags};
use middle::ty::{self, Ty, TypeError, HasTypeFlags};
use middle::ty_fold::{self, TypeFolder, TypeFoldable};
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
use rustc_data_structures::unify::{self, UnificationTable};
@ -913,7 +913,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
match higher_ranked::leak_check(self, skol_map, snapshot) {
Ok(()) => Ok(()),
Err((br, r)) => Err(ty::RegionsInsufficientlyPolymorphic(br, r))
Err((br, r)) => Err(TypeError::RegionsInsufficientlyPolymorphic(br, r))
}
}

View file

@ -23,7 +23,7 @@ use super::{RegionVariableOrigin, SubregionOrigin, TypeTrace, MiscVariable};
use rustc_data_structures::graph::{self, Direction, NodeIndex};
use middle::free_region::FreeRegionMap;
use middle::region;
use middle::ty::{self, Ty};
use middle::ty::{self, Ty, TypeError};
use middle::ty::{BoundRegion, FreeRegion, Region, RegionVid};
use middle::ty::{ReEmpty, ReStatic, ReInfer, ReFree, ReEarlyBound};
use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh};
@ -873,7 +873,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
if self.tcx.region_maps.nearest_common_ancestor(fr_scope, s_id) == fr_scope {
Ok(s)
} else {
Err(ty::RegionsNoOverlap(b, a))
Err(TypeError::RegionsNoOverlap(b, a))
}
}
@ -892,7 +892,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
if a == b {
Ok(a)
} else {
Err(ty::RegionsNoOverlap(b, a))
Err(TypeError::RegionsNoOverlap(b, a))
}
}
}
@ -949,7 +949,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
} else if r_id == scope_b {
Ok(ReScope(scope_a))
} else {
Err(ty::RegionsNoOverlap(region_a, region_b))
Err(TypeError::RegionsNoOverlap(region_a, region_b))
}
}
}

View file

@ -11,7 +11,6 @@
// FIXME: (@jroesch) @eddyb should remove this when he renames ctxt
#![allow(non_camel_case_types)]
pub use self::TypeError::*;
pub use self::InferTy::*;
pub use self::InferRegion::*;
pub use self::ImplOrTraitItemId::*;
@ -4932,6 +4931,7 @@ impl<'tcx> TyS<'tcx> {
}
fn sort_string(&self, cx: &ctxt) -> String {
match self.sty {
TyBool | TyChar | TyInt(_) |
TyUint(_) | TyFloat(_) | TyStr => self.to_string(),
@ -4977,6 +4977,8 @@ impl<'tcx> TyS<'tcx> {
/// errors.
impl<'tcx> fmt::Display for TypeError<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::TypeError::*;
match *self {
CyclicTy => write!(f, "cyclic type of infinite size"),
Mismatch => write!(f, "types differ"),
@ -5413,6 +5415,8 @@ impl<'tcx> ctxt<'tcx> {
}
pub fn note_and_explain_type_err(&self, err: &TypeError<'tcx>, sp: Span) {
use self::TypeError::*;
match *err {
RegionsDoesNotOutlive(subregion, superregion) => {
self.note_and_explain_region("", subregion, "...");

View file

@ -78,7 +78,7 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx> {
(&ty::TyInfer(_), _) |
(_, &ty::TyInfer(_)) => {
Err(ty::Sorts(ty_relate::expected_found(self, &a, &b)))
Err(ty::TypeError::Sorts(ty_relate::expected_found(self, &a, &b)))
}
(&ty::TyError, _) | (_, &ty::TyError) => {

View file

@ -14,7 +14,7 @@
//! type equality, etc.
use middle::subst::{ErasedRegions, NonerasedRegions, ParamSpace, Substs};
use middle::ty::{self, Ty};
use middle::ty::{self, Ty, TypeError};
use middle::ty_fold::TypeFoldable;
use std::rc::Rc;
use syntax::abi;
@ -101,7 +101,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TypeWithMutability<'tcx> {
a,
b);
if a.mutbl != b.mutbl {
Err(ty::Mutability)
Err(TypeError::Mutability)
} else {
let mutbl = a.mutbl;
let variance = match mutbl {
@ -186,7 +186,7 @@ fn relate_type_params<'a,'tcx:'a,R>(relation: &mut R,
where R: TypeRelation<'a,'tcx>
{
if a_tys.len() != b_tys.len() {
return Err(ty::TyParamSize(expected_found(relation,
return Err(TypeError::TyParamSize(expected_found(relation,
&a_tys.len(),
&b_tys.len())));
}
@ -256,7 +256,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::FnSig<'tcx> {
where R: TypeRelation<'a,'tcx>
{
if a.variadic != b.variadic {
return Err(ty::VariadicMismatch(
return Err(TypeError::VariadicMismatch(
expected_found(relation, &a.variadic, &b.variadic)));
}
@ -270,7 +270,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::FnSig<'tcx> {
(ty::FnDiverging, ty::FnDiverging) =>
Ok(ty::FnDiverging),
(a, b) =>
Err(ty::ConvergenceMismatch(
Err(TypeError::ConvergenceMismatch(
expected_found(relation, &(a != ty::FnDiverging), &(b != ty::FnDiverging)))),
});
@ -287,7 +287,7 @@ fn relate_arg_vecs<'a,'tcx:'a,R>(relation: &mut R,
where R: TypeRelation<'a,'tcx>
{
if a_args.len() != b_args.len() {
return Err(ty::ArgCount);
return Err(TypeError::ArgCount);
}
a_args.iter().zip(b_args)
@ -303,7 +303,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ast::Unsafety {
where R: TypeRelation<'a,'tcx>
{
if a != b {
Err(ty::UnsafetyMismatch(expected_found(relation, a, b)))
Err(TypeError::UnsafetyMismatch(expected_found(relation, a, b)))
} else {
Ok(*a)
}
@ -320,7 +320,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for abi::Abi {
if a == b {
Ok(*a)
} else {
Err(ty::AbiMismatch(expected_found(relation, a, b)))
Err(TypeError::AbiMismatch(expected_found(relation, a, b)))
}
}
}
@ -333,7 +333,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::ProjectionTy<'tcx> {
where R: TypeRelation<'a,'tcx>
{
if a.item_name != b.item_name {
Err(ty::ProjectionNameMismatched(
Err(TypeError::ProjectionNameMismatched(
expected_found(relation, &a.item_name, &b.item_name)))
} else {
let trait_ref = try!(relation.relate(&a.trait_ref, &b.trait_ref));
@ -368,7 +368,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for Vec<ty::PolyProjectionPredicate<'tcx>> {
// so we can just iterate through the lists pairwise, so long as they are the
// same length.
if a.len() != b.len() {
Err(ty::ProjectionBoundsLength(expected_found(relation, &a.len(), &b.len())))
Err(TypeError::ProjectionBoundsLength(expected_found(relation, &a.len(), &b.len())))
} else {
a.iter().zip(b)
.map(|(a, b)| relation.relate(a, b))
@ -412,7 +412,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::BuiltinBounds {
// Two sets of builtin bounds are only relatable if they are
// precisely the same (but see the coercion code).
if a != b {
Err(ty::BuiltinBoundsMismatch(expected_found(relation, a, b)))
Err(TypeError::BuiltinBoundsMismatch(expected_found(relation, a, b)))
} else {
Ok(*a)
}
@ -428,7 +428,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TraitRef<'tcx> {
{
// Different traits cannot be related
if a.def_id != b.def_id {
Err(ty::Traits(expected_found(relation, &a.def_id, &b.def_id)))
Err(TypeError::Traits(expected_found(relation, &a.def_id, &b.def_id)))
} else {
let substs = try!(relate_item_substs(relation, a.def_id, a.substs, b.substs));
Ok(ty::TraitRef { def_id: a.def_id, substs: relation.tcx().mk_substs(substs) })
@ -547,7 +547,7 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
if sz_a == sz_b {
Ok(tcx.mk_array(t, sz_a))
} else {
Err(ty::FixedArraySize(expected_found(relation, &sz_a, &sz_b)))
Err(TypeError::FixedArraySize(expected_found(relation, &sz_a, &sz_b)))
}
}
@ -565,10 +565,10 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
.collect::<Result<_, _>>());
Ok(tcx.mk_tup(ts))
} else if !(as_.is_empty() || bs.is_empty()) {
Err(ty::TupleSize(
Err(TypeError::TupleSize(
expected_found(relation, &as_.len(), &bs.len())))
} else {
Err(ty::Sorts(expected_found(relation, &a, &b)))
Err(TypeError::Sorts(expected_found(relation, &a, &b)))
}
}
@ -587,7 +587,7 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
_ =>
{
Err(ty::Sorts(expected_found(relation, &a, &b)))
Err(TypeError::Sorts(expected_found(relation, &a, &b)))
}
}
}

View file

@ -66,7 +66,7 @@ use middle::infer::{self, Coercion};
use middle::traits::{self, ObligationCause};
use middle::traits::{predicate_for_trait_def, report_selection_error};
use middle::ty::{AutoDerefRef, AdjustDerefRef};
use middle::ty::{self, TypeWithMutability, Ty};
use middle::ty::{self, TypeWithMutability, Ty, TypeError};
use middle::ty_relate::RelateResult;
use util::common::indent;
@ -247,7 +247,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
(u, cu)
} else {
debug!("Missing Unsize or CoerceUnsized traits");
return Err(ty::Mismatch);
return Err(TypeError::Mismatch);
};
// Note, we want to avoid unnecessary unsizing. We don't want to coerce to
@ -307,7 +307,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
// Uncertain or unimplemented.
Ok(None) | Err(traits::Unimplemented) => {
debug!("coerce_unsized: early return - can't prove obligation");
return Err(ty::Mismatch);
return Err(TypeError::Mismatch);
}
// Object safety violations or miscellaneous.
@ -472,6 +472,6 @@ fn coerce_mutbls<'tcx>(from_mutbl: ast::Mutability,
(ast::MutMutable, ast::MutMutable) |
(ast::MutImmutable, ast::MutImmutable) |
(ast::MutMutable, ast::MutImmutable) => Ok(None),
(ast::MutImmutable, ast::MutMutable) => Err(ty::Mutability)
(ast::MutImmutable, ast::MutMutable) => Err(TypeError::Mutability)
}
}

View file

@ -454,7 +454,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
mk_ptr: &Fn(Ty<'tcx>) -> Ty<'tcx>| {
if (mt_a.mutbl, mt_b.mutbl) == (ast::MutImmutable, ast::MutMutable) {
infcx.report_mismatched_types(span, mk_ptr(mt_b.ty),
target, &ty::Mutability);
target, &ty::TypeError::Mutability);
}
(mt_a.ty, mt_b.ty, unsize_trait, None)
};