From 79fa657abc6b8885ceb4023099b4e0026c5ef28f Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 8 Feb 2016 15:34:47 +0100 Subject: [breaking-change] don't glob export ast::Decl_ variants --- src/libsyntax_ext/deriving/debug.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsyntax_ext/deriving/debug.rs') diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 008067f39a3..3c36ce57d18 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -151,6 +151,6 @@ fn stmt_let_undescore(cx: &mut ExtCtxt, span: sp, attrs: None, }); - let decl = respan(sp, ast::DeclLocal(local)); + let decl = respan(sp, ast::DeclKind::Local(local)); P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID))) } -- cgit 1.4.1-3-g733a5 From 69072c4f5d18d7a1762fbfb007b0ba3d6b59ad33 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 8 Feb 2016 17:06:20 +0100 Subject: [breaking-change] don't pub export ast::Lit_ variants --- src/librustc/middle/check_match.rs | 2 +- src/librustc/middle/const_eval.rs | 20 ++++++++++---------- src/librustc_back/svh.rs | 2 +- src/librustc_driver/lib.rs | 2 +- src/librustc_lint/builtin.rs | 2 +- src/librustc_lint/types.rs | 25 +++++++++++++------------ src/librustc_metadata/encoder.rs | 2 +- src/librustc_trans/trans/consts.rs | 22 +++++++++++----------- src/librustc_trans/trans/expr.rs | 2 +- src/librustc_trans/trans/tvec.rs | 6 +++--- src/librustc_typeck/check/_match.rs | 2 +- src/librustc_typeck/check/mod.rs | 20 ++++++++++---------- src/librustdoc/clean/mod.rs | 16 ++++++++-------- src/libsyntax/ast.rs | 25 ++++++++++++------------- src/libsyntax/attr.rs | 6 +++--- src/libsyntax/ext/base.rs | 4 ++-- src/libsyntax/ext/build.rs | 23 ++++++++++++----------- src/libsyntax/ext/quote.rs | 10 +++++----- src/libsyntax/ext/source_util.rs | 2 +- src/libsyntax/parse/attr.rs | 2 +- src/libsyntax/parse/mod.rs | 18 +++++++++--------- src/libsyntax/parse/parser.rs | 27 +++++++++++++-------------- src/libsyntax/print/pprust.rs | 16 ++++++++-------- src/libsyntax_ext/concat.rs | 20 ++++++++++---------- src/libsyntax_ext/deriving/debug.rs | 6 +++--- src/libsyntax_ext/format.rs | 2 +- 26 files changed, 142 insertions(+), 142 deletions(-) (limited to 'src/libsyntax_ext/deriving/debug.rs') diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index fa09c9d2bb6..62b6279bb33 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -421,7 +421,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir: fn const_val_to_expr(value: &ConstVal) -> P { let node = match value { - &ConstVal::Bool(b) => ast::LitBool(b), + &ConstVal::Bool(b) => ast::LitKind::Bool(b), _ => unreachable!() }; P(hir::Expr { diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index e8e817db7ab..80adc3e6fc6 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -1322,22 +1322,22 @@ fn cast_const<'tcx>(tcx: &ty::ctxt<'tcx>, val: ConstVal, ty: Ty) -> CastResult { fn lit_to_const(sess: &Session, span: Span, lit: &ast::Lit, ty_hint: Option) -> ConstVal { match lit.node { - ast::LitStr(ref s, _) => Str((*s).clone()), - ast::LitByteStr(ref data) => { + ast::LitKind::Str(ref s, _) => Str((*s).clone()), + ast::LitKind::ByteStr(ref data) => { ByteStr(data.clone()) } - ast::LitByte(n) => Uint(n as u64), - ast::LitChar(n) => Uint(n as u64), - ast::LitInt(n, ast::SignedIntLit(_)) => Int(n as i64), - ast::LitInt(n, ast::UnsuffixedIntLit) => { + 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) => { match ty_hint.map(|ty| &ty.sty) { Some(&ty::TyUint(_)) => Uint(n), _ => Int(n as i64) } } - ast::LitInt(n, ast::UnsignedIntLit(_)) => Uint(n), - ast::LitFloat(ref n, _) | - ast::LitFloatUnsuffixed(ref n) => { + ast::LitKind::Int(n, ast::UnsignedIntLit(_)) => Uint(n), + ast::LitKind::Float(ref n, _) | + ast::LitKind::FloatUnsuffixed(ref n) => { if let Ok(x) = n.parse::() { Float(x) } else { @@ -1345,7 +1345,7 @@ fn lit_to_const(sess: &Session, span: Span, lit: &ast::Lit, ty_hint: Option) sess.span_bug(span, "could not evaluate float literal (see issue #31407)"); } } - ast::LitBool(b) => Bool(b) + ast::LitKind::Bool(b) => Bool(b) } } diff --git a/src/librustc_back/svh.rs b/src/librustc_back/svh.rs index 2532882d012..b2911630991 100644 --- a/src/librustc_back/svh.rs +++ b/src/librustc_back/svh.rs @@ -232,7 +232,7 @@ mod svh_visitor { SawExprTup, SawExprBinary(hir::BinOp_), SawExprUnary(hir::UnOp), - SawExprLit(ast::Lit_), + SawExprLit(ast::LitKind), SawExprCast, SawExprType, SawExprIf, diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index efc2dc2814a..c0e935f7952 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -563,7 +563,7 @@ impl RustcDefaultCalls { ast::MetaWord(ref word) => println!("{}", word), ast::MetaNameValue(ref name, ref value) => { println!("{}=\"{}\"", name, match value.node { - ast::LitStr(ref s, _) => s, + ast::LitKind::Str(ref s, _) => s, _ => continue, }); } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 09cdab33c84..d90e145454c 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -73,7 +73,7 @@ impl LateLintPass for WhileTrue { fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { if let hir::ExprWhile(ref cond, _, _) = e.node { if let hir::ExprLit(ref lit) = cond.node { - if let ast::LitBool(true) = lit.node { + if let ast::LitKind::Bool(true) = lit.node { cx.span_lint(WHILE_TRUE, e.span, "denote infinite loops with loop { ... }"); } diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 9993234c36a..11469f43140 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -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::LitInt(_, ast::UnsignedIntLit(_)) => { + ast::LitKind::Int(_, ast::UnsignedIntLit(_)) => { forbid_unsigned_negation(cx, e.span); }, - ast::LitInt(_, ast::UnsuffixedIntLit) => { + ast::LitKind::Int(_, ast::UnsuffixedIntLit) => { if let ty::TyUint(_) = cx.tcx.node_id_to_type(e.id).sty { forbid_unsigned_negation(cx, e.span); } @@ -139,7 +139,7 @@ impl LateLintPass for TypeLimits { if let Some(bits) = opt_ty_bits { let exceeding = if let hir::ExprLit(ref lit) = r.node { - if let ast::LitInt(shift, _) = lit.node { shift >= bits } + if let ast::LitKind::Int(shift, _) = lit.node { shift >= bits } else { false } } else { match eval_const_expr_partial(cx.tcx, &r, ExprTypeChecked, None) { @@ -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::LitInt(v, ast::SignedIntLit(_)) | - ast::LitInt(v, ast::UnsuffixedIntLit) => { + ast::LitKind::Int(v, ast::SignedIntLit(_)) | + ast::LitKind::Int(v, ast::UnsuffixedIntLit) => { let int_type = if let ast::IntTy::Is = t { cx.sess().target.int_type } else { @@ -189,8 +189,9 @@ impl LateLintPass for TypeLimits { }; let (min, max) = uint_ty_range(uint_type); let lit_val: u64 = match lit.node { - ast::LitByte(_v) => return, // _v is u8, within range by definition - ast::LitInt(v, _) => v, + // _v is u8, within range by definition + ast::LitKind::Byte(_v) => return, + ast::LitKind::Int(v, _) => v, _ => panic!() }; if lit_val < min || lit_val > max { @@ -201,8 +202,8 @@ impl LateLintPass for TypeLimits { ty::TyFloat(t) => { let (min, max) = float_ty_range(t); let lit_val: f64 = match lit.node { - ast::LitFloat(ref v, _) | - ast::LitFloatUnsuffixed(ref v) => { + ast::LitKind::Float(ref v, _) | + ast::LitKind::FloatUnsuffixed(ref v) => { match v.parse() { Ok(f) => f, Err(_) => return @@ -311,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::LitInt(v, ast::SignedIntLit(_)) | - ast::LitInt(v, ast::UnsuffixedIntLit) => v as i64, + ast::LitKind::Int(v, ast::SignedIntLit(_)) | + ast::LitKind::Int(v, ast::UnsuffixedIntLit) => v as i64, _ => return true }, _ => panic!() @@ -323,7 +324,7 @@ impl LateLintPass for TypeLimits { let (min, max): (u64, u64) = uint_ty_range(uint_ty); let lit_val: u64 = match lit.node { hir::ExprLit(ref li) => match li.node { - ast::LitInt(v, _) => v, + ast::LitKind::Int(v, _) => v, _ => return true }, _ => panic!() diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index bcc506e96bb..9afbe5f1dbb 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1548,7 +1548,7 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) { } ast::MetaNameValue(ref name, ref value) => { match value.node { - ast::LitStr(ref value, _) => { + ast::LitKind::Str(ref value, _) => { rbml_w.start_tag(tag_meta_item_name_value); rbml_w.wr_tagged_str(tag_meta_item_name, name); rbml_w.wr_tagged_str(tag_meta_item_value, value); diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index 81df4746d10..f6bee7c2696 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -52,7 +52,7 @@ use rustc_front::hir; use std::ffi::{CStr, CString}; use std::borrow::Cow; use libc::c_uint; -use syntax::ast; +use syntax::ast::{self, LitKind}; use syntax::attr; use syntax::parse::token; use syntax::ptr::P; @@ -64,15 +64,15 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit) let _icx = push_ctxt("trans_lit"); debug!("const_lit: {:?}", lit); match lit.node { - ast::LitByte(b) => C_integral(Type::uint_from_ty(cx, ast::UintTy::U8), b as u64, false), - ast::LitChar(i) => C_integral(Type::char(cx), i as u64, false), - ast::LitInt(i, ast::SignedIntLit(t)) => { + 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)) => { C_integral(Type::int_from_ty(cx, t), i, true) } - ast::LitInt(u, ast::UnsignedIntLit(t)) => { + LitKind::Int(u, ast::UnsignedIntLit(t)) => { C_integral(Type::uint_from_ty(cx, t), u, false) } - ast::LitInt(i, ast::UnsuffixedIntLit) => { + LitKind::Int(i, ast::UnsuffixedIntLit) => { let lit_int_ty = cx.tcx().node_id_to_type(e.id); match lit_int_ty.sty { ty::TyInt(t) => { @@ -87,10 +87,10 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit) lit_int_ty)) } } - ast::LitFloat(ref fs, t) => { + LitKind::Float(ref fs, t) => { C_floating(&fs, Type::float_from_ty(cx, t)) } - ast::LitFloatUnsuffixed(ref fs) => { + LitKind::FloatUnsuffixed(ref fs) => { let lit_float_ty = cx.tcx().node_id_to_type(e.id); match lit_float_ty.sty { ty::TyFloat(t) => { @@ -102,9 +102,9 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit) } } } - ast::LitBool(b) => C_bool(cx, b), - ast::LitStr(ref s, _) => C_str_slice(cx, (*s).clone()), - ast::LitByteStr(ref data) => { + LitKind::Bool(b) => C_bool(cx, b), + LitKind::Str(ref s, _) => C_str_slice(cx, (*s).clone()), + LitKind::ByteStr(ref data) => { addr_of(cx, C_bytes(cx, &data[..]), 1, "byte_str") } } diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index a09936e1220..e411ed34691 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -1153,7 +1153,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } hir::ExprLit(ref lit) => { match lit.node { - ast::LitStr(ref s, _) => { + ast::LitKind::Str(ref s, _) => { tvec::trans_lit_str(bcx, expr, (*s).clone(), dest) } _ => { diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index 3a1568a70c9..b3f783a974d 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -92,7 +92,7 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // Handle the "..." case (returns a slice since strings are always unsized): if let hir::ExprLit(ref lit) = content_expr.node { - if let ast::LitStr(ref s, _) = lit.node { + if let ast::LitKind::Str(ref s, _) = lit.node { let scratch = rvalue_scratch_datum(bcx, vec_ty, ""); bcx = trans_lit_str(bcx, content_expr, @@ -180,7 +180,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match content_expr.node { hir::ExprLit(ref lit) => { match lit.node { - ast::LitStr(ref s, _) => { + ast::LitKind::Str(ref s, _) => { match dest { Ignore => return bcx, SaveIn(lldest) => { @@ -276,7 +276,7 @@ fn elements_required(bcx: Block, content_expr: &hir::Expr) -> usize { match content_expr.node { hir::ExprLit(ref lit) => { match lit.node { - ast::LitStr(ref s, _) => s.len(), + ast::LitKind::Str(ref s, _) => s.len(), _ => { bcx.tcx().sess.span_bug(content_expr.span, "unexpected evec content") diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index c43349f8810..f0436eee420 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -57,7 +57,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, // They can denote both statically and dynamically sized byte arrays let mut pat_ty = expr_ty; if let hir::ExprLit(ref lt) = lt.node { - if let ast::LitByteStr(_) = lt.node { + if let ast::LitKind::ByteStr(_) = lt.node { let expected_ty = structurally_resolved_type(fcx, pat.span, expected); if let ty::TyRef(_, mt) = expected_ty.sty { if let ty::TySlice(_) = mt.ty.sty { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 176f9bcd4f6..e348f7a9e06 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2606,16 +2606,16 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, let tcx = fcx.ccx.tcx; match lit.node { - ast::LitStr(..) => tcx.mk_static_str(), - ast::LitByteStr(ref v) => { + ast::LitKind::Str(..) => tcx.mk_static_str(), + ast::LitKind::ByteStr(ref v) => { tcx.mk_imm_ref(tcx.mk_region(ty::ReStatic), tcx.mk_array(tcx.types.u8, v.len())) } - ast::LitByte(_) => tcx.types.u8, - ast::LitChar(_) => tcx.types.char, - ast::LitInt(_, ast::SignedIntLit(t)) => tcx.mk_mach_int(t), - ast::LitInt(_, ast::UnsignedIntLit(t)) => tcx.mk_mach_uint(t), - ast::LitInt(_, ast::UnsuffixedIntLit) => { + 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) => { let opt_ty = expected.to_option(fcx).and_then(|ty| { match ty.sty { ty::TyInt(_) | ty::TyUint(_) => Some(ty), @@ -2628,8 +2628,8 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, opt_ty.unwrap_or_else( || tcx.mk_int_var(fcx.infcx().next_int_var_id())) } - ast::LitFloat(_, t) => tcx.mk_mach_float(t), - ast::LitFloatUnsuffixed(_) => { + ast::LitKind::Float(_, t) => tcx.mk_mach_float(t), + ast::LitKind::FloatUnsuffixed(_) => { let opt_ty = expected.to_option(fcx).and_then(|ty| { match ty.sty { ty::TyFloat(_) => Some(ty), @@ -2639,7 +2639,7 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, opt_ty.unwrap_or_else( || tcx.mk_float_var(fcx.infcx().next_float_var_id())) } - ast::LitBool(_) => tcx.types.bool + ast::LitKind::Bool(_) => tcx.types.bool } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 29722e5b538..2a346b773e6 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2531,9 +2531,9 @@ impl ToSource for syntax::codemap::Span { fn lit_to_string(lit: &ast::Lit) -> String { match lit.node { - ast::LitStr(ref st, _) => st.to_string(), - ast::LitByteStr(ref data) => format!("{:?}", data), - ast::LitByte(b) => { + ast::LitKind::Str(ref st, _) => st.to_string(), + ast::LitKind::ByteStr(ref data) => format!("{:?}", data), + ast::LitKind::Byte(b) => { let mut res = String::from("b'"); for c in (b as char).escape_default() { res.push(c); @@ -2541,11 +2541,11 @@ fn lit_to_string(lit: &ast::Lit) -> String { res.push('\''); res }, - ast::LitChar(c) => format!("'{}'", c), - ast::LitInt(i, _t) => i.to_string(), - ast::LitFloat(ref f, _t) => f.to_string(), - ast::LitFloatUnsuffixed(ref f) => f.to_string(), - ast::LitBool(b) => b.to_string(), + ast::LitKind::Char(c) => format!("'{}'", c), + ast::LitKind::Int(i, _t) => i.to_string(), + ast::LitKind::Float(ref f, _t) => f.to_string(), + ast::LitKind::FloatUnsuffixed(ref f) => f.to_string(), + ast::LitKind::Bool(b) => b.to_string(), } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 5752cbda9b9..41414ef5be1 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -13,7 +13,6 @@ pub use self::ForeignItem_::*; pub use self::Item_::*; pub use self::KleeneOp::*; -pub use self::Lit_::*; pub use self::LitIntType::*; pub use self::MacStmtStyle::*; pub use self::MetaItem_::*; @@ -1264,7 +1263,7 @@ pub enum StrStyle { } /// A literal -pub type Lit = Spanned; +pub type Lit = Spanned; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum LitIntType { @@ -1274,30 +1273,30 @@ pub enum LitIntType { } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum Lit_ { +pub enum LitKind { /// A string literal (`"foo"`) - LitStr(InternedString, StrStyle), + Str(InternedString, StrStyle), /// A byte string (`b"foo"`) - LitByteStr(Rc>), + ByteStr(Rc>), /// A byte char (`b'f'`) - LitByte(u8), + Byte(u8), /// A character literal (`'a'`) - LitChar(char), + Char(char), /// An integer literal (`1u8`) - LitInt(u64, LitIntType), + Int(u64, LitIntType), /// A float literal (`1f64` or `1E10f64`) - LitFloat(InternedString, FloatTy), + Float(InternedString, FloatTy), /// A float literal without a suffix (`1.0 or 1.0E10`) - LitFloatUnsuffixed(InternedString), + FloatUnsuffixed(InternedString), /// A boolean literal - LitBool(bool), + Bool(bool), } -impl Lit_ { +impl LitKind { /// Returns true if this literal is a string and false otherwise. pub fn is_str(&self) -> bool { match *self { - LitStr(..) => true, + LitKind::Str(..) => true, _ => false, } } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 64e6bcaa53c..c79661c1948 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -106,7 +106,7 @@ impl AttrMetaMethods for MetaItem { match self.node { MetaNameValue(_, ref v) => { match v.node { - ast::LitStr(ref s, _) => Some((*s).clone()), + ast::LitKind::Str(ref s, _) => Some((*s).clone()), _ => None, } }, @@ -173,7 +173,7 @@ impl AttributeMethods for Attribute { pub fn mk_name_value_item_str(name: InternedString, value: InternedString) -> P { - let value_lit = dummy_spanned(ast::LitStr(value, ast::CookedStr)); + let value_lit = dummy_spanned(ast::LitKind::Str(value, ast::CookedStr)); mk_name_value_item(name, value_lit) } @@ -225,7 +225,7 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos, hi: BytePos) -> Attribute { let style = doc_comment_style(&text); - let lit = spanned(lo, hi, ast::LitStr(text, ast::CookedStr)); + let lit = spanned(lo, hi, ast::LitKind::Str(text, ast::CookedStr)); let attr = Attribute_ { id: id, style: style, diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index b58f8007e0a..267b2dd9f6a 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -349,7 +349,7 @@ impl DummyResult { pub fn raw_expr(sp: Span) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::Lit(P(codemap::respan(sp, ast::LitBool(false)))), + node: ast::ExprKind::Lit(P(codemap::respan(sp, ast::LitKind::Bool(false)))), span: sp, attrs: None, }) @@ -774,7 +774,7 @@ pub fn expr_to_string(cx: &mut ExtCtxt, expr: P, err_msg: &str) let expr = cx.expander().fold_expr(expr); match expr.node { ast::ExprKind::Lit(ref l) => match l.node { - ast::LitStr(ref s, style) => return Some(((*s).clone(), style)), + ast::LitKind::Str(ref s, style) => return Some(((*s).clone(), style)), _ => cx.span_err(l.span, err_msg) }, _ => cx.span_err(expr.span, err_msg) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 241ea976eee..9302cabe8d8 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -139,7 +139,7 @@ pub trait AstBuilder { fn expr_struct_ident(&self, span: Span, id: ast::Ident, fields: Vec) -> P; - fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P; + fn expr_lit(&self, sp: Span, lit: ast::LitKind) -> P; fn expr_usize(&self, span: Span, i: usize) -> P; fn expr_isize(&self, sp: Span, i: isize) -> P; @@ -285,7 +285,7 @@ pub trait AstBuilder { fn meta_name_value(&self, sp: Span, name: InternedString, - value: ast::Lit_) + value: ast::LitKind) -> P; fn item_use(&self, sp: Span, @@ -676,29 +676,30 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_struct(span, self.path_ident(span, id), fields) } - fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P { + fn expr_lit(&self, sp: Span, lit: ast::LitKind) -> P { self.expr(sp, ast::ExprKind::Lit(P(respan(sp, lit)))) } fn expr_usize(&self, span: Span, i: usize) -> P { - self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::UintTy::Us))) + self.expr_lit(span, ast::LitKind::Int(i as u64, ast::UnsignedIntLit(ast::UintTy::Us))) } fn expr_isize(&self, sp: Span, i: isize) -> P { if i < 0 { let i = (-i) as u64; - let lit = self.expr_lit(sp, ast::LitInt(i, ast::SignedIntLit(ast::IntTy::Is))); + let lit_ty = ast::LitIntType::Signed(ast::IntTy::Is); + 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::LitInt(i as u64, ast::SignedIntLit(ast::IntTy::Is))) + self.expr_lit(sp, ast::LitKind::Int(i as u64, ast::SignedIntLit(ast::IntTy::Is))) } } fn expr_u32(&self, sp: Span, u: u32) -> P { - self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::UintTy::U32))) + self.expr_lit(sp, ast::LitKind::Int(u as u64, ast::UnsignedIntLit(ast::UintTy::U32))) } fn expr_u8(&self, sp: Span, u: u8) -> P { - self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::UintTy::U8))) + self.expr_lit(sp, ast::LitKind::Int(u as u64, ast::UnsignedIntLit(ast::UintTy::U8))) } fn expr_bool(&self, sp: Span, value: bool) -> P { - self.expr_lit(sp, ast::LitBool(value)) + self.expr_lit(sp, ast::LitKind::Bool(value)) } fn expr_vec(&self, sp: Span, exprs: Vec>) -> P { @@ -712,7 +713,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_addr_of(sp, self.expr_vec(sp, exprs)) } fn expr_str(&self, sp: Span, s: InternedString) -> P { - self.expr_lit(sp, ast::LitStr(s, ast::CookedStr)) + self.expr_lit(sp, ast::LitKind::Str(s, ast::CookedStr)) } fn expr_cast(&self, sp: Span, expr: P, ty: P) -> P { @@ -1113,7 +1114,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn meta_name_value(&self, sp: Span, name: InternedString, - value: ast::Lit_) + value: ast::LitKind) -> P { P(respan(sp, ast::MetaNameValue(name, respan(sp, value)))) } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index dfe3f8e3c54..18342fa775b 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -218,7 +218,7 @@ pub mod rt { impl ToTokens for str { fn to_tokens(&self, cx: &ExtCtxt) -> Vec { - let lit = ast::LitStr( + let lit = ast::LitKind::Str( token::intern_and_get_ident(self), ast::CookedStr); dummy_spanned(lit).to_tokens(cx) } @@ -249,13 +249,13 @@ pub mod rt { impl ToTokens for bool { fn to_tokens(&self, cx: &ExtCtxt) -> Vec { - dummy_spanned(ast::LitBool(*self)).to_tokens(cx) + dummy_spanned(ast::LitKind::Bool(*self)).to_tokens(cx) } } impl ToTokens for char { fn to_tokens(&self, cx: &ExtCtxt) -> Vec { - dummy_spanned(ast::LitChar(*self)).to_tokens(cx) + dummy_spanned(ast::LitKind::Char(*self)).to_tokens(cx) } } @@ -268,7 +268,7 @@ pub mod rt { } else { *self }; - let lit = ast::LitInt(val as u64, ast::SignedIntLit($tag)); + let lit = ast::LitKind::Int(val as u64, ast::SignedIntLit($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 { - let lit = ast::LitInt(*self as u64, ast::UnsignedIntLit($tag)); + let lit = ast::LitKind::Int(*self as u64, ast::UnsignedIntLit($tag)); dummy_spanned(lit).to_tokens(cx) } } diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index f00224bacdd..3e375e1798d 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -187,7 +187,7 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) let filename = format!("{}", file.display()); cx.codemap().new_filemap_and_lines(&filename, ""); - base::MacEager::expr(cx.expr_lit(sp, ast::LitByteStr(Rc::new(bytes)))) + base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(Rc::new(bytes)))) } } } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 96ac9b83d2f..3f9f2ae44a3 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -175,7 +175,7 @@ impl<'a> Parser<'a> { // FIXME #623 Non-string meta items are not serialized correctly; // just forbid them for now match lit.node { - ast::LitStr(..) => {} + ast::LitKind::Str(..) => {} _ => { self.span_err(lit.span, "non-string literals are not allowed in meta-items"); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index d467405e089..bfd3dea38ce 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -449,11 +449,11 @@ fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool { } fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>, - sd: &Handler, sp: Span) -> ast::Lit_ { + sd: &Handler, sp: Span) -> ast::LitKind { debug!("filtered_float_lit: {}, {:?}", data, suffix); match suffix.as_ref().map(|s| &**s) { - Some("f32") => ast::LitFloat(data, ast::FloatTy::F32), - Some("f64") => ast::LitFloat(data, ast::FloatTy::F64), + Some("f32") => ast::LitKind::Float(data, ast::FloatTy::F32), + Some("f64") => ast::LitKind::Float(data, ast::FloatTy::F64), Some(suf) => { if suf.len() >= 2 && looks_like_width_suffix(&['f'], suf) { // if it looks like a width, lets try to be helpful. @@ -466,13 +466,13 @@ fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>, .emit(); } - ast::LitFloatUnsuffixed(data) + ast::LitKind::FloatUnsuffixed(data) } - None => ast::LitFloatUnsuffixed(data) + None => ast::LitKind::FloatUnsuffixed(data) } } pub fn float_lit(s: &str, suffix: Option, - sd: &Handler, sp: Span) -> ast::Lit_ { + sd: &Handler, sp: Span) -> ast::LitKind { debug!("float_lit: {:?}, {:?}", s, suffix); // FIXME #2252: bounds checking float literals is deferred until trans let s = s.chars().filter(|&c| c != '_').collect::(); @@ -576,7 +576,7 @@ pub fn integer_lit(s: &str, suffix: Option, sd: &Handler, sp: Span) - -> ast::Lit_ { + -> ast::LitKind { // s can only be ascii, byte indexing is fine let s2 = s.chars().filter(|&c| c != '_').collect::(); @@ -652,7 +652,7 @@ pub fn integer_lit(s: &str, string was {:?}, the original suffix was {:?}", ty, base, s, orig, suffix); match u64::from_str_radix(s, base) { - Ok(r) => ast::LitInt(r, ty), + Ok(r) => ast::LitKind::Int(r, ty), Err(_) => { // small bases are lexed as if they were base 10, e.g, the string // might be `0b10201`. This will cause the conversion above to fail, @@ -665,7 +665,7 @@ pub fn integer_lit(s: &str, if !already_errored { sd.span_err(sp, "int literal is too large"); } - ast::LitInt(0, ty) + ast::LitKind::Int(0, ty) } } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1a8b1cbc374..d3b92ac0c0c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -27,9 +27,8 @@ 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_, UintTy}; -use ast::{LitBool, LitChar, LitByte, LitByteStr}; -use ast::{LitStr, LitInt, Local}; +use ast::{Lit, LitKind, UintTy}; +use ast::Local; use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces}; use ast::{MutImmutable, MutMutable, Mac_}; use ast::{MutTy, Mutability}; @@ -1517,7 +1516,7 @@ impl<'a> Parser<'a> { } /// Matches token_lit = LIT_INTEGER | ... - pub fn lit_from_token(&self, tok: &token::Token) -> PResult<'a, Lit_> { + pub fn lit_from_token(&self, tok: &token::Token) -> PResult<'a, LitKind> { match *tok { token::Interpolated(token::NtExpr(ref v)) => { match v.node { @@ -1527,8 +1526,8 @@ impl<'a> Parser<'a> { } token::Literal(lit, suf) => { let (suffix_illegal, out) = match lit { - token::Byte(i) => (true, LitByte(parse::byte_lit(&i.as_str()).0)), - token::Char(i) => (true, LitChar(parse::char_lit(&i.as_str()).0)), + token::Byte(i) => (true, LitKind::Byte(parse::byte_lit(&i.as_str()).0)), + token::Char(i) => (true, LitKind::Char(parse::char_lit(&i.as_str()).0)), // there are some valid suffixes for integer and // float literals, so all the handling is done @@ -1548,20 +1547,20 @@ impl<'a> Parser<'a> { token::Str_(s) => { (true, - LitStr(token::intern_and_get_ident(&parse::str_lit(&s.as_str())), - ast::CookedStr)) + LitKind::Str(token::intern_and_get_ident(&parse::str_lit(&s.as_str())), + ast::CookedStr)) } token::StrRaw(s, n) => { (true, - LitStr( + LitKind::Str( token::intern_and_get_ident(&parse::raw_str_lit(&s.as_str())), ast::RawStr(n))) } token::ByteStr(i) => - (true, LitByteStr(parse::byte_str_lit(&i.as_str()))), + (true, LitKind::ByteStr(parse::byte_str_lit(&i.as_str()))), token::ByteStrRaw(i, _) => (true, - LitByteStr(Rc::new(i.to_string().into_bytes()))), + LitKind::ByteStr(Rc::new(i.to_string().into_bytes()))), }; if suffix_illegal { @@ -1579,9 +1578,9 @@ impl<'a> Parser<'a> { pub fn parse_lit(&mut self) -> PResult<'a, Lit> { let lo = self.span.lo; let lit = if self.eat_keyword(keywords::True) { - LitBool(true) + LitKind::Bool(true) } else if self.eat_keyword(keywords::False) { - LitBool(false) + LitKind::Bool(false) } else { let token = self.bump_and_get(); let lit = try!(self.lit_from_token(&token)); @@ -2015,7 +2014,7 @@ impl<'a> Parser<'a> { pub fn mk_lit_u32(&mut self, i: u32, attrs: ThinAttributes) -> P { let span = &self.span; let lv_lit = P(codemap::Spanned { - node: LitInt(i as u64, ast::UnsignedIntLit(UintTy::U32)), + node: LitKind::Int(i as u64, ast::UnsignedIntLit(UintTy::U32)), span: *span }); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 1e57d347f5a..96c5d116629 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -630,20 +630,20 @@ pub trait PrintState<'a> { _ => () } match lit.node { - ast::LitStr(ref st, style) => self.print_string(&st, style), - ast::LitByte(byte) => { + ast::LitKind::Str(ref st, style) => self.print_string(&st, style), + ast::LitKind::Byte(byte) => { let mut res = String::from("b'"); res.extend(ascii::escape_default(byte).map(|c| c as char)); res.push('\''); word(self.writer(), &res[..]) } - ast::LitChar(ch) => { + ast::LitKind::Char(ch) => { let mut res = String::from("'"); res.extend(ch.escape_default()); res.push('\''); word(self.writer(), &res[..]) } - ast::LitInt(i, t) => { + ast::LitKind::Int(i, t) => { match t { ast::SignedIntLit(st) => { word(self.writer(), @@ -657,18 +657,18 @@ pub trait PrintState<'a> { } } } - ast::LitFloat(ref f, t) => { + ast::LitKind::Float(ref f, t) => { word(self.writer(), &format!( "{}{}", &f, t.ty_to_string())) } - ast::LitFloatUnsuffixed(ref f) => word(self.writer(), &f[..]), - ast::LitBool(val) => { + ast::LitKind::FloatUnsuffixed(ref f) => word(self.writer(), &f[..]), + ast::LitKind::Bool(val) => { if val { word(self.writer(), "true") } else { word(self.writer(), "false") } } - ast::LitByteStr(ref v) => { + ast::LitKind::ByteStr(ref v) => { let mut escaped: String = String::new(); for &ch in v.iter() { escaped.extend(ascii::escape_default(ch) diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs index 9f6cf73ed64..8ea0580d4c8 100644 --- a/src/libsyntax_ext/concat.rs +++ b/src/libsyntax_ext/concat.rs @@ -29,24 +29,24 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, match e.node { ast::ExprKind::Lit(ref lit) => { match lit.node { - ast::LitStr(ref s, _) | - ast::LitFloat(ref s, _) | - ast::LitFloatUnsuffixed(ref s) => { + ast::LitKind::Str(ref s, _) | + ast::LitKind::Float(ref s, _) | + ast::LitKind::FloatUnsuffixed(ref s) => { accumulator.push_str(&s); } - ast::LitChar(c) => { + ast::LitKind::Char(c) => { accumulator.push(c); } - ast::LitInt(i, ast::UnsignedIntLit(_)) | - ast::LitInt(i, ast::SignedIntLit(_)) | - ast::LitInt(i, ast::UnsuffixedIntLit) => { + ast::LitKind::Int(i, ast::UnsignedIntLit(_)) | + ast::LitKind::Int(i, ast::SignedIntLit(_)) | + ast::LitKind::Int(i, ast::UnsuffixedIntLit) => { accumulator.push_str(&format!("{}", i)); } - ast::LitBool(b) => { + ast::LitKind::Bool(b) => { accumulator.push_str(&format!("{}", b)); } - ast::LitByte(..) | - ast::LitByteStr(..) => { + ast::LitKind::Byte(..) | + ast::LitKind::ByteStr(..) => { cx.span_err(e.span, "cannot concatenate a byte string literal"); } } diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 3c36ce57d18..1751f43e0a1 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -71,8 +71,8 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, // We want to make sure we have the expn_id set so that we can use unstable methods let span = Span { expn_id: cx.backtrace(), .. span }; - let name = cx.expr_lit(span, ast::Lit_::LitStr(ident.name.as_str(), - ast::StrStyle::CookedStr)); + let name = cx.expr_lit(span, ast::LitKind::Str(ident.name.as_str(), + ast::StrStyle::CookedStr)); let builder = token::str_to_ident("builder"); let builder_expr = cx.expr_ident(span, builder.clone()); @@ -112,7 +112,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, stmts.push(cx.stmt_let(DUMMY_SP, true, builder, expr)); for field in fields { - let name = cx.expr_lit(field.span, ast::Lit_::LitStr( + let name = cx.expr_lit(field.span, ast::LitKind::Str( field.name.unwrap().name.as_str(), ast::StrStyle::CookedStr)); diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 21b32153ed9..541c2dbda4e 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -409,7 +409,7 @@ impl<'a, 'b> Context<'a, 'b> { } // Translate the format - let fill = self.ecx.expr_lit(sp, ast::LitChar(fill)); + let fill = self.ecx.expr_lit(sp, ast::LitKind::Char(fill)); let align = |name| { let mut p = Context::rtpath(self.ecx, "Alignment"); p.push(self.ecx.ident_of(name)); -- cgit 1.4.1-3-g733a5 From 8290c950a8b4cdc70038736abcf29f41dede6e0c Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 8 Feb 2016 17:23:13 +0100 Subject: [breaking-change] don't pub export ast::Stmt_ variants --- src/librustc_front/lowering.rs | 8 ++++---- src/librustc_lint/unused.rs | 2 +- src/librustc_passes/const_fn.rs | 8 ++++---- src/libsyntax/ast.rs | 33 ++++++++++++++++----------------- src/libsyntax/attr.rs | 12 ++++++------ src/libsyntax/config.rs | 2 +- src/libsyntax/ext/base.rs | 6 +++--- src/libsyntax/ext/build.rs | 8 ++++---- src/libsyntax/ext/expand.rs | 13 ++++++------- src/libsyntax/fold.rs | 20 ++++++++++---------- src/libsyntax/parse/classify.rs | 10 +++++----- src/libsyntax/parse/mod.rs | 4 ++-- src/libsyntax/parse/parser.rs | 35 ++++++++++++++++------------------- src/libsyntax/print/pprust.rs | 8 ++++---- src/libsyntax/visit.rs | 6 +++--- src/libsyntax_ext/deriving/debug.rs | 2 +- src/libsyntax_ext/format.rs | 2 +- 17 files changed, 87 insertions(+), 92 deletions(-) (limited to 'src/libsyntax_ext/deriving/debug.rs') diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index 813a7f71fe9..55f37759892 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -1534,25 +1534,25 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P { pub fn lower_stmt(lctx: &LoweringContext, s: &Stmt) -> hir::Stmt { match s.node { - StmtDecl(ref d, id) => { + StmtKind::Decl(ref d, id) => { Spanned { node: hir::StmtDecl(lower_decl(lctx, d), id), span: s.span, } } - StmtExpr(ref e, id) => { + StmtKind::Expr(ref e, id) => { Spanned { node: hir::StmtExpr(lower_expr(lctx, e), id), span: s.span, } } - StmtSemi(ref e, id) => { + StmtKind::Semi(ref e, id) => { Spanned { node: hir::StmtSemi(lower_expr(lctx, e), id), span: s.span, } } - StmtMac(..) => panic!("Shouldn't exist here"), + StmtKind::Mac(..) => panic!("Shouldn't exist here"), } } diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index bbd714fad06..f18b68a5b73 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -365,7 +365,7 @@ impl EarlyLintPass for UnusedParens { fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) { let (value, msg) = match s.node { - ast::StmtDecl(ref decl, _) => match decl.node { + ast::StmtKind::Decl(ref decl, _) => match decl.node { ast::DeclKind::Local(ref local) => match local.init { Some(ref value) => (value, "assigned value"), None => return diff --git a/src/librustc_passes/const_fn.rs b/src/librustc_passes/const_fn.rs index 5ec00439df2..ec9fa1afb55 100644 --- a/src/librustc_passes/const_fn.rs +++ b/src/librustc_passes/const_fn.rs @@ -57,7 +57,7 @@ fn check_block(sess: &Session, b: &ast::Block, kind: &'static str) { // Check all statements in the block for stmt in &b.stmts { let span = match stmt.node { - ast::StmtDecl(ref decl, _) => { + ast::StmtKind::Decl(ref decl, _) => { match decl.node { ast::DeclKind::Local(_) => decl.span, @@ -65,9 +65,9 @@ fn check_block(sess: &Session, b: &ast::Block, kind: &'static str) { ast::DeclKind::Item(_) => continue, } } - ast::StmtExpr(ref expr, _) => expr.span, - ast::StmtSemi(ref semi, _) => semi.span, - ast::StmtMac(..) => unreachable!(), + ast::StmtKind::Expr(ref expr, _) => expr.span, + ast::StmtKind::Semi(ref semi, _) => semi.span, + ast::StmtKind::Mac(..) => unreachable!(), }; span_err!(sess, span, E0016, "blocks in {}s are limited to items and tail expressions", kind); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 6ece7ed56cf..b677941291b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -18,7 +18,6 @@ pub use self::MetaItem_::*; pub use self::Mutability::*; pub use self::Pat_::*; pub use self::PathListItem_::*; -pub use self::Stmt_::*; pub use self::StrStyle::*; pub use self::StructFieldKind::*; pub use self::TraitItem_::*; @@ -735,7 +734,7 @@ impl UnOp { } /// A statement -pub type Stmt = Spanned; +pub type Stmt = Spanned; impl fmt::Debug for Stmt { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -748,36 +747,36 @@ impl fmt::Debug for Stmt { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] -pub enum Stmt_ { +pub enum StmtKind { /// Could be an item or a local (let) binding: - StmtDecl(P, NodeId), + Decl(P, NodeId), /// Expr without trailing semi-colon (must have unit type): - StmtExpr(P, NodeId), + Expr(P, NodeId), /// Expr with trailing semi-colon (may have any type): - StmtSemi(P, NodeId), + Semi(P, NodeId), - StmtMac(P, MacStmtStyle, ThinAttributes), + Mac(P, MacStmtStyle, ThinAttributes), } -impl Stmt_ { +impl StmtKind { pub fn id(&self) -> Option { match *self { - StmtDecl(_, id) => Some(id), - StmtExpr(_, id) => Some(id), - StmtSemi(_, id) => Some(id), - StmtMac(..) => None, + StmtKind::Decl(_, id) => Some(id), + StmtKind::Expr(_, id) => Some(id), + StmtKind::Semi(_, id) => Some(id), + StmtKind::Mac(..) => None, } } pub fn attrs(&self) -> &[Attribute] { match *self { - StmtDecl(ref d, _) => d.attrs(), - StmtExpr(ref e, _) | - StmtSemi(ref e, _) => e.attrs(), - StmtMac(_, _, Some(ref b)) => b, - StmtMac(_, _, None) => &[], + StmtKind::Decl(ref d, _) => d.attrs(), + StmtKind::Expr(ref e, _) | + StmtKind::Semi(ref e, _) => e.attrs(), + StmtKind::Mac(_, _, Some(ref b)) => b, + StmtKind::Mac(_, _, None) => &[], } } } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index c79661c1948..f9c41ee43dd 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -16,7 +16,7 @@ pub use self::IntType::*; use ast; use ast::{AttrId, Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList}; -use ast::{Stmt, StmtDecl, StmtExpr, StmtMac, StmtSemi, DeclKind}; +use ast::{Stmt, StmtKind, DeclKind}; use ast::{Expr, Item, Local, Decl}; use codemap::{Span, Spanned, spanned, dummy_spanned}; use codemap::BytePos; @@ -947,12 +947,12 @@ impl WithAttrs for P { Spanned { span: span, node: match node { - StmtDecl(decl, id) => StmtDecl(decl.with_attrs(attrs), id), - StmtExpr(expr, id) => StmtExpr(expr.with_attrs(attrs), id), - StmtSemi(expr, id) => StmtSemi(expr.with_attrs(attrs), id), - StmtMac(mac, style, mut ats) => { + StmtKind::Decl(decl, id) => StmtKind::Decl(decl.with_attrs(attrs), id), + StmtKind::Expr(expr, id) => StmtKind::Expr(expr.with_attrs(attrs), id), + StmtKind::Semi(expr, id) => StmtKind::Semi(expr.with_attrs(attrs), id), + StmtKind::Mac(mac, style, mut ats) => { ats.update(|a| a.append(attrs)); - StmtMac(mac, style, ats) + StmtKind::Mac(mac, style, ats) } }, } diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 8d74990fc32..840acff73ad 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -372,7 +372,7 @@ impl<'v, 'a, 'b> visit::Visitor<'v> for StmtExprAttrFeatureVisitor<'a, 'b> { let stmt_attrs = s.node.attrs(); if stmt_attrs.len() > 0 { // attributes on items are fine - if let ast::StmtDecl(ref decl, _) = s.node { + if let ast::StmtKind::Decl(ref decl, _) = s.node { if let ast::DeclKind::Item(_) = decl.node { visit::walk_stmt(self, s); return; diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 267b2dd9f6a..ceb7cf69680 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -205,7 +205,7 @@ macro_rules! make_stmts_default { ($me:expr) => { $me.make_expr().map(|e| { SmallVector::one(P(codemap::respan( - e.span, ast::StmtExpr(e, ast::DUMMY_NODE_ID)))) + e.span, ast::StmtKind::Expr(e, ast::DUMMY_NODE_ID)))) }) } } @@ -402,8 +402,8 @@ impl MacResult for DummyResult { fn make_stmts(self: Box) -> Option>> { Some(SmallVector::one(P( codemap::respan(self.span, - ast::StmtExpr(DummyResult::raw_expr(self.span), - ast::DUMMY_NODE_ID))))) + ast::StmtKind::Expr(DummyResult::raw_expr(self.span), + ast::DUMMY_NODE_ID))))) } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 7dfea4f798c..76071cc71e6 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -506,7 +506,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn stmt_expr(&self, expr: P) -> P { - P(respan(expr.span, ast::StmtSemi(expr, ast::DUMMY_NODE_ID))) + P(respan(expr.span, ast::StmtKind::Semi(expr, ast::DUMMY_NODE_ID))) } fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, @@ -525,7 +525,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { attrs: None, }); let decl = respan(sp, ast::DeclKind::Local(local)); - P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID))) + P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))) } fn stmt_let_typed(&self, @@ -549,7 +549,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { attrs: None, }); let decl = respan(sp, ast::DeclKind::Local(local)); - P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID))) + P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))) } fn block(&self, span: Span, stmts: Vec>, @@ -559,7 +559,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn stmt_item(&self, sp: Span, item: P) -> P { let decl = respan(sp, ast::DeclKind::Item(item)); - P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID))) + P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))) } fn block_expr(&self, expr: P) -> P { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 9b31465b547..78bc4e2c735 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -10,8 +10,7 @@ use ast::{Block, Crate, DeclKind, PatMac}; use ast::{Local, Ident, Mac_, Name}; -use ast::{ItemMac, MacStmtWithSemicolon, Mrk, Stmt, StmtDecl, StmtMac}; -use ast::{StmtExpr, StmtSemi}; +use ast::{ItemMac, MacStmtWithSemicolon, Mrk, Stmt, StmtKind}; use ast::TokenTree; use ast; use ext::mtwt; @@ -507,7 +506,7 @@ pub fn expand_item_mac(it: P, fn expand_stmt(stmt: P, fld: &mut MacroExpander) -> SmallVector> { let stmt = stmt.and_then(|stmt| stmt); let (mac, style, attrs) = match stmt.node { - StmtMac(mac, style, attrs) => (mac, style, attrs), + StmtKind::Mac(mac, style, attrs) => (mac, style, attrs), _ => return expand_non_macro_stmt(stmt, fld) }; @@ -539,7 +538,7 @@ fn expand_stmt(stmt: P, fld: &mut MacroExpander) -> SmallVector> { let new_stmt = stmt.map(|Spanned {node, span}| { Spanned { node: match node { - StmtExpr(e, stmt_id) => StmtSemi(e, stmt_id), + StmtKind::Expr(e, stmt_id) => StmtKind::Semi(e, stmt_id), _ => node /* might already have a semi */ }, span: span @@ -558,7 +557,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE -> SmallVector> { // is it a let? match node { - StmtDecl(decl, node_id) => decl.and_then(|Spanned {node: decl, span}| match decl { + StmtKind::Decl(decl, node_id) => decl.and_then(|Spanned {node: decl, span}| match decl { DeclKind::Local(local) => { // take it apart: let rewritten_local = local.map(|Local {id, pat, ty, init, span, attrs}| { @@ -596,7 +595,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE } }); SmallVector::one(P(Spanned { - node: StmtDecl(P(Spanned { + node: StmtKind::Decl(P(Spanned { node: DeclKind::Local(rewritten_local), span: span }), @@ -606,7 +605,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE } _ => { noop_fold_stmt(Spanned { - node: StmtDecl(P(Spanned { + node: StmtKind::Decl(P(Spanned { node: decl, span: span }), diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 1a6171e1981..9819dc6220a 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1347,39 +1347,39 @@ pub fn noop_fold_stmt(Spanned {node, span}: Stmt, folder: &mut T) -> SmallVector> { let span = folder.new_span(span); match node { - StmtDecl(d, id) => { + StmtKind::Decl(d, id) => { let id = folder.new_id(id); folder.fold_decl(d).into_iter().map(|d| P(Spanned { - node: StmtDecl(d, id), + node: StmtKind::Decl(d, id), span: span })).collect() } - StmtExpr(e, id) => { + StmtKind::Expr(e, id) => { let id = folder.new_id(id); if let Some(e) = folder.fold_opt_expr(e) { SmallVector::one(P(Spanned { - node: StmtExpr(e, id), + node: StmtKind::Expr(e, id), span: span })) } else { SmallVector::zero() } } - StmtSemi(e, id) => { + StmtKind::Semi(e, id) => { let id = folder.new_id(id); if let Some(e) = folder.fold_opt_expr(e) { SmallVector::one(P(Spanned { - node: StmtSemi(e, id), + node: StmtKind::Semi(e, id), span: span })) } else { SmallVector::zero() } } - StmtMac(mac, semi, attrs) => SmallVector::one(P(Spanned { - node: StmtMac(mac.map(|m| folder.fold_mac(m)), - semi, - attrs.map_thin_attrs(|v| fold_attrs(v, folder))), + StmtKind::Mac(mac, semi, attrs) => SmallVector::one(P(Spanned { + node: StmtKind::Mac(mac.map(|m| folder.fold_mac(m)), + semi, + attrs.map_thin_attrs(|v| fold_attrs(v, folder))), span: span })) } diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 325fe64203c..89110f3160f 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -45,16 +45,16 @@ pub fn expr_is_simple_block(e: &ast::Expr) -> bool { /// this statement requires a semicolon after it. /// note that in one case (stmt_semi), we've already /// seen the semicolon, and thus don't need another. -pub fn stmt_ends_with_semi(stmt: &ast::Stmt_) -> bool { +pub fn stmt_ends_with_semi(stmt: &ast::StmtKind) -> bool { match *stmt { - ast::StmtDecl(ref d, _) => { + ast::StmtKind::Decl(ref d, _) => { match d.node { ast::DeclKind::Local(_) => true, ast::DeclKind::Item(_) => false, } } - ast::StmtExpr(ref e, _) => expr_requires_semi_to_be_stmt(e), - ast::StmtSemi(..) => false, - ast::StmtMac(..) => false, + ast::StmtKind::Expr(ref e, _) => expr_requires_semi_to_be_stmt(e), + ast::StmtKind::Semi(..) => false, + ast::StmtKind::Mac(..) => false, } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 3d68dcdc6b7..2bbf1699662 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -867,7 +867,7 @@ mod tests { #[test] fn parse_stmt_1 () { assert!(string_to_stmt("b;".to_string()) == Some(P(Spanned{ - node: ast::StmtExpr(P(ast::Expr { + node: ast::StmtKind::Expr(P(ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprKind::Path(None, ast::Path { span:sp(0,1), @@ -958,7 +958,7 @@ mod tests { }, P(ast::Block { stmts: vec!(P(Spanned{ - node: ast::StmtSemi(P(ast::Expr{ + node: ast::StmtKind::Semi(P(ast::Expr{ id: ast::DUMMY_NODE_ID, node: ast::ExprKind::Path(None, ast::Path{ diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 85a5b5b3068..93088648e93 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -36,8 +36,8 @@ use ast::NamedField; use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange}; use ast::{PatRegion, PatStruct, PatTup, PatVec, PatWild}; use ast::{PolyTraitRef, QSelf}; -use ast::{Stmt, StmtDecl}; -use ast::{StmtExpr, StmtSemi, StmtMac, VariantData, StructField}; +use ast::{Stmt, StmtKind}; +use ast::{VariantData, StructField}; use ast::StrStyle; use ast::SelfKind; use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef}; @@ -3678,7 +3678,7 @@ impl<'a> Parser<'a> { try!(self.expect_keyword(keywords::Let)); let decl = try!(self.parse_let(attrs.into_thin_attrs())); let hi = decl.span.hi; - let stmt = StmtDecl(decl, ast::DUMMY_NODE_ID); + let stmt = StmtKind::Decl(decl, ast::DUMMY_NODE_ID); spanned(lo, hi, stmt) } else if self.token.is_ident() && !self.token.is_any_keyword() @@ -3730,11 +3730,8 @@ impl<'a> Parser<'a> { }; if id.name == token::special_idents::invalid.name { - let stmt = StmtMac(P(spanned(lo, - hi, - Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT })), - style, - attrs.into_thin_attrs()); + let mac = P(spanned(lo, hi, Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT })); + let stmt = StmtKind::Mac(mac, style, attrs.into_thin_attrs()); spanned(lo, hi, stmt) } else { // if it has a special ident, it's definitely an item @@ -3749,7 +3746,7 @@ impl<'a> Parser<'a> { followed by a semicolon"); } } - spanned(lo, hi, StmtDecl( + spanned(lo, hi, StmtKind::Decl( P(spanned(lo, hi, DeclKind::Item( self.mk_item( lo, hi, id /*id is good here*/, @@ -3764,7 +3761,7 @@ impl<'a> Parser<'a> { Some(i) => { let hi = i.span.hi; let decl = P(spanned(lo, hi, DeclKind::Item(i))); - spanned(lo, hi, StmtDecl(decl, ast::DUMMY_NODE_ID)) + spanned(lo, hi, StmtKind::Decl(decl, ast::DUMMY_NODE_ID)) } None => { let unused_attrs = |attrs: &[_], s: &mut Self| { @@ -3790,7 +3787,7 @@ impl<'a> Parser<'a> { let e = try!(self.parse_expr_res( Restrictions::RESTRICTION_STMT_EXPR, Some(attrs.into_thin_attrs()))); let hi = e.span.hi; - let stmt = StmtExpr(e, ast::DUMMY_NODE_ID); + let stmt = StmtKind::Expr(e, ast::DUMMY_NODE_ID); spanned(lo, hi, stmt) } } @@ -3844,16 +3841,16 @@ impl<'a> Parser<'a> { continue; }; match node { - StmtExpr(e, _) => { + StmtKind::Expr(e, _) => { try!(self.handle_expression_like_statement(e, span, &mut stmts, &mut expr)); } - StmtMac(mac, MacStmtWithoutBraces, attrs) => { + StmtKind::Mac(mac, MacStmtWithoutBraces, attrs) => { // statement macro without braces; might be an // expr depending on whether a semicolon follows match self.token { token::Semi => { stmts.push(P(Spanned { - node: StmtMac(mac, MacStmtWithSemicolon, attrs), + node: StmtKind::Mac(mac, MacStmtWithSemicolon, attrs), span: mk_sp(span.lo, self.span.hi), })); self.bump(); @@ -3873,12 +3870,12 @@ impl<'a> Parser<'a> { } } } - StmtMac(m, style, attrs) => { + StmtKind::Mac(m, style, attrs) => { // statement macro; might be an expr match self.token { token::Semi => { stmts.push(P(Spanned { - node: StmtMac(m, MacStmtWithSemicolon, attrs), + node: StmtKind::Mac(m, MacStmtWithSemicolon, attrs), span: mk_sp(span.lo, self.span.hi), })); self.bump(); @@ -3892,7 +3889,7 @@ impl<'a> Parser<'a> { } _ => { stmts.push(P(Spanned { - node: StmtMac(m, style, attrs), + node: StmtKind::Mac(m, style, attrs), span: span })); } @@ -3944,14 +3941,14 @@ impl<'a> Parser<'a> { expn_id: span.expn_id, }; stmts.push(P(Spanned { - node: StmtSemi(e, ast::DUMMY_NODE_ID), + node: StmtKind::Semi(e, ast::DUMMY_NODE_ID), span: span_with_semi, })); } token::CloseDelim(token::Brace) => *last_block_expr = Some(e), _ => { stmts.push(P(Spanned { - node: StmtExpr(e, ast::DUMMY_NODE_ID), + node: StmtKind::Expr(e, ast::DUMMY_NODE_ID), span: span })); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 8d29cb39d3a..a880e0dca80 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1613,19 +1613,19 @@ impl<'a> State<'a> { pub fn print_stmt(&mut self, st: &ast::Stmt) -> io::Result<()> { try!(self.maybe_print_comment(st.span.lo)); match st.node { - ast::StmtDecl(ref decl, _) => { + ast::StmtKind::Decl(ref decl, _) => { try!(self.print_decl(&**decl)); } - ast::StmtExpr(ref expr, _) => { + ast::StmtKind::Expr(ref expr, _) => { try!(self.space_if_not_bol()); try!(self.print_expr_outer_attr_style(&**expr, false)); } - ast::StmtSemi(ref expr, _) => { + ast::StmtKind::Semi(ref expr, _) => { try!(self.space_if_not_bol()); try!(self.print_expr_outer_attr_style(&**expr, false)); try!(word(&mut self.s, ";")); } - ast::StmtMac(ref mac, style, ref attrs) => { + ast::StmtKind::Mac(ref mac, style, ref attrs) => { try!(self.space_if_not_bol()); try!(self.print_outer_attributes(attrs.as_attr_slice())); let delim = match style { diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 44b3e581849..369efcd051e 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -625,11 +625,11 @@ pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) { pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) { match statement.node { - StmtDecl(ref declaration, _) => visitor.visit_decl(declaration), - StmtExpr(ref expression, _) | StmtSemi(ref expression, _) => { + StmtKind::Decl(ref declaration, _) => visitor.visit_decl(declaration), + StmtKind::Expr(ref expression, _) | StmtKind::Semi(ref expression, _) => { visitor.visit_expr(expression) } - StmtMac(ref mac, _, ref attrs) => { + StmtKind::Mac(ref mac, _, ref attrs) => { visitor.visit_mac(mac); for attr in attrs.as_attr_slice() { visitor.visit_attribute(attr); diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 1751f43e0a1..917c6b1ab89 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -152,5 +152,5 @@ fn stmt_let_undescore(cx: &mut ExtCtxt, attrs: None, }); let decl = respan(sp, ast::DeclKind::Local(local)); - P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID))) + P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))) } diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 541c2dbda4e..831a6250c9f 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -461,7 +461,7 @@ impl<'a, 'b> Context<'a, 'b> { // Wrap the declaration in a block so that it forms a single expression. ecx.expr_block(ecx.block(sp, - vec![P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))], + vec![P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID)))], Some(ecx.expr_ident(sp, name)))) } -- cgit 1.4.1-3-g733a5 From 73fa9b2da2ee82c91a5c8d605b91f22f19e4d74b Mon Sep 17 00:00:00 2001 From: Oliver 'ker' Schneider Date: Tue, 9 Feb 2016 17:44:47 +0100 Subject: [breaking-change] don't glob export ast::Mutablity variants --- src/librustc/middle/ty/relate.rs | 4 ++-- src/librustc_front/lowering.rs | 4 ++-- src/librustc_passes/const_fn.rs | 2 +- src/librustc_trans/save/dump_csv.rs | 4 ++-- src/librustc_trans/save/mod.rs | 12 ++++++---- src/libsyntax/ast.rs | 5 ++-- src/libsyntax/ast_util.rs | 3 ++- src/libsyntax/diagnostics/plugin.rs | 2 +- src/libsyntax/ext/build.rs | 13 ++++++---- src/libsyntax/parse/mod.rs | 4 ++-- src/libsyntax/parse/parser.rs | 40 ++++++++++++++++++------------- src/libsyntax/print/pprust.rs | 22 ++++++++--------- src/libsyntax/test.rs | 4 ++-- src/libsyntax_ext/deriving/debug.rs | 2 +- src/libsyntax_ext/deriving/decodable.rs | 4 ++-- src/libsyntax_ext/deriving/encodable.rs | 4 ++-- src/libsyntax_ext/deriving/generic/mod.rs | 17 +++++++------ src/libsyntax_ext/deriving/generic/ty.rs | 2 +- src/libsyntax_ext/deriving/hash.rs | 4 ++-- src/libsyntax_ext/env.rs | 2 +- src/libsyntax_ext/format.rs | 6 ++--- 21 files changed, 87 insertions(+), 73 deletions(-) (limited to 'src/libsyntax_ext/deriving/debug.rs') diff --git a/src/librustc/middle/ty/relate.rs b/src/librustc/middle/ty/relate.rs index 46bc13bd598..974b5c4bc6c 100644 --- a/src/librustc/middle/ty/relate.rs +++ b/src/librustc/middle/ty/relate.rs @@ -105,8 +105,8 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TypeAndMut<'tcx> { } else { let mutbl = a.mutbl; let variance = match mutbl { - ast::MutImmutable => ty::Covariant, - ast::MutMutable => ty::Invariant, + ast::Mutability::MutImmutable => ty::Covariant, + ast::Mutability::MutMutable => ty::Invariant, }; let ty = try!(relation.relate_with_variance(variance, &a.ty, &b.ty)); Ok(ty::TypeAndMut {ty: ty, mutbl: mutbl}) diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index d04f4c96504..e9dfa1bd164 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -427,8 +427,8 @@ pub fn lower_explicit_self_underscore(lctx: &LoweringContext, pub fn lower_mutability(_lctx: &LoweringContext, m: Mutability) -> hir::Mutability { match m { - MutMutable => hir::MutMutable, - MutImmutable => hir::MutImmutable, + Mutability::Mutable => hir::MutMutable, + Mutability::Immutable => hir::MutImmutable, } } diff --git a/src/librustc_passes/const_fn.rs b/src/librustc_passes/const_fn.rs index 98346f538b0..edbc6424ccd 100644 --- a/src/librustc_passes/const_fn.rs +++ b/src/librustc_passes/const_fn.rs @@ -105,7 +105,7 @@ impl<'a, 'v> Visitor<'v> for CheckConstFn<'a> { for arg in &fd.inputs { match arg.pat.node { ast::PatWild => {} - ast::PatIdent(ast::BindingMode::ByValue(ast::MutImmutable), _, None) => {} + ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable), _, None) => {} _ => { span_err!(self.sess, arg.pat.span, E0022, "arguments of constant functions can only \ diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index d8f21fd4dd6..68c04427c65 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -807,7 +807,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { self.visit_pat(&p); for &(id, ref p, immut, _) in &collector.collected_paths { - let value = if immut == ast::MutImmutable { + let value = if immut == ast::Mutability::Immutable { value.to_string() } else { "".to_string() @@ -1200,7 +1200,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { let def = def_map.get(&id).unwrap().full_def(); match def { Def::Local(_, id) => { - let value = if immut == ast::MutImmutable { + let value = if immut == ast::Mutability::Immutable { self.span.snippet(p.span).to_string() } else { "".to_string() diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 1790da39ad0..ff19640d645 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -248,8 +248,10 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { // If the variable is immutable, save the initialising expression. let (value, keyword) = match mt { - ast::MutMutable => (String::from(""), keywords::Mut), - ast::MutImmutable => (self.span_utils.snippet(expr.span), keywords::Static), + ast::Mutability::Mutable => (String::from(""), keywords::Mut), + ast::Mutability::Immutable => { + (self.span_utils.snippet(expr.span), keywords::Static) + }, }; let sub_span = self.span_utils.sub_span_after_keyword(item.span, keyword); @@ -758,12 +760,12 @@ impl<'v> Visitor<'v> for PathCollector { match p.node { ast::PatStruct(ref path, _, _) => { self.collected_paths.push((p.id, path.clone(), - ast::MutMutable, recorder::TypeRef)); + ast::Mutability::Mutable, recorder::TypeRef)); } ast::PatEnum(ref path, _) | ast::PatQPath(_, ref path) => { self.collected_paths.push((p.id, path.clone(), - ast::MutMutable, recorder::VarRef)); + ast::Mutability::Mutable, recorder::VarRef)); } ast::PatIdent(bm, ref path1, _) => { debug!("PathCollector, visit ident in pat {}: {:?} {:?}", @@ -774,7 +776,7 @@ impl<'v> Visitor<'v> for PathCollector { // Even if the ref is mut, you can't change the ref, only // the data pointed at, so showing the initialising expression // is still worthwhile. - ast::BindingMode::ByRef(_) => ast::MutImmutable, + ast::BindingMode::ByRef(_) => ast::Mutability::Immutable, ast::BindingMode::ByValue(mt) => mt, }; // collect path for either visit_local or visit_arm diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a3a59b7898b..cfaa5fc4a96 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,7 +10,6 @@ // The Rust abstract syntax tree. -pub use self::Mutability::*; pub use self::Pat_::*; pub use self::PathListItem_::*; pub use self::StrStyle::*; @@ -602,8 +601,8 @@ pub enum Pat_ { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum Mutability { - MutMutable, - MutImmutable, + Mutable, + Immutable, } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 270133ad599..e22cdab97e8 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -66,9 +66,10 @@ pub fn path_to_ident(path: &Path) -> Option { } pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> P { + let spanned = codemap::Spanned{ span: s, node: i }; P(Pat { id: id, - node: PatIdent(BindingMode::ByValue(MutImmutable), codemap::Spanned{span:s, node:i}, None), + node: PatIdent(BindingMode::ByValue(Mutability::Immutable), spanned, None), span: s }) } diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index e8a4bb59bdc..2e343948c42 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -207,7 +207,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, span, ecx.ty_ident(span, ecx.ident_of("str")), Some(static_), - ast::MutImmutable, + ast::Mutability::Immutable, ); let ty = ecx.ty( diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index a807fbb93fb..e32dcc99a0e 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -512,7 +512,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: P) -> P { let pat = if mutbl { - self.pat_ident_binding_mode(sp, ident, ast::BindingMode::ByValue(ast::MutMutable)) + let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Mutable); + self.pat_ident_binding_mode(sp, ident, binding_mode) } else { self.pat_ident(sp, ident) }; @@ -536,7 +537,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ex: P) -> P { let pat = if mutbl { - self.pat_ident_binding_mode(sp, ident, ast::BindingMode::ByValue(ast::MutMutable)) + let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Mutable); + self.pat_ident_binding_mode(sp, ident, binding_mode) } else { self.pat_ident(sp, ident) }; @@ -636,10 +638,10 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr(sp, ast::ExprKind::TupField(expr, id)) } fn expr_addr_of(&self, sp: Span, e: P) -> P { - self.expr(sp, ast::ExprKind::AddrOf(ast::MutImmutable, e)) + self.expr(sp, ast::ExprKind::AddrOf(ast::Mutability::Immutable, e)) } fn expr_mut_addr_of(&self, sp: Span, e: P) -> P { - self.expr(sp, ast::ExprKind::AddrOf(ast::MutMutable, e)) + self.expr(sp, ast::ExprKind::AddrOf(ast::Mutability::Mutable, e)) } fn expr_call(&self, span: Span, expr: P, args: Vec>) -> P { @@ -813,7 +815,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.pat(span, ast::PatLit(expr)) } fn pat_ident(&self, span: Span, ident: ast::Ident) -> P { - self.pat_ident_binding_mode(span, ident, ast::BindingMode::ByValue(ast::MutImmutable)) + let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Immutable); + self.pat_ident_binding_mode(span, ident, binding_mode) } fn pat_ident_binding_mode(&self, diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index a505b27e9db..850b4365256 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -896,7 +896,7 @@ mod tests { assert!(panictry!(parser.parse_pat()) == P(ast::Pat{ id: ast::DUMMY_NODE_ID, - node: ast::PatIdent(ast::BindingMode::ByValue(ast::MutImmutable), + node: ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable), Spanned{ span:sp(0, 1), node: str_to_ident("b") }, @@ -932,7 +932,7 @@ mod tests { pat: P(ast::Pat { id: ast::DUMMY_NODE_ID, node: ast::PatIdent( - ast::BindingMode::ByValue(ast::MutImmutable), + ast::BindingMode::ByValue(ast::Mutability::Immutable), Spanned{ span: sp(6,7), node: str_to_ident("b")}, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0875d054564..11638a3d424 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -27,7 +27,7 @@ use ast::{Ident, Inherited, ImplItem, Item, ItemKind}; use ast::{Lit, LitKind, UintTy}; use ast::Local; use ast::MacStmtStyle; -use ast::{MutImmutable, MutMutable, Mac_}; +use ast::Mac_; use ast::{MutTy, Mutability}; use ast::NamedField; use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange}; @@ -1417,16 +1417,16 @@ impl<'a> Parser<'a> { pub fn parse_ptr(&mut self) -> PResult<'a, MutTy> { let mutbl = if self.eat_keyword(keywords::Mut) { - MutMutable + Mutability::Mutable } else if self.eat_keyword(keywords::Const) { - MutImmutable + Mutability::Immutable } else { let span = self.last_span; self.span_err(span, "bare raw pointers are no longer allowed, you should \ likely use `*mut T`, but otherwise `*T` is now \ known as `*const T`"); - MutImmutable + Mutability::Immutable }; let t = try!(self.parse_ty()); Ok(MutTy { ty: t, mutbl: mutbl }) @@ -1924,9 +1924,9 @@ impl<'a> Parser<'a> { /// Parse mutability declaration (mut/const/imm) pub fn parse_mutability(&mut self) -> PResult<'a, Mutability> { if self.eat_keyword(keywords::Mut) { - Ok(MutMutable) + Ok(Mutability::Mutable) } else { - Ok(MutImmutable) + Ok(Mutability::Immutable) } } @@ -3350,10 +3350,10 @@ impl<'a> Parser<'a> { hi = self.last_span.hi; let bind_type = match (is_ref, is_mut) { - (true, true) => BindingMode::ByRef(MutMutable), - (true, false) => BindingMode::ByRef(MutImmutable), - (false, true) => BindingMode::ByValue(MutMutable), - (false, false) => BindingMode::ByValue(MutImmutable), + (true, true) => BindingMode::ByRef(Mutability::Mutable), + (true, false) => BindingMode::ByRef(Mutability::Immutable), + (false, true) => BindingMode::ByValue(Mutability::Mutable), + (false, false) => BindingMode::ByValue(Mutability::Immutable), }; let fieldpath = codemap::Spanned{span:self.last_span, node:fieldname}; let fieldpat = P(ast::Pat{ @@ -3448,7 +3448,7 @@ impl<'a> Parser<'a> { // At this point, token != _, &, &&, (, [ if self.eat_keyword(keywords::Mut) { // Parse mut ident @ pat - pat = try!(self.parse_pat_ident(BindingMode::ByValue(MutMutable))); + pat = try!(self.parse_pat_ident(BindingMode::ByValue(Mutability::Mutable))); } else if self.eat_keyword(keywords::Ref) { // Parse ref ident @ pat / ref mut ident @ pat let mutbl = try!(self.parse_mutability()); @@ -3481,7 +3481,8 @@ impl<'a> Parser<'a> { // Parse ident @ pat // This can give false positives and parse nullary enums, // they are dealt with later in resolve - pat = try!(self.parse_pat_ident(BindingMode::ByValue(MutImmutable))); + let binding_mode = BindingMode::ByValue(Mutability::Immutable); + pat = try!(self.parse_pat_ident(binding_mode)); } } else { let (qself, path) = if self.eat_lt() { @@ -4408,7 +4409,7 @@ impl<'a> Parser<'a> { if this.look_ahead(1, |t| t.is_keyword(keywords::SelfValue)) { this.bump(); - Ok(SelfKind::Region(None, MutImmutable, try!(this.expect_self_ident()))) + Ok(SelfKind::Region(None, Mutability::Immutable, try!(this.expect_self_ident()))) } else if this.look_ahead(1, |t| t.is_mutability()) && this.look_ahead(2, |t| t.is_keyword(keywords::SelfValue)) { this.bump(); @@ -4418,7 +4419,8 @@ impl<'a> Parser<'a> { this.look_ahead(2, |t| t.is_keyword(keywords::SelfValue)) { this.bump(); let lifetime = try!(this.parse_lifetime()); - Ok(SelfKind::Region(Some(lifetime), MutImmutable, try!(this.expect_self_ident()))) + let ident = try!(this.expect_self_ident()); + Ok(SelfKind::Region(Some(lifetime), Mutability::Immutable, ident)) } else if this.look_ahead(1, |t| t.is_lifetime()) && this.look_ahead(2, |t| t.is_mutability()) && this.look_ahead(3, |t| t.is_keyword(keywords::SelfValue)) { @@ -4439,7 +4441,7 @@ impl<'a> Parser<'a> { let mut self_ident_lo = self.span.lo; let mut self_ident_hi = self.span.hi; - let mut mutbl_self = MutImmutable; + let mut mutbl_self = Mutability::Immutable; let explicit_self = match self.token { token::BinOp(token::And) => { let eself = try!(maybe_parse_borrowed_explicit_self(self)); @@ -4454,7 +4456,7 @@ impl<'a> Parser<'a> { let _mutability = if self.token.is_mutability() { try!(self.parse_mutability()) } else { - MutImmutable + Mutability::Immutable }; if self.is_self_ident() { let span = self.span; @@ -5527,7 +5529,11 @@ impl<'a> Parser<'a> { if self.eat_keyword(keywords::Static) { // STATIC ITEM - let m = if self.eat_keyword(keywords::Mut) {MutMutable} else {MutImmutable}; + let m = if self.eat_keyword(keywords::Mut) { + Mutability::Mutable + } else { + Mutability::Immutable + }; let (ident, item_, extra_attrs) = try!(self.parse_item_const(Some(m))); let last_span = self.last_span; let item = self.mk_item(lo, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 8495853c2c9..b14117c9704 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -417,7 +417,7 @@ pub fn lit_to_string(l: &ast::Lit) -> String { } pub fn explicit_self_to_string(explicit_self: &ast::SelfKind) -> String { - to_string(|s| s.print_explicit_self(explicit_self, ast::MutImmutable).map(|_| {})) + to_string(|s| s.print_explicit_self(explicit_self, ast::Mutability::Immutable).map(|_| {})) } pub fn variant_to_string(var: &ast::Variant) -> String { @@ -965,8 +965,8 @@ impl<'a> State<'a> { ast::TyKind::Ptr(ref mt) => { try!(word(&mut self.s, "*")); match mt.mutbl { - ast::MutMutable => try!(self.word_nbsp("mut")), - ast::MutImmutable => try!(self.word_nbsp("const")), + ast::Mutability::Mutable => try!(self.word_nbsp("mut")), + ast::Mutability::Immutable => try!(self.word_nbsp("const")), } try!(self.print_type(&*mt.ty)); } @@ -1147,7 +1147,7 @@ impl<'a> State<'a> { ast::ItemKind::Static(ref ty, m, ref expr) => { try!(self.head(&visibility_qualified(item.vis, "static"))); - if m == ast::MutMutable { + if m == ast::Mutability::Mutable { try!(self.word_space("mut")); } try!(self.print_ident(item.ident)); @@ -2464,8 +2464,8 @@ impl<'a> State<'a> { try!(self.word_nbsp("ref")); try!(self.print_mutability(mutbl)); } - ast::BindingMode::ByValue(ast::MutImmutable) => {} - ast::BindingMode::ByValue(ast::MutMutable) => { + ast::BindingMode::ByValue(ast::Mutability::Immutable) => {} + ast::BindingMode::ByValue(ast::Mutability::Mutable) => { try!(self.word_nbsp("mut")); } } @@ -2534,7 +2534,7 @@ impl<'a> State<'a> { } ast::PatRegion(ref inner, mutbl) => { try!(word(&mut self.s, "&")); - if mutbl == ast::MutMutable { + if mutbl == ast::Mutability::Mutable { try!(word(&mut self.s, "mut ")); } try!(self.print_pat(&**inner)); @@ -2669,10 +2669,10 @@ impl<'a> State<'a> { let mut first = true; if let Some(explicit_self) = opt_explicit_self { let m = match *explicit_self { - ast::SelfKind::Static => ast::MutImmutable, + ast::SelfKind::Static => ast::Mutability::Immutable, _ => match decl.inputs[0].pat.node { ast::PatIdent(ast::BindingMode::ByValue(m), _, _) => m, - _ => ast::MutImmutable + _ => ast::Mutability::Immutable } }; first = !try!(self.print_explicit_self(explicit_self, m)); @@ -2946,8 +2946,8 @@ impl<'a> State<'a> { pub fn print_mutability(&mut self, mutbl: ast::Mutability) -> io::Result<()> { match mutbl { - ast::MutMutable => self.word_nbsp("mut"), - ast::MutImmutable => Ok(()), + ast::Mutability::Mutable => self.word_nbsp("mut"), + ast::Mutability::Immutable => Ok(()), } } diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index a817eb62af8..92ecadd7ae8 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -593,7 +593,7 @@ fn mk_tests(cx: &TestCtxt) -> P { let static_type = ecx.ty_rptr(sp, ecx.ty(sp, ast::TyKind::Vec(struct_type)), Some(static_lt), - ast::MutImmutable); + ast::Mutability::Immutable); // static TESTS: $static_type = &[...]; ecx.item_const(sp, ecx.ident_of("TESTS"), @@ -613,7 +613,7 @@ fn mk_test_descs(cx: &TestCtxt) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::AddrOf(ast::MutImmutable, + node: ast::ExprKind::AddrOf(ast::Mutability::Immutable, P(ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprKind::Vec(cx.testfns.iter().map(|test| { diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 917c6b1ab89..6e769cd3810 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -27,7 +27,7 @@ pub fn expand_deriving_debug(cx: &mut ExtCtxt, { // &mut ::std::fmt::Formatter let fmtr = Ptr(Box::new(Literal(path_std!(cx, core::fmt::Formatter))), - Borrowed(None, ast::MutMutable)); + Borrowed(None, ast::Mutability::Mutable)); let trait_def = TraitDef { span: span, diff --git a/src/libsyntax_ext/deriving/decodable.rs b/src/libsyntax_ext/deriving/decodable.rs index 4ea4f04623a..092f8548966 100644 --- a/src/libsyntax_ext/deriving/decodable.rs +++ b/src/libsyntax_ext/deriving/decodable.rs @@ -14,7 +14,7 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast; -use syntax::ast::{MetaItem, Expr, MutMutable}; +use syntax::ast::{MetaItem, Expr, Mutability}; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; @@ -72,7 +72,7 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt, }, explicit_self: None, args: vec!(Ptr(Box::new(Literal(Path::new_local("__D"))), - Borrowed(None, MutMutable))), + Borrowed(None, Mutability::Mutable))), ret_ty: Literal(Path::new_( pathvec_std!(cx, core::result::Result), None, diff --git a/src/libsyntax_ext/deriving/encodable.rs b/src/libsyntax_ext/deriving/encodable.rs index 14631659b0b..614a6381962 100644 --- a/src/libsyntax_ext/deriving/encodable.rs +++ b/src/libsyntax_ext/deriving/encodable.rs @@ -91,7 +91,7 @@ use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast::{MetaItem, Expr, ExprKind, MutMutable}; +use syntax::ast::{MetaItem, Expr, ExprKind, Mutability}; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt,Annotatable}; use syntax::ext::build::AstBuilder; @@ -148,7 +148,7 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt, }, explicit_self: borrowed_explicit_self(), args: vec!(Ptr(Box::new(Literal(Path::new_local("__S"))), - Borrowed(None, MutMutable))), + Borrowed(None, Mutability::Mutable))), ret_ty: Literal(Path::new_( pathvec_std!(cx, core::result::Result), None, diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 51091b84672..b316b1e7d86 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -864,7 +864,9 @@ impl<'a> MethodDef<'a> { let self_arg = match explicit_self.node { ast::SelfKind::Static => None, // creating fresh self id - _ => Some(ast::Arg::new_self(trait_.span, ast::MutImmutable, special_idents::self_)) + _ => Some(ast::Arg::new_self(trait_.span, + ast::Mutability::Immutable, + special_idents::self_)) }; let args = { let args = arg_types.into_iter().map(|(name, ty)| { @@ -942,7 +944,7 @@ impl<'a> MethodDef<'a> { struct_def, &format!("__self_{}", i), - ast::MutImmutable); + ast::Mutability::Immutable); patterns.push(pat); raw_fields.push(ident_expr); } @@ -1135,11 +1137,12 @@ impl<'a> MethodDef<'a> { let mut match_arms: Vec = variants.iter().enumerate() .map(|(index, variant)| { let mk_self_pat = |cx: &mut ExtCtxt, self_arg_name: &str| { - let (p, idents) = trait_.create_enum_variant_pattern(cx, type_ident, - &**variant, - self_arg_name, - ast::MutImmutable); - (cx.pat(sp, ast::PatRegion(p, ast::MutImmutable)), idents) + let (p, idents) = trait_.create_enum_variant_pattern( + cx, type_ident, + &**variant, + self_arg_name, + ast::Mutability::Immutable); + (cx.pat(sp, ast::PatRegion(p, ast::Mutability::Immutable)), idents) }; // A single arm has form (&VariantK, &VariantK, ...) => BodyK diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index e5b82fa1afc..a924cc06953 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -98,7 +98,7 @@ pub enum Ty<'a> { } pub fn borrowed_ptrty<'r>() -> PtrTy<'r> { - Borrowed(None, ast::MutImmutable) + Borrowed(None, ast::Mutability::Immutable) } pub fn borrowed<'r>(ty: Box>) -> Ty<'r> { Ptr(ty, borrowed_ptrty()) diff --git a/src/libsyntax_ext/deriving/hash.rs b/src/libsyntax_ext/deriving/hash.rs index 6bd21f7c0e0..371ba732b48 100644 --- a/src/libsyntax_ext/deriving/hash.rs +++ b/src/libsyntax_ext/deriving/hash.rs @@ -11,7 +11,7 @@ use deriving::generic::*; use deriving::generic::ty::*; -use syntax::ast::{MetaItem, Expr, MutMutable}; +use syntax::ast::{MetaItem, Expr, Mutability}; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; @@ -43,7 +43,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt, vec![path_std!(cx, core::hash::Hasher)])], }, explicit_self: borrowed_explicit_self(), - args: vec!(Ptr(Box::new(Literal(arg)), Borrowed(None, MutMutable))), + args: vec!(Ptr(Box::new(Literal(arg)), Borrowed(None, Mutability::Mutable))), ret_ty: nil_ty(), attributes: vec![], is_unsafe: false, diff --git a/src/libsyntax_ext/env.rs b/src/libsyntax_ext/env.rs index f1dd6854a3a..63ec9cac073 100644 --- a/src/libsyntax_ext/env.rs +++ b/src/libsyntax_ext/env.rs @@ -42,7 +42,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenT Some(cx.lifetime(sp, cx.ident_of( "'static").name)), - ast::MutImmutable)), + ast::Mutability::Immutable)), Vec::new())) } Ok(s) => { diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index a5ad143f15b..4e24eb9f6d7 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -450,10 +450,10 @@ impl<'a, 'b> Context<'a, 'b> { let ty = ecx.ty_rptr(sp, ecx.ty(sp, ast::TyKind::Vec(piece_ty)), Some(ecx.lifetime(sp, special_idents::static_lifetime.name)), - ast::MutImmutable); + ast::Mutability::Immutable); let slice = ecx.expr_vec_slice(sp, pieces); // static instead of const to speed up codegen by not requiring this to be inlined - let st = ast::ItemKind::Static(ty, ast::MutImmutable, slice); + let st = ast::ItemKind::Static(ty, ast::Mutability::Immutable, slice); let name = ecx.ident_of(name); let item = ecx.item(sp, name, vec![], st); @@ -480,7 +480,7 @@ impl<'a, 'b> Context<'a, 'b> { self.fmtsp, self.ecx.ty_ident(self.fmtsp, self.ecx.ident_of("str")), Some(static_lifetime), - ast::MutImmutable); + ast::Mutability::Immutable); let pieces = Context::static_array(self.ecx, "__STATIC_FMTSTR", piece_ty, -- cgit 1.4.1-3-g733a5 From 8b3856b1bc1c23969e5d8983f25cf85698a5c2b1 Mon Sep 17 00:00:00 2001 From: Oliver 'ker' Schneider Date: Tue, 9 Feb 2016 18:01:08 +0100 Subject: [breaking-change] don't glob export ast::StrStyle variants --- src/librustc_front/print/pprust.rs | 12 ++++++------ src/libsyntax/ast.rs | 5 ++--- src/libsyntax/attr.rs | 4 ++-- src/libsyntax/ext/build.rs | 2 +- src/libsyntax/ext/quote.rs | 2 +- src/libsyntax/parse/parser.rs | 10 ++++++---- src/libsyntax/print/pprust.rs | 16 ++++++++-------- src/libsyntax_ext/deriving/debug.rs | 5 ++--- 8 files changed, 28 insertions(+), 28 deletions(-) (limited to 'src/libsyntax_ext/deriving/debug.rs') diff --git a/src/librustc_front/print/pprust.rs b/src/librustc_front/print/pprust.rs index 091352bb8f8..cc43e3ae56e 100644 --- a/src/librustc_front/print/pprust.rs +++ b/src/librustc_front/print/pprust.rs @@ -652,7 +652,7 @@ impl<'a> State<'a> { if let Some(p) = *optional_path { let val = p.as_str(); if val.contains("-") { - try!(self.print_string(&val, ast::CookedStr)); + try!(self.print_string(&val, ast::StrStyle::Cooked)); } else { try!(self.print_name(p)); } @@ -1510,9 +1510,9 @@ impl<'a> State<'a> { try!(self.commasep(Inconsistent, &a.outputs, |s, out| { match out.constraint.slice_shift_char() { Some(('=', operand)) if out.is_rw => { - try!(s.print_string(&format!("+{}", operand), ast::CookedStr)) + try!(s.print_string(&format!("+{}", operand), ast::StrStyle::Cooked)) } - _ => try!(s.print_string(&out.constraint, ast::CookedStr)), + _ => try!(s.print_string(&out.constraint, ast::StrStyle::Cooked)), } try!(s.popen()); try!(s.print_expr(&*out.expr)); @@ -1523,7 +1523,7 @@ impl<'a> State<'a> { try!(self.word_space(":")); try!(self.commasep(Inconsistent, &a.inputs, |s, &(ref co, ref o)| { - try!(s.print_string(&co, ast::CookedStr)); + try!(s.print_string(&co, ast::StrStyle::Cooked)); try!(s.popen()); try!(s.print_expr(&**o)); try!(s.pclose()); @@ -1533,7 +1533,7 @@ impl<'a> State<'a> { try!(self.word_space(":")); try!(self.commasep(Inconsistent, &a.clobbers, |s, co| { - try!(s.print_string(&co, ast::CookedStr)); + try!(s.print_string(&co, ast::StrStyle::Cooked)); Ok(()) })); @@ -1552,7 +1552,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)); try!(self.word_space(":")); try!(self.commasep(Inconsistent, &*options, |s, &co| { - try!(s.print_string(co, ast::CookedStr)); + try!(s.print_string(co, ast::StrStyle::Cooked)); Ok(()) })); } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 79b465a02b8..713f5c9a7be 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -12,7 +12,6 @@ pub use self::Pat_::*; pub use self::PathListItem_::*; -pub use self::StrStyle::*; pub use self::StructFieldKind::*; pub use self::TyParamBound::*; pub use self::UnsafeSource::*; @@ -1246,11 +1245,11 @@ pub struct Mac_ { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum StrStyle { /// A regular string, like `"foo"` - CookedStr, + Cooked, /// A raw string, like `r##"foo"##` /// /// The uint is the number of `#` symbols used - RawStr(usize) + Raw(usize) } /// A literal diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 53ab4e1b6d5..cc5f30e2184 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -173,7 +173,7 @@ impl AttributeMethods for Attribute { pub fn mk_name_value_item_str(name: InternedString, value: InternedString) -> P { - let value_lit = dummy_spanned(ast::LitKind::Str(value, ast::CookedStr)); + let value_lit = dummy_spanned(ast::LitKind::Str(value, ast::StrStyle::Cooked)); mk_name_value_item(name, value_lit) } @@ -225,7 +225,7 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos, hi: BytePos) -> Attribute { let style = doc_comment_style(&text); - let lit = spanned(lo, hi, ast::LitKind::Str(text, ast::CookedStr)); + let lit = spanned(lo, hi, ast::LitKind::Str(text, ast::StrStyle::Cooked)); let attr = Attribute_ { id: id, style: style, diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 0f1f92f3fb8..161443c6eb0 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -715,7 +715,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_addr_of(sp, self.expr_vec(sp, exprs)) } fn expr_str(&self, sp: Span, s: InternedString) -> P { - self.expr_lit(sp, ast::LitKind::Str(s, ast::CookedStr)) + self.expr_lit(sp, ast::LitKind::Str(s, ast::StrStyle::Cooked)) } fn expr_cast(&self, sp: Span, expr: P, ty: P) -> P { diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index d8099ff004b..57db1347021 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -219,7 +219,7 @@ pub mod rt { impl ToTokens for str { fn to_tokens(&self, cx: &ExtCtxt) -> Vec { let lit = ast::LitKind::Str( - token::intern_and_get_ident(self), ast::CookedStr); + token::intern_and_get_ident(self), ast::StrStyle::Cooked); dummy_spanned(lit).to_tokens(cx) } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a13c79bdda1..afab3a0711b 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1544,13 +1544,13 @@ impl<'a> Parser<'a> { token::Str_(s) => { (true, LitKind::Str(token::intern_and_get_ident(&parse::str_lit(&s.as_str())), - ast::CookedStr)) + ast::StrStyle::Cooked)) } token::StrRaw(s, n) => { (true, LitKind::Str( token::intern_and_get_ident(&parse::raw_str_lit(&s.as_str())), - ast::RawStr(n))) + ast::StrStyle::Raw(n))) } token::ByteStr(i) => (true, LitKind::ByteStr(parse::byte_str_lit(&i.as_str()))), @@ -5966,10 +5966,12 @@ impl<'a> Parser<'a> { Option)> { let ret = match self.token { token::Literal(token::Str_(s), suf) => { - (self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)), ast::CookedStr, suf) + let s = self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)); + (s, ast::StrStyle::Cooked, suf) } token::Literal(token::StrRaw(s, n), suf) => { - (self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)), ast::RawStr(n), suf) + let s = self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)); + (s, ast::StrStyle::Raw(n), suf) } _ => return None }; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 78a4bbd962f..bb3bc2d78e3 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -682,10 +682,10 @@ pub trait PrintState<'a> { fn print_string(&mut self, st: &str, style: ast::StrStyle) -> io::Result<()> { let st = match style { - ast::CookedStr => { + ast::StrStyle::Cooked => { (format!("\"{}\"", st.escape_default())) } - ast::RawStr(n) => { + ast::StrStyle::Raw(n) => { (format!("r{delim}\"{string}\"{delim}", delim=repeat("#", n), string=st)) @@ -1123,7 +1123,7 @@ impl<'a> State<'a> { if let Some(p) = *optional_path { let val = p.as_str(); if val.contains("-") { - try!(self.print_string(&val, ast::CookedStr)); + try!(self.print_string(&val, ast::StrStyle::Cooked)); } else { try!(self.print_name(p)); } @@ -2215,9 +2215,9 @@ impl<'a> State<'a> { match out.constraint.slice_shift_char() { Some(('=', operand)) if out.is_rw => { try!(s.print_string(&format!("+{}", operand), - ast::CookedStr)) + ast::StrStyle::Cooked)) } - _ => try!(s.print_string(&out.constraint, ast::CookedStr)) + _ => try!(s.print_string(&out.constraint, ast::StrStyle::Cooked)) } try!(s.popen()); try!(s.print_expr(&*out.expr)); @@ -2229,7 +2229,7 @@ impl<'a> State<'a> { try!(self.commasep(Inconsistent, &a.inputs, |s, &(ref co, ref o)| { - try!(s.print_string(&co, ast::CookedStr)); + try!(s.print_string(&co, ast::StrStyle::Cooked)); try!(s.popen()); try!(s.print_expr(&**o)); try!(s.pclose()); @@ -2240,7 +2240,7 @@ impl<'a> State<'a> { try!(self.commasep(Inconsistent, &a.clobbers, |s, co| { - try!(s.print_string(&co, ast::CookedStr)); + try!(s.print_string(&co, ast::StrStyle::Cooked)); Ok(()) })); @@ -2260,7 +2260,7 @@ impl<'a> State<'a> { try!(self.word_space(":")); try!(self.commasep(Inconsistent, &*options, |s, &co| { - try!(s.print_string(co, ast::CookedStr)); + try!(s.print_string(co, ast::StrStyle::Cooked)); Ok(()) })); } diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 6e769cd3810..858066cb626 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -71,8 +71,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, // We want to make sure we have the expn_id set so that we can use unstable methods let span = Span { expn_id: cx.backtrace(), .. span }; - let name = cx.expr_lit(span, ast::LitKind::Str(ident.name.as_str(), - ast::StrStyle::CookedStr)); + let name = cx.expr_lit(span, ast::LitKind::Str(ident.name.as_str(), ast::StrStyle::Cooked)); let builder = token::str_to_ident("builder"); let builder_expr = cx.expr_ident(span, builder.clone()); @@ -114,7 +113,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, for field in fields { let name = cx.expr_lit(field.span, ast::LitKind::Str( field.name.unwrap().name.as_str(), - ast::StrStyle::CookedStr)); + ast::StrStyle::Cooked)); // Use double indirection to make sure this works for unsized types let field = cx.expr_addr_of(field.span, field.self_.clone()); -- cgit 1.4.1-3-g733a5