Skip to content

Commit 69072c4

Browse files
committed
[breaking-change] don't pub export ast::Lit_ variants
1 parent 05d4cef commit 69072c4

File tree

26 files changed

+142
-142
lines changed

26 files changed

+142
-142
lines changed

src/librustc/middle/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
421421

422422
fn const_val_to_expr(value: &ConstVal) -> P<hir::Expr> {
423423
let node = match value {
424-
&ConstVal::Bool(b) => ast::LitBool(b),
424+
&ConstVal::Bool(b) => ast::LitKind::Bool(b),
425425
_ => unreachable!()
426426
};
427427
P(hir::Expr {

src/librustc/middle/const_eval.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,30 +1322,30 @@ fn cast_const<'tcx>(tcx: &ty::ctxt<'tcx>, val: ConstVal, ty: Ty) -> CastResult {
13221322

13231323
fn lit_to_const(sess: &Session, span: Span, lit: &ast::Lit, ty_hint: Option<Ty>) -> ConstVal {
13241324
match lit.node {
1325-
ast::LitStr(ref s, _) => Str((*s).clone()),
1326-
ast::LitByteStr(ref data) => {
1325+
ast::LitKind::Str(ref s, _) => Str((*s).clone()),
1326+
ast::LitKind::ByteStr(ref data) => {
13271327
ByteStr(data.clone())
13281328
}
1329-
ast::LitByte(n) => Uint(n as u64),
1330-
ast::LitChar(n) => Uint(n as u64),
1331-
ast::LitInt(n, ast::SignedIntLit(_)) => Int(n as i64),
1332-
ast::LitInt(n, ast::UnsuffixedIntLit) => {
1329+
ast::LitKind::Byte(n) => Uint(n as u64),
1330+
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) => {
13331333
match ty_hint.map(|ty| &ty.sty) {
13341334
Some(&ty::TyUint(_)) => Uint(n),
13351335
_ => Int(n as i64)
13361336
}
13371337
}
1338-
ast::LitInt(n, ast::UnsignedIntLit(_)) => Uint(n),
1339-
ast::LitFloat(ref n, _) |
1340-
ast::LitFloatUnsuffixed(ref n) => {
1338+
ast::LitKind::Int(n, ast::UnsignedIntLit(_)) => Uint(n),
1339+
ast::LitKind::Float(ref n, _) |
1340+
ast::LitKind::FloatUnsuffixed(ref n) => {
13411341
if let Ok(x) = n.parse::<f64>() {
13421342
Float(x)
13431343
} else {
13441344
// FIXME(#31407) this is only necessary because float parsing is buggy
13451345
sess.span_bug(span, "could not evaluate float literal (see issue #31407)");
13461346
}
13471347
}
1348-
ast::LitBool(b) => Bool(b)
1348+
ast::LitKind::Bool(b) => Bool(b)
13491349
}
13501350
}
13511351

src/librustc_back/svh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ mod svh_visitor {
232232
SawExprTup,
233233
SawExprBinary(hir::BinOp_),
234234
SawExprUnary(hir::UnOp),
235-
SawExprLit(ast::Lit_),
235+
SawExprLit(ast::LitKind),
236236
SawExprCast,
237237
SawExprType,
238238
SawExprIf,

src/librustc_driver/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ impl RustcDefaultCalls {
563563
ast::MetaWord(ref word) => println!("{}", word),
564564
ast::MetaNameValue(ref name, ref value) => {
565565
println!("{}=\"{}\"", name, match value.node {
566-
ast::LitStr(ref s, _) => s,
566+
ast::LitKind::Str(ref s, _) => s,
567567
_ => continue,
568568
});
569569
}

src/librustc_lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl LateLintPass for WhileTrue {
7373
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
7474
if let hir::ExprWhile(ref cond, _, _) = e.node {
7575
if let hir::ExprLit(ref lit) = cond.node {
76-
if let ast::LitBool(true) = lit.node {
76+
if let ast::LitKind::Bool(true) = lit.node {
7777
cx.span_lint(WHILE_TRUE, e.span,
7878
"denote infinite loops with loop { ... }");
7979
}

src/librustc_lint/types.rs

Lines changed: 13 additions & 12 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::LitInt(_, ast::UnsignedIntLit(_)) => {
106+
ast::LitKind::Int(_, ast::UnsignedIntLit(_)) => {
107107
forbid_unsigned_negation(cx, e.span);
108108
},
109-
ast::LitInt(_, ast::UnsuffixedIntLit) => {
109+
ast::LitKind::Int(_, ast::UnsuffixedIntLit) => {
110110
if let ty::TyUint(_) = cx.tcx.node_id_to_type(e.id).sty {
111111
forbid_unsigned_negation(cx, e.span);
112112
}
@@ -139,7 +139,7 @@ impl LateLintPass for TypeLimits {
139139

140140
if let Some(bits) = opt_ty_bits {
141141
let exceeding = if let hir::ExprLit(ref lit) = r.node {
142-
if let ast::LitInt(shift, _) = lit.node { shift >= bits }
142+
if let ast::LitKind::Int(shift, _) = lit.node { shift >= bits }
143143
else { false }
144144
} else {
145145
match eval_const_expr_partial(cx.tcx, &r, ExprTypeChecked, None) {
@@ -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::LitInt(v, ast::SignedIntLit(_)) |
163-
ast::LitInt(v, ast::UnsuffixedIntLit) => {
162+
ast::LitKind::Int(v, ast::SignedIntLit(_)) |
163+
ast::LitKind::Int(v, ast::UnsuffixedIntLit) => {
164164
let int_type = if let ast::IntTy::Is = t {
165165
cx.sess().target.int_type
166166
} else {
@@ -189,8 +189,9 @@ impl LateLintPass for TypeLimits {
189189
};
190190
let (min, max) = uint_ty_range(uint_type);
191191
let lit_val: u64 = match lit.node {
192-
ast::LitByte(_v) => return, // _v is u8, within range by definition
193-
ast::LitInt(v, _) => v,
192+
// _v is u8, within range by definition
193+
ast::LitKind::Byte(_v) => return,
194+
ast::LitKind::Int(v, _) => v,
194195
_ => panic!()
195196
};
196197
if lit_val < min || lit_val > max {
@@ -201,8 +202,8 @@ impl LateLintPass for TypeLimits {
201202
ty::TyFloat(t) => {
202203
let (min, max) = float_ty_range(t);
203204
let lit_val: f64 = match lit.node {
204-
ast::LitFloat(ref v, _) |
205-
ast::LitFloatUnsuffixed(ref v) => {
205+
ast::LitKind::Float(ref v, _) |
206+
ast::LitKind::FloatUnsuffixed(ref v) => {
206207
match v.parse() {
207208
Ok(f) => f,
208209
Err(_) => return
@@ -311,8 +312,8 @@ impl LateLintPass for TypeLimits {
311312
let (min, max) = int_ty_range(int_ty);
312313
let lit_val: i64 = match lit.node {
313314
hir::ExprLit(ref li) => match li.node {
314-
ast::LitInt(v, ast::SignedIntLit(_)) |
315-
ast::LitInt(v, ast::UnsuffixedIntLit) => v as i64,
315+
ast::LitKind::Int(v, ast::SignedIntLit(_)) |
316+
ast::LitKind::Int(v, ast::UnsuffixedIntLit) => v as i64,
316317
_ => return true
317318
},
318319
_ => panic!()
@@ -323,7 +324,7 @@ impl LateLintPass for TypeLimits {
323324
let (min, max): (u64, u64) = uint_ty_range(uint_ty);
324325
let lit_val: u64 = match lit.node {
325326
hir::ExprLit(ref li) => match li.node {
326-
ast::LitInt(v, _) => v,
327+
ast::LitKind::Int(v, _) => v,
327328
_ => return true
328329
},
329330
_ => panic!()

src/librustc_metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
15481548
}
15491549
ast::MetaNameValue(ref name, ref value) => {
15501550
match value.node {
1551-
ast::LitStr(ref value, _) => {
1551+
ast::LitKind::Str(ref value, _) => {
15521552
rbml_w.start_tag(tag_meta_item_name_value);
15531553
rbml_w.wr_tagged_str(tag_meta_item_name, name);
15541554
rbml_w.wr_tagged_str(tag_meta_item_value, value);

src/librustc_trans/trans/consts.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use rustc_front::hir;
5252
use std::ffi::{CStr, CString};
5353
use std::borrow::Cow;
5454
use libc::c_uint;
55-
use syntax::ast;
55+
use syntax::ast::{self, LitKind};
5656
use syntax::attr;
5757
use syntax::parse::token;
5858
use syntax::ptr::P;
@@ -64,15 +64,15 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
6464
let _icx = push_ctxt("trans_lit");
6565
debug!("const_lit: {:?}", lit);
6666
match lit.node {
67-
ast::LitByte(b) => C_integral(Type::uint_from_ty(cx, ast::UintTy::U8), b as u64, false),
68-
ast::LitChar(i) => C_integral(Type::char(cx), i as u64, false),
69-
ast::LitInt(i, ast::SignedIntLit(t)) => {
67+
LitKind::Byte(b) => C_integral(Type::uint_from_ty(cx, ast::UintTy::U8), b as u64, false),
68+
LitKind::Char(i) => C_integral(Type::char(cx), i as u64, false),
69+
LitKind::Int(i, ast::SignedIntLit(t)) => {
7070
C_integral(Type::int_from_ty(cx, t), i, true)
7171
}
72-
ast::LitInt(u, ast::UnsignedIntLit(t)) => {
72+
LitKind::Int(u, ast::UnsignedIntLit(t)) => {
7373
C_integral(Type::uint_from_ty(cx, t), u, false)
7474
}
75-
ast::LitInt(i, ast::UnsuffixedIntLit) => {
75+
LitKind::Int(i, ast::UnsuffixedIntLit) => {
7676
let lit_int_ty = cx.tcx().node_id_to_type(e.id);
7777
match lit_int_ty.sty {
7878
ty::TyInt(t) => {
@@ -87,10 +87,10 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
8787
lit_int_ty))
8888
}
8989
}
90-
ast::LitFloat(ref fs, t) => {
90+
LitKind::Float(ref fs, t) => {
9191
C_floating(&fs, Type::float_from_ty(cx, t))
9292
}
93-
ast::LitFloatUnsuffixed(ref fs) => {
93+
LitKind::FloatUnsuffixed(ref fs) => {
9494
let lit_float_ty = cx.tcx().node_id_to_type(e.id);
9595
match lit_float_ty.sty {
9696
ty::TyFloat(t) => {
@@ -102,9 +102,9 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
102102
}
103103
}
104104
}
105-
ast::LitBool(b) => C_bool(cx, b),
106-
ast::LitStr(ref s, _) => C_str_slice(cx, (*s).clone()),
107-
ast::LitByteStr(ref data) => {
105+
LitKind::Bool(b) => C_bool(cx, b),
106+
LitKind::Str(ref s, _) => C_str_slice(cx, (*s).clone()),
107+
LitKind::ByteStr(ref data) => {
108108
addr_of(cx, C_bytes(cx, &data[..]), 1, "byte_str")
109109
}
110110
}

src/librustc_trans/trans/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
11531153
}
11541154
hir::ExprLit(ref lit) => {
11551155
match lit.node {
1156-
ast::LitStr(ref s, _) => {
1156+
ast::LitKind::Str(ref s, _) => {
11571157
tvec::trans_lit_str(bcx, expr, (*s).clone(), dest)
11581158
}
11591159
_ => {

src/librustc_trans/trans/tvec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
9292

9393
// Handle the "..." case (returns a slice since strings are always unsized):
9494
if let hir::ExprLit(ref lit) = content_expr.node {
95-
if let ast::LitStr(ref s, _) = lit.node {
95+
if let ast::LitKind::Str(ref s, _) = lit.node {
9696
let scratch = rvalue_scratch_datum(bcx, vec_ty, "");
9797
bcx = trans_lit_str(bcx,
9898
content_expr,
@@ -180,7 +180,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
180180
match content_expr.node {
181181
hir::ExprLit(ref lit) => {
182182
match lit.node {
183-
ast::LitStr(ref s, _) => {
183+
ast::LitKind::Str(ref s, _) => {
184184
match dest {
185185
Ignore => return bcx,
186186
SaveIn(lldest) => {
@@ -276,7 +276,7 @@ fn elements_required(bcx: Block, content_expr: &hir::Expr) -> usize {
276276
match content_expr.node {
277277
hir::ExprLit(ref lit) => {
278278
match lit.node {
279-
ast::LitStr(ref s, _) => s.len(),
279+
ast::LitKind::Str(ref s, _) => s.len(),
280280
_ => {
281281
bcx.tcx().sess.span_bug(content_expr.span,
282282
"unexpected evec content")

0 commit comments

Comments
 (0)