mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
[breaking-change] don't pub export ast::IntLitType variants
This commit is contained in:
parent
69072c4f5d
commit
498a2e416e
@ -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::Char(n) => Uint(n as u64),
|
||||
ast::LitKind::Int(n, ast::SignedIntLit(_)) => Int(n as i64),
|
||||
ast::LitKind::Int(n, ast::UnsuffixedIntLit) => {
|
||||
ast::LitKind::Int(n, ast::LitIntType::Signed(_)) => Int(n as i64),
|
||||
ast::LitKind::Int(n, ast::LitIntType::Unsuffixed) => {
|
||||
match ty_hint.map(|ty| &ty.sty) {
|
||||
Some(&ty::TyUint(_)) => Uint(n),
|
||||
_ => 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::FloatUnsuffixed(ref n) => {
|
||||
if let Ok(x) = n.parse::<f64>() {
|
||||
|
@ -103,10 +103,10 @@ impl LateLintPass for TypeLimits {
|
||||
hir::ExprUnary(hir::UnNeg, ref expr) => {
|
||||
if let hir::ExprLit(ref lit) = expr.node {
|
||||
match lit.node {
|
||||
ast::LitKind::Int(_, ast::UnsignedIntLit(_)) => {
|
||||
ast::LitKind::Int(_, ast::LitIntType::Unsigned(_)) => {
|
||||
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 {
|
||||
forbid_unsigned_negation(cx, e.span);
|
||||
}
|
||||
@ -159,8 +159,8 @@ impl LateLintPass for TypeLimits {
|
||||
match cx.tcx.node_id_to_type(e.id).sty {
|
||||
ty::TyInt(t) => {
|
||||
match lit.node {
|
||||
ast::LitKind::Int(v, ast::SignedIntLit(_)) |
|
||||
ast::LitKind::Int(v, ast::UnsuffixedIntLit) => {
|
||||
ast::LitKind::Int(v, ast::LitIntType::Signed(_)) |
|
||||
ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => {
|
||||
let int_type = if let ast::IntTy::Is = t {
|
||||
cx.sess().target.int_type
|
||||
} else {
|
||||
@ -312,8 +312,8 @@ impl LateLintPass for TypeLimits {
|
||||
let (min, max) = int_ty_range(int_ty);
|
||||
let lit_val: i64 = match lit.node {
|
||||
hir::ExprLit(ref li) => match li.node {
|
||||
ast::LitKind::Int(v, ast::SignedIntLit(_)) |
|
||||
ast::LitKind::Int(v, ast::UnsuffixedIntLit) => v as i64,
|
||||
ast::LitKind::Int(v, ast::LitIntType::Signed(_)) |
|
||||
ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => v as i64,
|
||||
_ => return true
|
||||
},
|
||||
_ => panic!()
|
||||
|
@ -66,13 +66,13 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
|
||||
match lit.node {
|
||||
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::Int(i, ast::SignedIntLit(t)) => {
|
||||
LitKind::Int(i, ast::LitIntType::Signed(t)) => {
|
||||
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)
|
||||
}
|
||||
LitKind::Int(i, ast::UnsuffixedIntLit) => {
|
||||
LitKind::Int(i, ast::LitIntType::Unsuffixed) => {
|
||||
let lit_int_ty = cx.tcx().node_id_to_type(e.id);
|
||||
match lit_int_ty.sty {
|
||||
ty::TyInt(t) => {
|
||||
|
@ -2613,9 +2613,9 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
}
|
||||
ast::LitKind::Byte(_) => tcx.types.u8,
|
||||
ast::LitKind::Char(_) => tcx.types.char,
|
||||
ast::LitKind::Int(_, ast::SignedIntLit(t)) => tcx.mk_mach_int(t),
|
||||
ast::LitKind::Int(_, ast::UnsignedIntLit(t)) => tcx.mk_mach_uint(t),
|
||||
ast::LitKind::Int(_, ast::UnsuffixedIntLit) => {
|
||||
ast::LitKind::Int(_, ast::LitIntType::Signed(t)) => tcx.mk_mach_int(t),
|
||||
ast::LitKind::Int(_, ast::LitIntType::Unsigned(t)) => tcx.mk_mach_uint(t),
|
||||
ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => {
|
||||
let opt_ty = expected.to_option(fcx).and_then(|ty| {
|
||||
match ty.sty {
|
||||
ty::TyInt(_) | ty::TyUint(_) => Some(ty),
|
||||
|
@ -13,7 +13,6 @@
|
||||
pub use self::ForeignItem_::*;
|
||||
pub use self::Item_::*;
|
||||
pub use self::KleeneOp::*;
|
||||
pub use self::LitIntType::*;
|
||||
pub use self::MacStmtStyle::*;
|
||||
pub use self::MetaItem_::*;
|
||||
pub use self::Mutability::*;
|
||||
@ -1267,9 +1266,9 @@ pub type Lit = Spanned<LitKind>;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
||||
pub enum LitIntType {
|
||||
SignedIntLit(IntTy),
|
||||
UnsignedIntLit(UintTy),
|
||||
UnsuffixedIntLit,
|
||||
Signed(IntTy),
|
||||
Unsigned(UintTy),
|
||||
Unsuffixed,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
|
@ -680,7 +680,7 @@ 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::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> {
|
||||
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));
|
||||
self.expr_unary(sp, ast::UnOp::Neg, lit)
|
||||
} 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> {
|
||||
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> {
|
||||
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> {
|
||||
self.expr_lit(sp, ast::LitKind::Bool(value))
|
||||
|
@ -268,7 +268,7 @@ pub mod rt {
|
||||
} else {
|
||||
*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 {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::ExprKind::Lit(P(dummy_spanned(lit))),
|
||||
@ -290,7 +290,7 @@ pub mod rt {
|
||||
(unsigned, $t:ty, $tag:expr) => (
|
||||
impl ToTokens for $t {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ pub fn integer_lit(s: &str,
|
||||
|
||||
let mut base = 10;
|
||||
let orig = s;
|
||||
let mut ty = ast::UnsuffixedIntLit;
|
||||
let mut ty = ast::LitIntType::Unsuffixed;
|
||||
|
||||
if char_at(s, 0) == '0' && s.len() > 1 {
|
||||
match char_at(s, 1) {
|
||||
@ -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::IntTy::Is),
|
||||
"i8" => ast::SignedIntLit(ast::IntTy::I8),
|
||||
"i16" => ast::SignedIntLit(ast::IntTy::I16),
|
||||
"i32" => ast::SignedIntLit(ast::IntTy::I32),
|
||||
"i64" => ast::SignedIntLit(ast::IntTy::I64),
|
||||
"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),
|
||||
"isize" => ast::LitIntType::Signed(ast::IntTy::Is),
|
||||
"i8" => ast::LitIntType::Signed(ast::IntTy::I8),
|
||||
"i16" => ast::LitIntType::Signed(ast::IntTy::I16),
|
||||
"i32" => ast::LitIntType::Signed(ast::IntTy::I32),
|
||||
"i64" => ast::LitIntType::Signed(ast::IntTy::I64),
|
||||
"usize" => ast::LitIntType::Unsigned(ast::UintTy::Us),
|
||||
"u8" => ast::LitIntType::Unsigned(ast::UintTy::U8),
|
||||
"u16" => ast::LitIntType::Unsigned(ast::UintTy::U16),
|
||||
"u32" => ast::LitIntType::Unsigned(ast::UintTy::U32),
|
||||
"u64" => ast::LitIntType::Unsigned(ast::UintTy::U64),
|
||||
_ => {
|
||||
// i<digits> and u<digits> look like widths, so lets
|
||||
// give an error message along those lines
|
||||
|
@ -2014,7 +2014,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: LitKind::Int(i as u64, ast::UnsignedIntLit(UintTy::U32)),
|
||||
node: LitKind::Int(i as u64, ast::LitIntType::Unsigned(UintTy::U32)),
|
||||
span: *span
|
||||
});
|
||||
|
||||
|
@ -645,14 +645,14 @@ pub trait PrintState<'a> {
|
||||
}
|
||||
ast::LitKind::Int(i, t) => {
|
||||
match t {
|
||||
ast::SignedIntLit(st) => {
|
||||
ast::LitIntType::Signed(st) => {
|
||||
word(self.writer(),
|
||||
&st.val_to_string(i as i64))
|
||||
}
|
||||
ast::UnsignedIntLit(ut) => {
|
||||
ast::LitIntType::Unsigned(ut) => {
|
||||
word(self.writer(), &ut.val_to_string(i))
|
||||
}
|
||||
ast::UnsuffixedIntLit => {
|
||||
ast::LitIntType::Unsuffixed => {
|
||||
word(self.writer(), &format!("{}", i))
|
||||
}
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
|
||||
ast::LitKind::Char(c) => {
|
||||
accumulator.push(c);
|
||||
}
|
||||
ast::LitKind::Int(i, ast::UnsignedIntLit(_)) |
|
||||
ast::LitKind::Int(i, ast::SignedIntLit(_)) |
|
||||
ast::LitKind::Int(i, ast::UnsuffixedIntLit) => {
|
||||
ast::LitKind::Int(i, ast::LitIntType::Unsigned(_)) |
|
||||
ast::LitKind::Int(i, ast::LitIntType::Signed(_)) |
|
||||
ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) => {
|
||||
accumulator.push_str(&format!("{}", i));
|
||||
}
|
||||
ast::LitKind::Bool(b) => {
|
||||
|
Loading…
Reference in New Issue
Block a user