diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index 08489ee7c31..6017c88bf87 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -10,14 +10,11 @@ //! See the Book for more information. -#![allow(non_camel_case_types)] - pub use self::LateBoundRegionConversionTime::*; pub use self::RegionVariableOrigin::*; pub use self::SubregionOrigin::*; pub use self::TypeOrigin::*; pub use self::ValuePairs::*; -pub use self::fixup_err::*; pub use middle::ty::IntVarValue; pub use self::freshen::TypeFreshener; pub use self::region_inference::GenericKind; @@ -65,7 +62,7 @@ pub mod unify_key; pub type Bound<T> = Option<T>; pub type UnitResult<'tcx> = RelateResult<'tcx, ()>; // "unify result" -pub type fres<T> = Result<T, fixup_err>; // "fixup result" +pub type FixupResult<T> = Result<T, FixupError>; // "fixup result" pub struct InferCtxt<'a, 'tcx: 'a> { pub tcx: &'a ty::ctxt<'tcx>, @@ -313,23 +310,25 @@ pub enum RegionVariableOrigin { } #[derive(Copy, Clone, Debug)] -pub enum fixup_err { - unresolved_int_ty(IntVid), - unresolved_float_ty(FloatVid), - unresolved_ty(TyVid) +pub enum FixupError { + UnresolvedIntTy(IntVid), + UnresolvedFloatTy(FloatVid), + UnresolvedTy(TyVid) } -pub fn fixup_err_to_string(f: fixup_err) -> String { +pub fn fixup_err_to_string(f: FixupError) -> String { + use self::FixupError::*; + match f { - unresolved_int_ty(_) => { + UnresolvedIntTy(_) => { "cannot determine the type of this integer; add a suffix to \ specify the type explicitly".to_string() } - unresolved_float_ty(_) => { + UnresolvedFloatTy(_) => { "cannot determine the type of this number; add a suffix to specify \ the type explicitly".to_string() } - unresolved_ty(_) => "unconstrained type".to_string(), + UnresolvedTy(_) => "unconstrained type".to_string(), } } @@ -1169,7 +1168,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { if ty.has_infer_types() || ty.references_error() { Err(()) } else { Ok(ty) } } - pub fn fully_resolve<T:TypeFoldable<'tcx>>(&self, value: &T) -> fres<T> { + pub fn fully_resolve<T:TypeFoldable<'tcx>>(&self, value: &T) -> FixupResult<T> { /*! * Attempts to resolve all type/region variables in * `value`. Region inference must have been run already (e.g., diff --git a/src/librustc/middle/infer/resolve.rs b/src/librustc/middle/infer/resolve.rs index 41a0d373fba..39807002b58 100644 --- a/src/librustc/middle/infer/resolve.rs +++ b/src/librustc/middle/infer/resolve.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use super::{InferCtxt, fixup_err, fres, unresolved_ty, unresolved_int_ty, unresolved_float_ty}; +use super::{InferCtxt, FixupError, FixupResult}; use middle::ty::{self, Ty, HasTypeFlags}; use middle::ty_fold::{self, TypeFoldable}; @@ -51,7 +51,7 @@ impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for OpportunisticTypeResolver<'a, 'tcx> /// Full type resolution replaces all type and region variables with /// their concrete results. If any variable cannot be replaced (never unified, etc) /// then an `Err` result is returned. -pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a,'tcx>, value: &T) -> fres<T> +pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a,'tcx>, value: &T) -> FixupResult<T> where T : TypeFoldable<'tcx> { let mut full_resolver = FullTypeResolver { infcx: infcx, err: None }; @@ -66,7 +66,7 @@ pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a,'tcx>, value: &T) -> fres // `err` field is not enforcable otherwise. struct FullTypeResolver<'a, 'tcx:'a> { infcx: &'a InferCtxt<'a, 'tcx>, - err: Option<fixup_err>, + err: Option<FixupError>, } impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> { @@ -81,15 +81,15 @@ impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> { let t = self.infcx.shallow_resolve(t); match t.sty { ty::TyInfer(ty::TyVar(vid)) => { - self.err = Some(unresolved_ty(vid)); + self.err = Some(FixupError::UnresolvedTy(vid)); self.tcx().types.err } ty::TyInfer(ty::IntVar(vid)) => { - self.err = Some(unresolved_int_ty(vid)); + self.err = Some(FixupError::UnresolvedIntTy(vid)); self.tcx().types.err } ty::TyInfer(ty::FloatVar(vid)) => { - self.err = Some(unresolved_float_ty(vid)); + self.err = Some(FixupError::UnresolvedFloatTy(vid)); self.tcx().types.err } ty::TyInfer(_) => { diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index 75215295dbd..8f44bb67050 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/trans/debuginfo/metadata.rs @@ -765,7 +765,9 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, trait_pointer_metadata(cx, t, None, unique_type_id), false) } - ty::TyBox(ty) | ty::TyRawPtr(ty::TypeAndMut{ty, ..}) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) => { + ty::TyBox(ty) | + ty::TyRawPtr(ty::TypeAndMut{ty, ..}) | + ty::TyRef(_, ty::TypeAndMut{ty, ..}) => { match ty.sty { ty::TySlice(typ) => { vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span) diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index 9ea9135c831..c08ab4f0ce6 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -440,9 +440,12 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match (&source.ty.sty, &target.ty.sty) { (&ty::TyBox(a), &ty::TyBox(b)) | - (&ty::TyRef(_, ty::TypeAndMut { ty: a, .. }), &ty::TyRef(_, ty::TypeAndMut { ty: b, .. })) | - (&ty::TyRef(_, ty::TypeAndMut { ty: a, .. }), &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) | - (&ty::TyRawPtr(ty::TypeAndMut { ty: a, .. }), &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) => { + (&ty::TyRef(_, ty::TypeAndMut { ty: a, .. }), + &ty::TyRef(_, ty::TypeAndMut { ty: b, .. })) | + (&ty::TyRef(_, ty::TypeAndMut { ty: a, .. }), + &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) | + (&ty::TyRawPtr(ty::TypeAndMut { ty: a, .. }), + &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) => { let (inner_source, inner_target) = (a, b); let (base, old_info) = if !type_is_sized(bcx.tcx(), inner_source) { diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs index 817d996085d..5be513d8ba4 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -193,7 +193,9 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ ty::TyUint(t) => Type::uint_from_ty(cx, t), ty::TyFloat(t) => Type::float_from_ty(cx, t), - ty::TyBox(ty) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) | ty::TyRawPtr(ty::TypeAndMut{ty, ..}) => { + ty::TyBox(ty) | + ty::TyRef(_, ty::TypeAndMut{ty, ..}) | + ty::TyRawPtr(ty::TypeAndMut{ty, ..}) => { if type_is_sized(cx.tcx(), ty) { Type::i8p(cx) } else { @@ -352,7 +354,9 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> adt::incomplete_type_of(cx, &*repr, "closure") } - ty::TyBox(ty) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) | ty::TyRawPtr(ty::TypeAndMut{ty, ..}) => { + ty::TyBox(ty) | + ty::TyRef(_, ty::TypeAndMut{ty, ..}) | + ty::TyRawPtr(ty::TypeAndMut{ty, ..}) => { if !type_is_sized(cx.tcx(), ty) { if let ty::TyStr = ty.sty { // This means we get a nicer name in the output (str is always diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 419fa9e160a..9d7ff3b9613 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -390,7 +390,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> { reason: reason } } - fn report_error(&self, e: infer::fixup_err) { + fn report_error(&self, e: infer::FixupError) { self.writeback_errors.set(true); if !self.tcx.sess.has_errors() { match self.reason {