Skip to content

Commit 498a2e4

Browse files
committed
[breaking-change] don't pub export ast::IntLitType variants
1 parent 69072c4 commit 498a2e4

File tree

11 files changed

+42
-43
lines changed

11 files changed

+42
-43
lines changed

src/librustc/middle/const_eval.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,14 +1328,14 @@ fn lit_to_const(sess: &Session, span: Span, lit: &ast::Lit, ty_hint: Option<Ty>)
13281328
}
13291329
ast::LitKind::Byte(n) => Uint(n as u64),
13301330
ast::LitKind::Char(n) => Uint(n as u64),
1331-
ast::LitKind::Int(n, ast::SignedIntLit(_)) => Int(n as i64),
1332-
ast::LitKind::Int(n, ast::UnsuffixedIntLit) => {
1331+
ast::LitKind::Int(n, ast::LitIntType::Signed(_)) => Int(n as i64),
1332+
ast::LitKind::Int(n, ast::LitIntType::Unsuffixed) => {
13331333
match ty_hint.map(|ty| &ty.sty) {
13341334
Some(&ty::TyUint(_)) => Uint(n),
13351335
_ => Int(n as i64)
13361336
}
13371337
}
1338-
ast::LitKind::Int(n, ast::UnsignedIntLit(_)) => Uint(n),
1338+
ast::LitKind::Int(n, ast::LitIntType::Unsigned(_)) => Uint(n),
13391339
ast::LitKind::Float(ref n, _) |
13401340
ast::LitKind::FloatUnsuffixed(ref n) => {
13411341
if let Ok(x) = n.parse::<f64>() {

src/librustc_lint/types.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ impl LateLintPass for TypeLimits {
103103
hir::ExprUnary(hir::UnNeg, ref expr) => {
104104
if let hir::ExprLit(ref lit) = expr.node {
105105
match lit.node {
106-
ast::LitKind::Int(_, ast::UnsignedIntLit(_)) => {
106+
ast::LitKind::Int(_, ast::LitIntType::Unsigned(_)) => {
107107
forbid_unsigned_negation(cx, e.span);
108108
},
109-
ast::LitKind::Int(_, ast::UnsuffixedIntLit) => {
109+
ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => {
110110
if let ty::TyUint(_) = cx.tcx.node_id_to_type(e.id).sty {
111111
forbid_unsigned_negation(cx, e.span);
112112
}
@@ -159,8 +159,8 @@ impl LateLintPass for TypeLimits {
159159
match cx.tcx.node_id_to_type(e.id).sty {
160160
ty::TyInt(t) => {
161161
match lit.node {
162-
ast::LitKind::Int(v, ast::SignedIntLit(_)) |
163-
ast::LitKind::Int(v, ast::UnsuffixedIntLit) => {
162+
ast::LitKind::Int(v, ast::LitIntType::Signed(_)) |
163+
ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => {
164164
let int_type = if let ast::IntTy::Is = t {
165165
cx.sess().target.int_type
166166
} else {
@@ -312,8 +312,8 @@ impl LateLintPass for TypeLimits {
312312
let (min, max) = int_ty_range(int_ty);
313313
let lit_val: i64 = match lit.node {
314314
hir::ExprLit(ref li) => match li.node {
315-
ast::LitKind::Int(v, ast::SignedIntLit(_)) |
316-
ast::LitKind::Int(v, ast::UnsuffixedIntLit) => v as i64,
315+
ast::LitKind::Int(v, ast::LitIntType::Signed(_)) |
316+
ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => v as i64,
317317
_ => return true
318318
},
319319
_ => panic!()

src/librustc_trans/trans/consts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
6666
match lit.node {
6767
LitKind::Byte(b) => C_integral(Type::uint_from_ty(cx, ast::UintTy::U8), b as u64, false),
6868
LitKind::Char(i) => C_integral(Type::char(cx), i as u64, false),
69-
LitKind::Int(i, ast::SignedIntLit(t)) => {
69+
LitKind::Int(i, ast::LitIntType::Signed(t)) => {
7070
C_integral(Type::int_from_ty(cx, t), i, true)
7171
}
72-
LitKind::Int(u, ast::UnsignedIntLit(t)) => {
72+
LitKind::Int(u, ast::LitIntType::Unsigned(t)) => {
7373
C_integral(Type::uint_from_ty(cx, t), u, false)
7474
}
75-
LitKind::Int(i, ast::UnsuffixedIntLit) => {
75+
LitKind::Int(i, ast::LitIntType::Unsuffixed) => {
7676
let lit_int_ty = cx.tcx().node_id_to_type(e.id);
7777
match lit_int_ty.sty {
7878
ty::TyInt(t) => {

src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,9 +2613,9 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
26132613
}
26142614
ast::LitKind::Byte(_) => tcx.types.u8,
26152615
ast::LitKind::Char(_) => tcx.types.char,
2616-
ast::LitKind::Int(_, ast::SignedIntLit(t)) => tcx.mk_mach_int(t),
2617-
ast::LitKind::Int(_, ast::UnsignedIntLit(t)) => tcx.mk_mach_uint(t),
2618-
ast::LitKind::Int(_, ast::UnsuffixedIntLit) => {
2616+
ast::LitKind::Int(_, ast::LitIntType::Signed(t)) => tcx.mk_mach_int(t),
2617+
ast::LitKind::Int(_, ast::LitIntType::Unsigned(t)) => tcx.mk_mach_uint(t),
2618+
ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => {
26192619
let opt_ty = expected.to_option(fcx).and_then(|ty| {
26202620
match ty.sty {
26212621
ty::TyInt(_) | ty::TyUint(_) => Some(ty),

src/libsyntax/ast.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
pub use self::ForeignItem_::*;
1414
pub use self::Item_::*;
1515
pub use self::KleeneOp::*;
16-
pub use self::LitIntType::*;
1716
pub use self::MacStmtStyle::*;
1817
pub use self::MetaItem_::*;
1918
pub use self::Mutability::*;
@@ -1267,9 +1266,9 @@ pub type Lit = Spanned<LitKind>;
12671266

12681267
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
12691268
pub enum LitIntType {
1270-
SignedIntLit(IntTy),
1271-
UnsignedIntLit(UintTy),
1272-
UnsuffixedIntLit,
1269+
Signed(IntTy),
1270+
Unsigned(UintTy),
1271+
Unsuffixed,
12731272
}
12741273

12751274
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]

src/libsyntax/ext/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
680680
self.expr(sp, ast::ExprKind::Lit(P(respan(sp, lit))))
681681
}
682682
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> {
683-
self.expr_lit(span, ast::LitKind::Int(i as u64, ast::UnsignedIntLit(ast::UintTy::Us)))
683+
self.expr_lit(span, ast::LitKind::Int(i as u64, ast::LitIntType::Unsigned(ast::UintTy::Us)))
684684
}
685685
fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr> {
686686
if i < 0 {
@@ -689,14 +689,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
689689
let lit = self.expr_lit(sp, ast::LitKind::Int(i, lit_ty));
690690
self.expr_unary(sp, ast::UnOp::Neg, lit)
691691
} else {
692-
self.expr_lit(sp, ast::LitKind::Int(i as u64, ast::SignedIntLit(ast::IntTy::Is)))
692+
self.expr_lit(sp, ast::LitKind::Int(i as u64, ast::LitIntType::Signed(ast::IntTy::Is)))
693693
}
694694
}
695695
fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr> {
696-
self.expr_lit(sp, ast::LitKind::Int(u as u64, ast::UnsignedIntLit(ast::UintTy::U32)))
696+
self.expr_lit(sp, ast::LitKind::Int(u as u64, ast::LitIntType::Unsigned(ast::UintTy::U32)))
697697
}
698698
fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> {
699-
self.expr_lit(sp, ast::LitKind::Int(u as u64, ast::UnsignedIntLit(ast::UintTy::U8)))
699+
self.expr_lit(sp, ast::LitKind::Int(u as u64, ast::LitIntType::Unsigned(ast::UintTy::U8)))
700700
}
701701
fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr> {
702702
self.expr_lit(sp, ast::LitKind::Bool(value))

src/libsyntax/ext/quote.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ pub mod rt {
268268
} else {
269269
*self
270270
};
271-
let lit = ast::LitKind::Int(val as u64, ast::SignedIntLit($tag));
271+
let lit = ast::LitKind::Int(val as u64, ast::LitIntType::Signed($tag));
272272
let lit = P(ast::Expr {
273273
id: ast::DUMMY_NODE_ID,
274274
node: ast::ExprKind::Lit(P(dummy_spanned(lit))),
@@ -290,7 +290,7 @@ pub mod rt {
290290
(unsigned, $t:ty, $tag:expr) => (
291291
impl ToTokens for $t {
292292
fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
293-
let lit = ast::LitKind::Int(*self as u64, ast::UnsignedIntLit($tag));
293+
let lit = ast::LitKind::Int(*self as u64, ast::LitIntType::Unsigned($tag));
294294
dummy_spanned(lit).to_tokens(cx)
295295
}
296296
}

src/libsyntax/parse/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ pub fn integer_lit(s: &str,
586586

587587
let mut base = 10;
588588
let orig = s;
589-
let mut ty = ast::UnsuffixedIntLit;
589+
let mut ty = ast::LitIntType::Unsuffixed;
590590

591591
if char_at(s, 0) == '0' && s.len() > 1 {
592592
match char_at(s, 1) {
@@ -618,16 +618,16 @@ pub fn integer_lit(s: &str,
618618
if let Some(ref suf) = suffix {
619619
if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")}
620620
ty = match &**suf {
621-
"isize" => ast::SignedIntLit(ast::IntTy::Is),
622-
"i8" => ast::SignedIntLit(ast::IntTy::I8),
623-
"i16" => ast::SignedIntLit(ast::IntTy::I16),
624-
"i32" => ast::SignedIntLit(ast::IntTy::I32),
625-
"i64" => ast::SignedIntLit(ast::IntTy::I64),
626-
"usize" => ast::UnsignedIntLit(ast::UintTy::Us),
627-
"u8" => ast::UnsignedIntLit(ast::UintTy::U8),
628-
"u16" => ast::UnsignedIntLit(ast::UintTy::U16),
629-
"u32" => ast::UnsignedIntLit(ast::UintTy::U32),
630-
"u64" => ast::UnsignedIntLit(ast::UintTy::U64),
621+
"isize" => ast::LitIntType::Signed(ast::IntTy::Is),
622+
"i8" => ast::LitIntType::Signed(ast::IntTy::I8),
623+
"i16" => ast::LitIntType::Signed(ast::IntTy::I16),
624+
"i32" => ast::LitIntType::Signed(ast::IntTy::I32),
625+
"i64" => ast::LitIntType::Signed(ast::IntTy::I64),
626+
"usize" => ast::LitIntType::Unsigned(ast::UintTy::Us),
627+
"u8" => ast::LitIntType::Unsigned(ast::UintTy::U8),
628+
"u16" => ast::LitIntType::Unsigned(ast::UintTy::U16),
629+
"u32" => ast::LitIntType::Unsigned(ast::UintTy::U32),
630+
"u64" => ast::LitIntType::Unsigned(ast::UintTy::U64),
631631
_ => {
632632
// i<digits> and u<digits> look like widths, so lets
633633
// give an error message along those lines

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,7 @@ impl<'a> Parser<'a> {
20142014
pub fn mk_lit_u32(&mut self, i: u32, attrs: ThinAttributes) -> P<Expr> {
20152015
let span = &self.span;
20162016
let lv_lit = P(codemap::Spanned {
2017-
node: LitKind::Int(i as u64, ast::UnsignedIntLit(UintTy::U32)),
2017+
node: LitKind::Int(i as u64, ast::LitIntType::Unsigned(UintTy::U32)),
20182018
span: *span
20192019
});
20202020

src/libsyntax/print/pprust.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,14 +645,14 @@ pub trait PrintState<'a> {
645645
}
646646
ast::LitKind::Int(i, t) => {
647647
match t {
648-
ast::SignedIntLit(st) => {
648+
ast::LitIntType::Signed(st) => {
649649
word(self.writer(),
650650
&st.val_to_string(i as i64))
651651
}
652-
ast::UnsignedIntLit(ut) => {
652+
ast::LitIntType::Unsigned(ut) => {
653653
word(self.writer(), &ut.val_to_string(i))
654654
}
655-
ast::UnsuffixedIntLit => {
655+
ast::LitIntType::Unsuffixed => {
656656
word(self.writer(), &format!("{}", i))
657657
}
658658
}

0 commit comments

Comments
 (0)