[breaking-change] don't glob export ast::{UintTy, IntTy} variants
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
// The Rust abstract syntax tree.
|
||||
|
||||
pub use self::ForeignItem_::*;
|
||||
pub use self::IntTy::*;
|
||||
pub use self::Item_::*;
|
||||
pub use self::KleeneOp::*;
|
||||
pub use self::Lit_::*;
|
||||
@@ -29,7 +28,6 @@ pub use self::StructFieldKind::*;
|
||||
pub use self::TraitItem_::*;
|
||||
pub use self::Ty_::*;
|
||||
pub use self::TyParamBound::*;
|
||||
pub use self::UintTy::*;
|
||||
pub use self::UnsafeSource::*;
|
||||
pub use self::ViewPath_::*;
|
||||
pub use self::Visibility::*;
|
||||
@@ -1393,11 +1391,11 @@ pub enum ImplItemKind {
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
|
||||
pub enum IntTy {
|
||||
TyIs,
|
||||
TyI8,
|
||||
TyI16,
|
||||
TyI32,
|
||||
TyI64,
|
||||
Is,
|
||||
I8,
|
||||
I16,
|
||||
I32,
|
||||
I64,
|
||||
}
|
||||
|
||||
impl fmt::Debug for IntTy {
|
||||
@@ -1415,11 +1413,11 @@ impl fmt::Display for IntTy {
|
||||
impl IntTy {
|
||||
pub fn ty_to_string(&self) -> &'static str {
|
||||
match *self {
|
||||
TyIs => "isize",
|
||||
TyI8 => "i8",
|
||||
TyI16 => "i16",
|
||||
TyI32 => "i32",
|
||||
TyI64 => "i64"
|
||||
IntTy::Is => "isize",
|
||||
IntTy::I8 => "i8",
|
||||
IntTy::I16 => "i16",
|
||||
IntTy::I32 => "i32",
|
||||
IntTy::I64 => "i64"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1432,41 +1430,41 @@ impl IntTy {
|
||||
|
||||
pub fn ty_max(&self) -> u64 {
|
||||
match *self {
|
||||
TyI8 => 0x80,
|
||||
TyI16 => 0x8000,
|
||||
TyIs | TyI32 => 0x80000000, // actually ni about TyIs
|
||||
TyI64 => 0x8000000000000000
|
||||
IntTy::I8 => 0x80,
|
||||
IntTy::I16 => 0x8000,
|
||||
IntTy::Is | IntTy::I32 => 0x80000000, // FIXME: actually ni about Is
|
||||
IntTy::I64 => 0x8000000000000000
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bit_width(&self) -> Option<usize> {
|
||||
Some(match *self {
|
||||
TyIs => return None,
|
||||
TyI8 => 8,
|
||||
TyI16 => 16,
|
||||
TyI32 => 32,
|
||||
TyI64 => 64,
|
||||
IntTy::Is => return None,
|
||||
IntTy::I8 => 8,
|
||||
IntTy::I16 => 16,
|
||||
IntTy::I32 => 32,
|
||||
IntTy::I64 => 64,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
|
||||
pub enum UintTy {
|
||||
TyUs,
|
||||
TyU8,
|
||||
TyU16,
|
||||
TyU32,
|
||||
TyU64,
|
||||
Us,
|
||||
U8,
|
||||
U16,
|
||||
U32,
|
||||
U64,
|
||||
}
|
||||
|
||||
impl UintTy {
|
||||
pub fn ty_to_string(&self) -> &'static str {
|
||||
match *self {
|
||||
TyUs => "usize",
|
||||
TyU8 => "u8",
|
||||
TyU16 => "u16",
|
||||
TyU32 => "u32",
|
||||
TyU64 => "u64"
|
||||
UintTy::Us => "usize",
|
||||
UintTy::U8 => "u8",
|
||||
UintTy::U16 => "u16",
|
||||
UintTy::U32 => "u32",
|
||||
UintTy::U64 => "u64"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1476,20 +1474,20 @@ impl UintTy {
|
||||
|
||||
pub fn ty_max(&self) -> u64 {
|
||||
match *self {
|
||||
TyU8 => 0xff,
|
||||
TyU16 => 0xffff,
|
||||
TyUs | TyU32 => 0xffffffff, // actually ni about TyUs
|
||||
TyU64 => 0xffffffffffffffff
|
||||
UintTy::U8 => 0xff,
|
||||
UintTy::U16 => 0xffff,
|
||||
UintTy::Us | UintTy::U32 => 0xffffffff, // FIXME: actually ni about Us
|
||||
UintTy::U64 => 0xffffffffffffffff
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bit_width(&self) -> Option<usize> {
|
||||
Some(match *self {
|
||||
TyUs => return None,
|
||||
TyU8 => 8,
|
||||
TyU16 => 16,
|
||||
TyU32 => 32,
|
||||
TyU64 => 64,
|
||||
UintTy::Us => return None,
|
||||
UintTy::U8 => 8,
|
||||
UintTy::U16 => 16,
|
||||
UintTy::U32 => 32,
|
||||
UintTy::U64 => 64,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -746,16 +746,16 @@ pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr>
|
||||
|
||||
fn int_type_of_word(s: &str) -> Option<IntType> {
|
||||
match s {
|
||||
"i8" => Some(SignedInt(ast::TyI8)),
|
||||
"u8" => Some(UnsignedInt(ast::TyU8)),
|
||||
"i16" => Some(SignedInt(ast::TyI16)),
|
||||
"u16" => Some(UnsignedInt(ast::TyU16)),
|
||||
"i32" => Some(SignedInt(ast::TyI32)),
|
||||
"u32" => Some(UnsignedInt(ast::TyU32)),
|
||||
"i64" => Some(SignedInt(ast::TyI64)),
|
||||
"u64" => Some(UnsignedInt(ast::TyU64)),
|
||||
"isize" => Some(SignedInt(ast::TyIs)),
|
||||
"usize" => Some(UnsignedInt(ast::TyUs)),
|
||||
"i8" => Some(SignedInt(ast::IntTy::I8)),
|
||||
"u8" => Some(UnsignedInt(ast::UintTy::U8)),
|
||||
"i16" => Some(SignedInt(ast::IntTy::I16)),
|
||||
"u16" => Some(UnsignedInt(ast::UintTy::U16)),
|
||||
"i32" => Some(SignedInt(ast::IntTy::I32)),
|
||||
"u32" => Some(UnsignedInt(ast::UintTy::U32)),
|
||||
"i64" => Some(SignedInt(ast::IntTy::I64)),
|
||||
"u64" => Some(UnsignedInt(ast::UintTy::U64)),
|
||||
"isize" => Some(SignedInt(ast::IntTy::Is)),
|
||||
"usize" => Some(UnsignedInt(ast::UintTy::Us)),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
@@ -797,11 +797,11 @@ impl IntType {
|
||||
}
|
||||
fn is_ffi_safe(self) -> bool {
|
||||
match self {
|
||||
SignedInt(ast::TyI8) | UnsignedInt(ast::TyU8) |
|
||||
SignedInt(ast::TyI16) | UnsignedInt(ast::TyU16) |
|
||||
SignedInt(ast::TyI32) | UnsignedInt(ast::TyU32) |
|
||||
SignedInt(ast::TyI64) | UnsignedInt(ast::TyU64) => true,
|
||||
SignedInt(ast::TyIs) | UnsignedInt(ast::TyUs) => false
|
||||
SignedInt(ast::IntTy::I8) | UnsignedInt(ast::UintTy::U8) |
|
||||
SignedInt(ast::IntTy::I16) | UnsignedInt(ast::UintTy::U16) |
|
||||
SignedInt(ast::IntTy::I32) | UnsignedInt(ast::UintTy::U32) |
|
||||
SignedInt(ast::IntTy::I64) | UnsignedInt(ast::UintTy::U64) => true,
|
||||
SignedInt(ast::IntTy::Is) | UnsignedInt(ast::UintTy::Us) => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,17 +680,17 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
self.expr(sp, ast::ExprKind::Lit(P(respan(sp, lit))))
|
||||
}
|
||||
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> {
|
||||
self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs)))
|
||||
self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::UintTy::Us)))
|
||||
}
|
||||
fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr> {
|
||||
self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs,
|
||||
self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::IntTy::Is,
|
||||
ast::Sign::new(i))))
|
||||
}
|
||||
fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr> {
|
||||
self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU32)))
|
||||
self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::UintTy::U32)))
|
||||
}
|
||||
fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> {
|
||||
self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU8)))
|
||||
self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::UintTy::U8)))
|
||||
}
|
||||
fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr> {
|
||||
self.expr_lit(sp, ast::LitBool(value))
|
||||
|
||||
@@ -279,17 +279,17 @@ pub mod rt {
|
||||
);
|
||||
}
|
||||
|
||||
impl_to_tokens_int! { signed, isize, ast::TyIs }
|
||||
impl_to_tokens_int! { signed, i8, ast::TyI8 }
|
||||
impl_to_tokens_int! { signed, i16, ast::TyI16 }
|
||||
impl_to_tokens_int! { signed, i32, ast::TyI32 }
|
||||
impl_to_tokens_int! { signed, i64, ast::TyI64 }
|
||||
impl_to_tokens_int! { signed, isize, ast::IntTy::Is }
|
||||
impl_to_tokens_int! { signed, i8, ast::IntTy::I8 }
|
||||
impl_to_tokens_int! { signed, i16, ast::IntTy::I16 }
|
||||
impl_to_tokens_int! { signed, i32, ast::IntTy::I32 }
|
||||
impl_to_tokens_int! { signed, i64, ast::IntTy::I64 }
|
||||
|
||||
impl_to_tokens_int! { unsigned, usize, ast::TyUs }
|
||||
impl_to_tokens_int! { unsigned, u8, ast::TyU8 }
|
||||
impl_to_tokens_int! { unsigned, u16, ast::TyU16 }
|
||||
impl_to_tokens_int! { unsigned, u32, ast::TyU32 }
|
||||
impl_to_tokens_int! { unsigned, u64, ast::TyU64 }
|
||||
impl_to_tokens_int! { unsigned, usize, ast::UintTy::Us }
|
||||
impl_to_tokens_int! { unsigned, u8, ast::UintTy::U8 }
|
||||
impl_to_tokens_int! { unsigned, u16, ast::UintTy::U16 }
|
||||
impl_to_tokens_int! { unsigned, u32, ast::UintTy::U32 }
|
||||
impl_to_tokens_int! { unsigned, u64, ast::UintTy::U64 }
|
||||
|
||||
pub trait ExtParseUtils {
|
||||
fn parse_item(&self, s: String) -> P<ast::Item>;
|
||||
|
||||
@@ -618,16 +618,16 @@ pub fn integer_lit(s: &str,
|
||||
if let Some(ref suf) = suffix {
|
||||
if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")}
|
||||
ty = match &**suf {
|
||||
"isize" => ast::SignedIntLit(ast::TyIs, ast::Plus),
|
||||
"i8" => ast::SignedIntLit(ast::TyI8, ast::Plus),
|
||||
"i16" => ast::SignedIntLit(ast::TyI16, ast::Plus),
|
||||
"i32" => ast::SignedIntLit(ast::TyI32, ast::Plus),
|
||||
"i64" => ast::SignedIntLit(ast::TyI64, ast::Plus),
|
||||
"usize" => ast::UnsignedIntLit(ast::TyUs),
|
||||
"u8" => ast::UnsignedIntLit(ast::TyU8),
|
||||
"u16" => ast::UnsignedIntLit(ast::TyU16),
|
||||
"u32" => ast::UnsignedIntLit(ast::TyU32),
|
||||
"u64" => ast::UnsignedIntLit(ast::TyU64),
|
||||
"isize" => ast::SignedIntLit(ast::IntTy::Is, ast::Plus),
|
||||
"i8" => ast::SignedIntLit(ast::IntTy::I8, ast::Plus),
|
||||
"i16" => ast::SignedIntLit(ast::IntTy::I16, ast::Plus),
|
||||
"i32" => ast::SignedIntLit(ast::IntTy::I32, ast::Plus),
|
||||
"i64" => ast::SignedIntLit(ast::IntTy::I64, ast::Plus),
|
||||
"usize" => ast::UnsignedIntLit(ast::UintTy::Us),
|
||||
"u8" => ast::UnsignedIntLit(ast::UintTy::U8),
|
||||
"u16" => ast::UnsignedIntLit(ast::UintTy::U16),
|
||||
"u32" => ast::UnsignedIntLit(ast::UintTy::U32),
|
||||
"u64" => ast::UnsignedIntLit(ast::UintTy::U64),
|
||||
_ => {
|
||||
// i<digits> and u<digits> look like widths, so lets
|
||||
// give an error message along those lines
|
||||
|
||||
@@ -27,7 +27,7 @@ use ast::{Ident, Inherited, ImplItem, Item, Item_, ItemStatic};
|
||||
use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl, ItemConst};
|
||||
use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, ItemDefaultImpl};
|
||||
use ast::{ItemExternCrate, ItemUse};
|
||||
use ast::{Lit, Lit_};
|
||||
use ast::{Lit, Lit_, UintTy};
|
||||
use ast::{LitBool, LitChar, LitByte, LitByteStr};
|
||||
use ast::{LitStr, LitInt, Local};
|
||||
use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces};
|
||||
@@ -45,7 +45,7 @@ use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
|
||||
use ast::{Ty, Ty_, TypeBinding, TyMac};
|
||||
use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer};
|
||||
use ast::{TyParam, TyParamBounds, TyParen, TyPath, TyPtr};
|
||||
use ast::{TyRptr, TyTup, TyU32, TyVec};
|
||||
use ast::{TyRptr, TyTup, TyVec};
|
||||
use ast::TypeTraitItem;
|
||||
use ast::UnnamedField;
|
||||
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
|
||||
@@ -2017,7 +2017,7 @@ impl<'a> Parser<'a> {
|
||||
pub fn mk_lit_u32(&mut self, i: u32, attrs: ThinAttributes) -> P<Expr> {
|
||||
let span = &self.span;
|
||||
let lv_lit = P(codemap::Spanned {
|
||||
node: LitInt(i as u64, ast::UnsignedIntLit(TyU32)),
|
||||
node: LitInt(i as u64, ast::UnsignedIntLit(UintTy::U32)),
|
||||
span: *span
|
||||
});
|
||||
|
||||
|
||||
@@ -3184,8 +3184,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_signed_int_to_string() {
|
||||
let pos_int = ast::LitInt(42, ast::SignedIntLit(ast::TyI32, ast::Plus));
|
||||
let neg_int = ast::LitInt((!42 + 1) as u64, ast::SignedIntLit(ast::TyI32, ast::Minus));
|
||||
let pos_int = ast::LitInt(42, ast::SignedIntLit(ast::IntTy::I32, ast::Plus));
|
||||
let neg_int = ast::LitInt((!42 + 1) as u64, ast::SignedIntLit(ast::IntTy::I32, ast::Minus));
|
||||
assert_eq!(format!("-{}", lit_to_string(&codemap::dummy_spanned(pos_int))),
|
||||
lit_to_string(&codemap::dummy_spanned(neg_int)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user