From ccf48bcd4054ecb4e205a18b1ac582ef3ac3a905 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 8 Feb 2016 16:09:01 +0100 Subject: [PATCH] [breaking-change] don't glob export ast::FloatTy variants --- src/librustc/middle/const_eval.rs | 4 ++-- src/librustc/middle/ty/context.rs | 8 ++++---- src/librustc_lint/types.rs | 4 ++-- src/librustc_metadata/tyencode.rs | 4 ++-- src/librustc_resolve/lib.rs | 8 ++++---- src/librustc_trans/trans/collector.rs | 4 ++-- src/librustc_trans/trans/type_.rs | 4 ++-- src/librustc_typeck/check/intrinsic.rs | 4 ++-- src/librustc_typeck/check/method/probe.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/coherence/orphan.rs | 4 ++-- src/librustdoc/clean/mod.rs | 8 ++++---- src/libsyntax/ast.rs | 13 ++++++------- src/libsyntax/parse/mod.rs | 4 ++-- 14 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index e5fc83cc5f3..4b4f9eefe22 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -1314,8 +1314,8 @@ macro_rules! convert_val { ty::TyUint(ast::TyU32) => convert_val!(u32, Uint, u64), ty::TyUint(ast::TyU64) => convert_val!(u64, Uint, u64), - ty::TyFloat(ast::TyF32) => convert_val!(f32, Float, f64), - ty::TyFloat(ast::TyF64) => convert_val!(f64, Float, f64), + ty::TyFloat(ast::FloatTy::F32) => convert_val!(f32, Float, f64), + ty::TyFloat(ast::FloatTy::F64) => convert_val!(f64, Float, f64), _ => Err(ErrKind::CannotCast), } } diff --git a/src/librustc/middle/ty/context.rs b/src/librustc/middle/ty/context.rs index 6307ec8bbd0..ac924962485 100644 --- a/src/librustc/middle/ty/context.rs +++ b/src/librustc/middle/ty/context.rs @@ -202,8 +202,8 @@ fn new(arena: &'tcx TypedArena>, u16: mk(TyUint(ast::TyU16)), u32: mk(TyUint(ast::TyU32)), u64: mk(TyUint(ast::TyU64)), - f32: mk(TyFloat(ast::TyF32)), - f64: mk(TyFloat(ast::TyF64)), + f32: mk(TyFloat(ast::FloatTy::F32)), + f64: mk(TyFloat(ast::FloatTy::F64)), } } } @@ -860,8 +860,8 @@ pub fn mk_mach_uint(&self, tm: ast::UintTy) -> Ty<'tcx> { pub fn mk_mach_float(&self, tm: ast::FloatTy) -> Ty<'tcx> { match tm { - ast::TyF32 => self.types.f32, - ast::TyF64 => self.types.f64, + ast::FloatTy::F32 => self.types.f32, + ast::FloatTy::F64 => self.types.f64, } } diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index fae40d7224b..6adec347ac6 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -267,8 +267,8 @@ fn uint_ty_range(uint_ty: ast::UintTy) -> (u64, u64) { fn float_ty_range(float_ty: ast::FloatTy) -> (f64, f64) { match float_ty { - ast::TyF32 => (f32::MIN as f64, f32::MAX as f64), - ast::TyF64 => (f64::MIN, f64::MAX) + ast::FloatTy::F32 => (f32::MIN as f64, f32::MAX as f64), + ast::FloatTy::F64 => (f64::MIN, f64::MAX) } } diff --git a/src/librustc_metadata/tyencode.rs b/src/librustc_metadata/tyencode.rs index f03c25d698f..d4060165c1d 100644 --- a/src/librustc_metadata/tyencode.rs +++ b/src/librustc_metadata/tyencode.rs @@ -94,8 +94,8 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Cursor>, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx } ty::TyFloat(t) => { match t { - ast::TyF32 => write!(w, "Mf"), - ast::TyF64 => write!(w, "MF"), + ast::FloatTy::F32 => write!(w, "Mf"), + ast::FloatTy::F64 => write!(w, "MF"), }; } ty::TyEnum(def, substs) => { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 5fbe06a868f..573bc91bbcb 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -60,9 +60,9 @@ use rustc::middle::ty::{Freevar, FreevarMap, TraitMap, GlobMap}; use rustc::util::nodemap::{NodeMap, DefIdSet, FnvHashMap}; -use syntax::ast; +use syntax::ast::{self, FloatTy}; use syntax::ast::{CRATE_NODE_ID, Name, NodeId, CrateNum, TyIs, TyI8, TyI16, TyI32, TyI64}; -use syntax::ast::{TyUs, TyU8, TyU16, TyU32, TyU64, TyF64, TyF32}; +use syntax::ast::{TyUs, TyU8, TyU16, TyU32, TyU64}; use syntax::attr::AttrMetaMethods; use syntax::codemap::{self, Span, Pos}; use syntax::errors::DiagnosticBuilder; @@ -1074,8 +1074,8 @@ fn new() -> PrimitiveTypeTable { table.intern("bool", TyBool); table.intern("char", TyChar); - table.intern("f32", TyFloat(TyF32)); - table.intern("f64", TyFloat(TyF64)); + table.intern("f32", TyFloat(FloatTy::F32)); + table.intern("f64", TyFloat(FloatTy::F64)); table.intern("isize", TyInt(TyIs)); table.intern("i8", TyInt(TyI8)); table.intern("i16", TyInt(TyI16)); diff --git a/src/librustc_trans/trans/collector.rs b/src/librustc_trans/trans/collector.rs index ae4f7461a26..1c127b90f27 100644 --- a/src/librustc_trans/trans/collector.rs +++ b/src/librustc_trans/trans/collector.rs @@ -1230,8 +1230,8 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty::TyUint(ast::TyU16) => output.push_str("u16"), ty::TyUint(ast::TyU32) => output.push_str("u32"), ty::TyUint(ast::TyU64) => output.push_str("u64"), - ty::TyFloat(ast::TyF32) => output.push_str("f32"), - ty::TyFloat(ast::TyF64) => output.push_str("f64"), + ty::TyFloat(ast::FloatTy::F32) => output.push_str("f32"), + ty::TyFloat(ast::FloatTy::F64) => output.push_str("f64"), ty::TyStruct(adt_def, substs) | ty::TyEnum(adt_def, substs) => { push_item_name(cx, adt_def.did, output); diff --git a/src/librustc_trans/trans/type_.rs b/src/librustc_trans/trans/type_.rs index c635d1ba233..5d5aa5240d6 100644 --- a/src/librustc_trans/trans/type_.rs +++ b/src/librustc_trans/trans/type_.rs @@ -147,8 +147,8 @@ pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type { pub fn float_from_ty(ccx: &CrateContext, t: ast::FloatTy) -> Type { match t { - ast::TyF32 => Type::f32(ccx), - ast::TyF64 => Type::f64(ccx), + ast::FloatTy::F32 => Type::f32(ccx), + ast::FloatTy::F64 => Type::f64(ccx), } } diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 248a2341c2b..0f3cce18ea2 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -443,8 +443,8 @@ fn match_intrinsic_type_to_type<'tcx, 'a>( n = bits)), }, Float(bits) => match (bits, &t.sty) { - (32, &ty::TyFloat(ast::FloatTy::TyF32)) | - (64, &ty::TyFloat(ast::FloatTy::TyF64)) => {}, + (32, &ty::TyFloat(ast::FloatTy::F32)) | + (64, &ty::TyFloat(ast::FloatTy::F64)) => {}, _ => simple_error(&format!("`{}`", t), &format!("`f{n}`", n = bits)), }, diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 44dd0ef7b17..becb0c93b26 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -357,11 +357,11 @@ fn assemble_probe(&mut self, self_ty: Ty<'tcx>) { let lang_def_id = self.tcx().lang_items.usize_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyFloat(ast::TyF32) => { + ty::TyFloat(ast::FloatTy::F32) => { let lang_def_id = self.tcx().lang_items.f32_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyFloat(ast::TyF64) => { + ty::TyFloat(ast::FloatTy::F64) => { let lang_def_id = self.tcx().lang_items.f64_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index a1280d0f7e4..7a38a4a0cbf 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2556,7 +2556,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, let arg_ty = structurally_resolved_type(fcx, arg.span, fcx.expr_ty(&**arg)); match arg_ty.sty { - ty::TyFloat(ast::TyF32) => { + ty::TyFloat(ast::FloatTy::F32) => { fcx.type_error_message(arg.span, |t| { format!("can't pass an {} to variadic \ diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index fb257f0e673..e03bbfd09f2 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -191,14 +191,14 @@ fn check_item(&self, item: &hir::Item) { "usize", item.span); } - ty::TyFloat(ast::TyF32) => { + ty::TyFloat(ast::FloatTy::F32) => { self.check_primitive_impl(def_id, self.tcx.lang_items.f32_impl(), "f32", "f32", item.span); } - ty::TyFloat(ast::TyF64) => { + ty::TyFloat(ast::FloatTy::F64) => { self.check_primitive_impl(def_id, self.tcx.lang_items.f64_impl(), "f64", diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index d7fb789ada1..254106434fa 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1650,8 +1650,8 @@ fn clean(&self, cx: &DocContext) -> Type { ty::TyUint(ast::TyU16) => Primitive(U16), ty::TyUint(ast::TyU32) => Primitive(U32), ty::TyUint(ast::TyU64) => Primitive(U64), - ty::TyFloat(ast::TyF32) => Primitive(F32), - ty::TyFloat(ast::TyF64) => Primitive(F64), + ty::TyFloat(ast::FloatTy::F32) => Primitive(F32), + ty::TyFloat(ast::FloatTy::F64) => Primitive(F64), ty::TyStr => Primitive(Str), ty::TyBox(t) => { let box_did = cx.tcx_opt().and_then(|tcx| { @@ -2629,8 +2629,8 @@ fn resolve_type(cx: &DocContext, hir::TyUint(ast::TyU16) => return Primitive(U16), hir::TyUint(ast::TyU32) => return Primitive(U32), hir::TyUint(ast::TyU64) => return Primitive(U64), - hir::TyFloat(ast::TyF32) => return Primitive(F32), - hir::TyFloat(ast::TyF64) => return Primitive(F64), + hir::TyFloat(ast::FloatTy::F32) => return Primitive(F32), + hir::TyFloat(ast::FloatTy::F64) => return Primitive(F64), }, Def::SelfTy(..) if path.segments.len() == 1 => { return Generic(special_idents::type_self.name.to_string()); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 36543bd35ca..a43874f9990 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,7 +10,6 @@ // The Rust abstract syntax tree. -pub use self::FloatTy::*; pub use self::ForeignItem_::*; pub use self::IntTy::*; pub use self::Item_::*; @@ -1509,8 +1508,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum FloatTy { - TyF32, - TyF64, + F32, + F64, } impl fmt::Debug for FloatTy { @@ -1528,15 +1527,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { impl FloatTy { pub fn ty_to_string(&self) -> &'static str { match *self { - TyF32 => "f32", - TyF64 => "f64", + FloatTy::F32 => "f32", + FloatTy::F64 => "f64", } } pub fn bit_width(&self) -> usize { match *self { - TyF32 => 32, - TyF64 => 64, + FloatTy::F32 => 32, + FloatTy::F64 => 64, } } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 9ad5dafbf8b..bbcb0c70ff4 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -452,8 +452,8 @@ fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>, sd: &Handler, sp: Span) -> ast::Lit_ { debug!("filtered_float_lit: {}, {:?}", data, suffix); match suffix.as_ref().map(|s| &**s) { - Some("f32") => ast::LitFloat(data, ast::TyF32), - Some("f64") => ast::LitFloat(data, ast::TyF64), + Some("f32") => ast::LitFloat(data, ast::FloatTy::F32), + Some("f64") => ast::LitFloat(data, ast::FloatTy::F64), Some(suf) => { if suf.len() >= 2 && looks_like_width_suffix(&['f'], suf) { // if it looks like a width, lets try to be helpful.