[breaking-change] don't pub export ast::IntLitType variants

This commit is contained in:
Oliver Schneider 2016-02-08 17:16:23 +01:00
parent 69072c4f5d
commit 498a2e416e
11 changed files with 42 additions and 43 deletions

View File

@ -1328,14 +1328,14 @@ fn lit_to_const(sess: &Session, span: Span, lit: &ast::Lit, ty_hint: Option<Ty>)
} }
ast::LitKind::Byte(n) => Uint(n as u64), ast::LitKind::Byte(n) => Uint(n as u64),
ast::LitKind::Char(n) => Uint(n as u64), ast::LitKind::Char(n) => Uint(n as u64),
ast::LitKind::Int(n, ast::SignedIntLit(_)) => Int(n as i64), ast::LitKind::Int(n, ast::LitIntType::Signed(_)) => Int(n as i64),
ast::LitKind::Int(n, ast::UnsuffixedIntLit) => { ast::LitKind::Int(n, ast::LitIntType::Unsuffixed) => {
match ty_hint.map(|ty| &ty.sty) { match ty_hint.map(|ty| &ty.sty) {
Some(&ty::TyUint(_)) => Uint(n), Some(&ty::TyUint(_)) => Uint(n),
_ => Int(n as i64) _ => Int(n as i64)
} }
} }
ast::LitKind::Int(n, ast::UnsignedIntLit(_)) => Uint(n), ast::LitKind::Int(n, ast::LitIntType::Unsigned(_)) => Uint(n),
ast::LitKind::Float(ref n, _) | ast::LitKind::Float(ref n, _) |
ast::LitKind::FloatUnsuffixed(ref n) => { ast::LitKind::FloatUnsuffixed(ref n) => {
if let Ok(x) = n.parse::<f64>() { if let Ok(x) = n.parse::<f64>() {

View File

@ -103,10 +103,10 @@ impl LateLintPass for TypeLimits {
hir::ExprUnary(hir::UnNeg, ref expr) => { hir::ExprUnary(hir::UnNeg, ref expr) => {
if let hir::ExprLit(ref lit) = expr.node { if let hir::ExprLit(ref lit) = expr.node {
match lit.node { match lit.node {
ast::LitKind::Int(_, ast::UnsignedIntLit(_)) => { ast::LitKind::Int(_, ast::LitIntType::Unsigned(_)) => {
forbid_unsigned_negation(cx, e.span); forbid_unsigned_negation(cx, e.span);
}, },
ast::LitKind::Int(_, ast::UnsuffixedIntLit) => { ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => {
if let ty::TyUint(_) = cx.tcx.node_id_to_type(e.id).sty { if let ty::TyUint(_) = cx.tcx.node_id_to_type(e.id).sty {
forbid_unsigned_negation(cx, e.span); forbid_unsigned_negation(cx, e.span);
} }
@ -159,8 +159,8 @@ impl LateLintPass for TypeLimits {
match cx.tcx.node_id_to_type(e.id).sty { match cx.tcx.node_id_to_type(e.id).sty {
ty::TyInt(t) => { ty::TyInt(t) => {
match lit.node { match lit.node {
ast::LitKind::Int(v, ast::SignedIntLit(_)) | ast::LitKind::Int(v, ast::LitIntType::Signed(_)) |
ast::LitKind::Int(v, ast::UnsuffixedIntLit) => { ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => {
let int_type = if let ast::IntTy::Is = t { let int_type = if let ast::IntTy::Is = t {
cx.sess().target.int_type cx.sess().target.int_type
} else { } else {
@ -312,8 +312,8 @@ impl LateLintPass for TypeLimits {
let (min, max) = int_ty_range(int_ty); let (min, max) = int_ty_range(int_ty);
let lit_val: i64 = match lit.node { let lit_val: i64 = match lit.node {
hir::ExprLit(ref li) => match li.node { hir::ExprLit(ref li) => match li.node {
ast::LitKind::Int(v, ast::SignedIntLit(_)) | ast::LitKind::Int(v, ast::LitIntType::Signed(_)) |
ast::LitKind::Int(v, ast::UnsuffixedIntLit) => v as i64, ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => v as i64,
_ => return true _ => return true
}, },
_ => panic!() _ => panic!()

View File

@ -66,13 +66,13 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
match lit.node { match lit.node {
LitKind::Byte(b) => C_integral(Type::uint_from_ty(cx, ast::UintTy::U8), b as u64, false), LitKind::Byte(b) => C_integral(Type::uint_from_ty(cx, ast::UintTy::U8), b as u64, false),
LitKind::Char(i) => C_integral(Type::char(cx), i as u64, false), LitKind::Char(i) => C_integral(Type::char(cx), i as u64, false),
LitKind::Int(i, ast::SignedIntLit(t)) => { LitKind::Int(i, ast::LitIntType::Signed(t)) => {
C_integral(Type::int_from_ty(cx, t), i, true) C_integral(Type::int_from_ty(cx, t), i, true)
} }
LitKind::Int(u, ast::UnsignedIntLit(t)) => { LitKind::Int(u, ast::LitIntType::Unsigned(t)) => {
C_integral(Type::uint_from_ty(cx, t), u, false) C_integral(Type::uint_from_ty(cx, t), u, false)
} }
LitKind::Int(i, ast::UnsuffixedIntLit) => { LitKind::Int(i, ast::LitIntType::Unsuffixed) => {
let lit_int_ty = cx.tcx().node_id_to_type(e.id); let lit_int_ty = cx.tcx().node_id_to_type(e.id);
match lit_int_ty.sty { match lit_int_ty.sty {
ty::TyInt(t) => { ty::TyInt(t) => {

View File

@ -2613,9 +2613,9 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
} }
ast::LitKind::Byte(_) => tcx.types.u8, ast::LitKind::Byte(_) => tcx.types.u8,
ast::LitKind::Char(_) => tcx.types.char, ast::LitKind::Char(_) => tcx.types.char,
ast::LitKind::Int(_, ast::SignedIntLit(t)) => tcx.mk_mach_int(t), ast::LitKind::Int(_, ast::LitIntType::Signed(t)) => tcx.mk_mach_int(t),
ast::LitKind::Int(_, ast::UnsignedIntLit(t)) => tcx.mk_mach_uint(t), ast::LitKind::Int(_, ast::LitIntType::Unsigned(t)) => tcx.mk_mach_uint(t),
ast::LitKind::Int(_, ast::UnsuffixedIntLit) => { ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => {
let opt_ty = expected.to_option(fcx).and_then(|ty| { let opt_ty = expected.to_option(fcx).and_then(|ty| {
match ty.sty { match ty.sty {
ty::TyInt(_) | ty::TyUint(_) => Some(ty), ty::TyInt(_) | ty::TyUint(_) => Some(ty),

View File

@ -13,7 +13,6 @@
pub use self::ForeignItem_::*; pub use self::ForeignItem_::*;
pub use self::Item_::*; pub use self::Item_::*;
pub use self::KleeneOp::*; pub use self::KleeneOp::*;
pub use self::LitIntType::*;
pub use self::MacStmtStyle::*; pub use self::MacStmtStyle::*;
pub use self::MetaItem_::*; pub use self::MetaItem_::*;
pub use self::Mutability::*; pub use self::Mutability::*;
@ -1267,9 +1266,9 @@ pub type Lit = Spanned<LitKind>;
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum LitIntType { pub enum LitIntType {
SignedIntLit(IntTy), Signed(IntTy),
UnsignedIntLit(UintTy), Unsigned(UintTy),
UnsuffixedIntLit, Unsuffixed,
} }
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]

View File

@ -680,7 +680,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
self.expr(sp, ast::ExprKind::Lit(P(respan(sp, lit)))) self.expr(sp, ast::ExprKind::Lit(P(respan(sp, lit))))
} }
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> { fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> {
self.expr_lit(span, ast::LitKind::Int(i as u64, ast::UnsignedIntLit(ast::UintTy::Us))) self.expr_lit(span, ast::LitKind::Int(i as u64, ast::LitIntType::Unsigned(ast::UintTy::Us)))
} }
fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr> { fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr> {
if i < 0 { if i < 0 {
@ -689,14 +689,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
let lit = self.expr_lit(sp, ast::LitKind::Int(i, lit_ty)); let lit = self.expr_lit(sp, ast::LitKind::Int(i, lit_ty));
self.expr_unary(sp, ast::UnOp::Neg, lit) self.expr_unary(sp, ast::UnOp::Neg, lit)
} else { } else {
self.expr_lit(sp, ast::LitKind::Int(i as u64, ast::SignedIntLit(ast::IntTy::Is))) self.expr_lit(sp, ast::LitKind::Int(i as u64, ast::LitIntType::Signed(ast::IntTy::Is)))
} }
} }
fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr> { fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitKind::Int(u as u64, ast::UnsignedIntLit(ast::UintTy::U32))) self.expr_lit(sp, ast::LitKind::Int(u as u64, ast::LitIntType::Unsigned(ast::UintTy::U32)))
} }
fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> { fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitKind::Int(u as u64, ast::UnsignedIntLit(ast::UintTy::U8))) self.expr_lit(sp, ast::LitKind::Int(u as u64, ast::LitIntType::Unsigned(ast::UintTy::U8)))
} }
fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr> { fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitKind::Bool(value)) self.expr_lit(sp, ast::LitKind::Bool(value))

View File

@ -268,7 +268,7 @@ pub mod rt {
} else { } else {
*self *self
}; };
let lit = ast::LitKind::Int(val as u64, ast::SignedIntLit($tag)); let lit = ast::LitKind::Int(val as u64, ast::LitIntType::Signed($tag));
let lit = P(ast::Expr { let lit = P(ast::Expr {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: ast::ExprKind::Lit(P(dummy_spanned(lit))), node: ast::ExprKind::Lit(P(dummy_spanned(lit))),
@ -290,7 +290,7 @@ pub mod rt {
(unsigned, $t:ty, $tag:expr) => ( (unsigned, $t:ty, $tag:expr) => (
impl ToTokens for $t { impl ToTokens for $t {
fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> { fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
let lit = ast::LitKind::Int(*self as u64, ast::UnsignedIntLit($tag)); let lit = ast::LitKind::Int(*self as u64, ast::LitIntType::Unsigned($tag));
dummy_spanned(lit).to_tokens(cx) dummy_spanned(lit).to_tokens(cx)
} }
} }

View File

@ -586,7 +586,7 @@ pub fn integer_lit(s: &str,
let mut base = 10; let mut base = 10;
let orig = s; let orig = s;
let mut ty = ast::UnsuffixedIntLit; let mut ty = ast::LitIntType::Unsuffixed;
if char_at(s, 0) == '0' && s.len() > 1 { if char_at(s, 0) == '0' && s.len() > 1 {
match char_at(s, 1) { match char_at(s, 1) {
@ -618,16 +618,16 @@ pub fn integer_lit(s: &str,
if let Some(ref suf) = suffix { if let Some(ref suf) = suffix {
if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")} if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")}
ty = match &**suf { ty = match &**suf {
"isize" => ast::SignedIntLit(ast::IntTy::Is), "isize" => ast::LitIntType::Signed(ast::IntTy::Is),
"i8" => ast::SignedIntLit(ast::IntTy::I8), "i8" => ast::LitIntType::Signed(ast::IntTy::I8),
"i16" => ast::SignedIntLit(ast::IntTy::I16), "i16" => ast::LitIntType::Signed(ast::IntTy::I16),
"i32" => ast::SignedIntLit(ast::IntTy::I32), "i32" => ast::LitIntType::Signed(ast::IntTy::I32),
"i64" => ast::SignedIntLit(ast::IntTy::I64), "i64" => ast::LitIntType::Signed(ast::IntTy::I64),
"usize" => ast::UnsignedIntLit(ast::UintTy::Us), "usize" => ast::LitIntType::Unsigned(ast::UintTy::Us),
"u8" => ast::UnsignedIntLit(ast::UintTy::U8), "u8" => ast::LitIntType::Unsigned(ast::UintTy::U8),
"u16" => ast::UnsignedIntLit(ast::UintTy::U16), "u16" => ast::LitIntType::Unsigned(ast::UintTy::U16),
"u32" => ast::UnsignedIntLit(ast::UintTy::U32), "u32" => ast::LitIntType::Unsigned(ast::UintTy::U32),
"u64" => ast::UnsignedIntLit(ast::UintTy::U64), "u64" => ast::LitIntType::Unsigned(ast::UintTy::U64),
_ => { _ => {
// i<digits> and u<digits> look like widths, so lets // i<digits> and u<digits> look like widths, so lets
// give an error message along those lines // give an error message along those lines

View File

@ -2014,7 +2014,7 @@ impl<'a> Parser<'a> {
pub fn mk_lit_u32(&mut self, i: u32, attrs: ThinAttributes) -> P<Expr> { pub fn mk_lit_u32(&mut self, i: u32, attrs: ThinAttributes) -> P<Expr> {
let span = &self.span; let span = &self.span;
let lv_lit = P(codemap::Spanned { let lv_lit = P(codemap::Spanned {
node: LitKind::Int(i as u64, ast::UnsignedIntLit(UintTy::U32)), node: LitKind::Int(i as u64, ast::LitIntType::Unsigned(UintTy::U32)),
span: *span span: *span
}); });

View File

@ -645,14 +645,14 @@ pub trait PrintState<'a> {
} }
ast::LitKind::Int(i, t) => { ast::LitKind::Int(i, t) => {
match t { match t {
ast::SignedIntLit(st) => { ast::LitIntType::Signed(st) => {
word(self.writer(), word(self.writer(),
&st.val_to_string(i as i64)) &st.val_to_string(i as i64))
} }
ast::UnsignedIntLit(ut) => { ast::LitIntType::Unsigned(ut) => {
word(self.writer(), &ut.val_to_string(i)) word(self.writer(), &ut.val_to_string(i))
} }
ast::UnsuffixedIntLit => { ast::LitIntType::Unsuffixed => {
word(self.writer(), &format!("{}", i)) word(self.writer(), &format!("{}", i))
} }
} }

View File

@ -37,9 +37,9 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
ast::LitKind::Char(c) => { ast::LitKind::Char(c) => {
accumulator.push(c); accumulator.push(c);
} }
ast::LitKind::Int(i, ast::UnsignedIntLit(_)) | ast::LitKind::Int(i, ast::LitIntType::Unsigned(_)) |
ast::LitKind::Int(i, ast::SignedIntLit(_)) | ast::LitKind::Int(i, ast::LitIntType::Signed(_)) |
ast::LitKind::Int(i, ast::UnsuffixedIntLit) => { ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) => {
accumulator.push_str(&format!("{}", i)); accumulator.push_str(&format!("{}", i));
} }
ast::LitKind::Bool(b) => { ast::LitKind::Bool(b) => {