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/format.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsyntax_ext/format.rs') diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 77bf90abbcc..449be3bc50c 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -457,7 +457,7 @@ impl<'a, 'b> Context<'a, 'b> { let name = ecx.ident_of(name); let item = ecx.item(sp, name, vec![], st); - let decl = respan(sp, ast::DeclItem(item)); + let decl = respan(sp, ast::DeclKind::Item(item)); // Wrap the declaration in a block so that it forms a single expression. ecx.expr_block(ecx.block(sp, -- cgit 1.4.1-3-g733a5 From 80bf9ae18a133571d694aa866b824dcaea875d32 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 8 Feb 2016 16:05:05 +0100 Subject: [breaking-change] don't glob export ast::Expr_ variants --- src/librustc_driver/pretty.rs | 2 +- src/librustc_front/lowering.rs | 74 ++++++++-------- src/librustc_lint/unused.rs | 45 +++++----- src/librustc_passes/const_fn.rs | 2 +- src/librustc_passes/no_asm.rs | 4 +- src/librustc_trans/save/dump_csv.rs | 20 ++--- src/librustc_trans/save/mod.rs | 8 +- src/libsyntax/ast.rs | 79 ++++++++--------- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/config.rs | 4 +- src/libsyntax/ext/base.rs | 6 +- src/libsyntax/ext/build.rs | 52 +++++------ src/libsyntax/ext/expand.rs | 40 ++++----- src/libsyntax/ext/quote.rs | 2 +- src/libsyntax/feature_gate.rs | 8 +- src/libsyntax/fold.rs | 126 +++++++++++++------------- src/libsyntax/parse/classify.rs | 18 ++-- src/libsyntax/parse/mod.rs | 14 +-- src/libsyntax/parse/parser.rs | 142 ++++++++++++++---------------- src/libsyntax/print/pprust.rs | 96 ++++++++++---------- src/libsyntax/ptr.rs | 2 +- src/libsyntax/test.rs | 4 +- src/libsyntax/visit.rs | 66 +++++++------- src/libsyntax_ext/asm.rs | 2 +- src/libsyntax_ext/concat.rs | 2 +- src/libsyntax_ext/concat_idents.rs | 2 +- src/libsyntax_ext/deriving/encodable.rs | 16 ++-- src/libsyntax_ext/deriving/generic/mod.rs | 8 +- src/libsyntax_ext/format.rs | 2 +- 29 files changed, 420 insertions(+), 428 deletions(-) (limited to 'src/libsyntax_ext/format.rs') diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 53438e3fca4..0f6ba63d54b 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -653,7 +653,7 @@ impl fold::Folder for ReplaceBodyWithLoop { let empty_block = expr_to_block(BlockCheckMode::Default, None); let loop_expr = P(ast::Expr { - node: ast::ExprLoop(empty_block, None), + node: ast::ExprKind::Loop(empty_block, None), id: ast::DUMMY_NODE_ID, span: codemap::DUMMY_SP, attrs: None, diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index de2da35f856..fe44ba7a646 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -986,12 +986,12 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P { // } // // But for now there are type-inference issues doing that. - ExprBox(ref e) => { + ExprKind::Box(ref e) => { hir::ExprBox(lower_expr(lctx, e)) } // Desugar ExprBox: `in (PLACE) EXPR` - ExprInPlace(ref placer, ref value_expr) => { + ExprKind::InPlace(ref placer, ref value_expr) => { // to: // // let p = PLACE; @@ -1099,57 +1099,57 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P { }); } - ExprVec(ref exprs) => { + ExprKind::Vec(ref exprs) => { hir::ExprVec(exprs.iter().map(|x| lower_expr(lctx, x)).collect()) } - ExprRepeat(ref expr, ref count) => { + ExprKind::Repeat(ref expr, ref count) => { let expr = lower_expr(lctx, expr); let count = lower_expr(lctx, count); hir::ExprRepeat(expr, count) } - ExprTup(ref elts) => { + ExprKind::Tup(ref elts) => { hir::ExprTup(elts.iter().map(|x| lower_expr(lctx, x)).collect()) } - ExprCall(ref f, ref args) => { + ExprKind::Call(ref f, ref args) => { let f = lower_expr(lctx, f); hir::ExprCall(f, args.iter().map(|x| lower_expr(lctx, x)).collect()) } - ExprMethodCall(i, ref tps, ref args) => { + ExprKind::MethodCall(i, ref tps, ref args) => { let tps = tps.iter().map(|x| lower_ty(lctx, x)).collect(); let args = args.iter().map(|x| lower_expr(lctx, x)).collect(); hir::ExprMethodCall(respan(i.span, i.node.name), tps, args) } - ExprBinary(binop, ref lhs, ref rhs) => { + ExprKind::Binary(binop, ref lhs, ref rhs) => { let binop = lower_binop(lctx, binop); let lhs = lower_expr(lctx, lhs); let rhs = lower_expr(lctx, rhs); hir::ExprBinary(binop, lhs, rhs) } - ExprUnary(op, ref ohs) => { + ExprKind::Unary(op, ref ohs) => { let op = lower_unop(lctx, op); let ohs = lower_expr(lctx, ohs); hir::ExprUnary(op, ohs) } - ExprLit(ref l) => hir::ExprLit(P((**l).clone())), - ExprCast(ref expr, ref ty) => { + ExprKind::Lit(ref l) => hir::ExprLit(P((**l).clone())), + ExprKind::Cast(ref expr, ref ty) => { let expr = lower_expr(lctx, expr); hir::ExprCast(expr, lower_ty(lctx, ty)) } - ExprType(ref expr, ref ty) => { + ExprKind::Type(ref expr, ref ty) => { let expr = lower_expr(lctx, expr); hir::ExprType(expr, lower_ty(lctx, ty)) } - ExprAddrOf(m, ref ohs) => { + ExprKind::AddrOf(m, ref ohs) => { let m = lower_mutability(lctx, m); let ohs = lower_expr(lctx, ohs); hir::ExprAddrOf(m, ohs) } // More complicated than you might expect because the else branch // might be `if let`. - ExprIf(ref cond, ref blk, ref else_opt) => { + ExprKind::If(ref cond, ref blk, ref else_opt) => { let else_opt = else_opt.as_ref().map(|els| { match els.node { - ExprIfLet(..) => { + ExprKind::IfLet(..) => { cache_ids(lctx, e.id, |lctx| { // wrap the if-let expr in a block let span = els.span; @@ -1171,47 +1171,47 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P { hir::ExprIf(lower_expr(lctx, cond), lower_block(lctx, blk), else_opt) } - ExprWhile(ref cond, ref body, opt_ident) => { + ExprKind::While(ref cond, ref body, opt_ident) => { hir::ExprWhile(lower_expr(lctx, cond), lower_block(lctx, body), opt_ident.map(|ident| lower_ident(lctx, ident))) } - ExprLoop(ref body, opt_ident) => { + ExprKind::Loop(ref body, opt_ident) => { hir::ExprLoop(lower_block(lctx, body), opt_ident.map(|ident| lower_ident(lctx, ident))) } - ExprMatch(ref expr, ref arms) => { + ExprKind::Match(ref expr, ref arms) => { hir::ExprMatch(lower_expr(lctx, expr), arms.iter().map(|x| lower_arm(lctx, x)).collect(), hir::MatchSource::Normal) } - ExprClosure(capture_clause, ref decl, ref body) => { + ExprKind::Closure(capture_clause, ref decl, ref body) => { hir::ExprClosure(lower_capture_clause(lctx, capture_clause), lower_fn_decl(lctx, decl), lower_block(lctx, body)) } - ExprBlock(ref blk) => hir::ExprBlock(lower_block(lctx, blk)), - ExprAssign(ref el, ref er) => { + ExprKind::Block(ref blk) => hir::ExprBlock(lower_block(lctx, blk)), + ExprKind::Assign(ref el, ref er) => { hir::ExprAssign(lower_expr(lctx, el), lower_expr(lctx, er)) } - ExprAssignOp(op, ref el, ref er) => { + ExprKind::AssignOp(op, ref el, ref er) => { hir::ExprAssignOp(lower_binop(lctx, op), lower_expr(lctx, el), lower_expr(lctx, er)) } - ExprField(ref el, ident) => { + ExprKind::Field(ref el, ident) => { hir::ExprField(lower_expr(lctx, el), respan(ident.span, ident.node.name)) } - ExprTupField(ref el, ident) => { + ExprKind::TupField(ref el, ident) => { hir::ExprTupField(lower_expr(lctx, el), ident) } - ExprIndex(ref el, ref er) => { + ExprKind::Index(ref el, ref er) => { hir::ExprIndex(lower_expr(lctx, el), lower_expr(lctx, er)) } - ExprRange(ref e1, ref e2) => { + ExprKind::Range(ref e1, ref e2) => { hir::ExprRange(e1.as_ref().map(|x| lower_expr(lctx, x)), e2.as_ref().map(|x| lower_expr(lctx, x))) } - ExprPath(ref qself, ref path) => { + ExprKind::Path(ref qself, ref path) => { let hir_qself = qself.as_ref().map(|&QSelf { ref ty, position }| { hir::QSelf { ty: lower_ty(lctx, ty), @@ -1220,14 +1220,14 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P { }); hir::ExprPath(hir_qself, lower_path_full(lctx, path, qself.is_none())) } - ExprBreak(opt_ident) => hir::ExprBreak(opt_ident.map(|sp_ident| { + ExprKind::Break(opt_ident) => hir::ExprBreak(opt_ident.map(|sp_ident| { respan(sp_ident.span, lower_ident(lctx, sp_ident.node)) })), - ExprAgain(opt_ident) => hir::ExprAgain(opt_ident.map(|sp_ident| { + ExprKind::Again(opt_ident) => hir::ExprAgain(opt_ident.map(|sp_ident| { respan(sp_ident.span, lower_ident(lctx, sp_ident.node)) })), - ExprRet(ref e) => hir::ExprRet(e.as_ref().map(|x| lower_expr(lctx, x))), - ExprInlineAsm(InlineAsm { + ExprKind::Ret(ref e) => hir::ExprRet(e.as_ref().map(|x| lower_expr(lctx, x))), + ExprKind::InlineAsm(InlineAsm { ref inputs, ref outputs, ref asm, @@ -1259,12 +1259,12 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P { dialect: dialect, expn_id: expn_id, }), - ExprStruct(ref path, ref fields, ref maybe_expr) => { + ExprKind::Struct(ref path, ref fields, ref maybe_expr) => { hir::ExprStruct(lower_path(lctx, path), fields.iter().map(|x| lower_field(lctx, x)).collect(), maybe_expr.as_ref().map(|x| lower_expr(lctx, x))) } - ExprParen(ref ex) => { + ExprKind::Paren(ref ex) => { // merge attributes into the inner expression. return lower_expr(lctx, ex).map(|mut ex| { ex.attrs.update(|attrs| { @@ -1276,7 +1276,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P { // Desugar ExprIfLet // From: `if let = []` - ExprIfLet(ref pat, ref sub_expr, ref body, ref else_opt) => { + ExprKind::IfLet(ref pat, ref sub_expr, ref body, ref else_opt) => { // to: // // match { @@ -1364,7 +1364,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P { // Desugar ExprWhileLet // From: `[opt_ident]: while let = ` - ExprWhileLet(ref pat, ref sub_expr, ref body, opt_ident) => { + ExprKind::WhileLet(ref pat, ref sub_expr, ref body, opt_ident) => { // to: // // [opt_ident]: loop { @@ -1410,7 +1410,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P { // Desugar ExprForLoop // From: `[opt_ident]: for in ` - ExprForLoop(ref pat, ref head, ref body, opt_ident) => { + ExprKind::ForLoop(ref pat, ref head, ref body, opt_ident) => { // to: // // { @@ -1524,7 +1524,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P { }); } - ExprMac(_) => panic!("Shouldn't exist here"), + ExprKind::Mac(_) => panic!("Shouldn't exist here"), }, span: e.span, attrs: e.attrs.clone(), diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 628dcb9217a..bbd714fad06 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -293,7 +293,7 @@ pub struct UnusedParens; impl UnusedParens { fn check_unused_parens_core(&self, cx: &EarlyContext, value: &ast::Expr, msg: &str, struct_lit_needs_parens: bool) { - if let ast::ExprParen(ref inner) = value.node { + if let ast::ExprKind::Paren(ref inner) = value.node { let necessary = struct_lit_needs_parens && contains_exterior_struct_lit(&**inner); if !necessary { cx.span_lint(UNUSED_PARENS, value.span, @@ -308,26 +308,26 @@ impl UnusedParens { /// y: 1 }) == foo` does not. fn contains_exterior_struct_lit(value: &ast::Expr) -> bool { match value.node { - ast::ExprStruct(..) => true, + ast::ExprKind::Struct(..) => true, - ast::ExprAssign(ref lhs, ref rhs) | - ast::ExprAssignOp(_, ref lhs, ref rhs) | - ast::ExprBinary(_, ref lhs, ref rhs) => { + ast::ExprKind::Assign(ref lhs, ref rhs) | + ast::ExprKind::AssignOp(_, ref lhs, ref rhs) | + ast::ExprKind::Binary(_, ref lhs, ref rhs) => { // X { y: 1 } + X { y: 2 } contains_exterior_struct_lit(&**lhs) || contains_exterior_struct_lit(&**rhs) } - ast::ExprUnary(_, ref x) | - ast::ExprCast(ref x, _) | - ast::ExprType(ref x, _) | - ast::ExprField(ref x, _) | - ast::ExprTupField(ref x, _) | - ast::ExprIndex(ref x, _) => { + ast::ExprKind::Unary(_, ref x) | + ast::ExprKind::Cast(ref x, _) | + ast::ExprKind::Type(ref x, _) | + ast::ExprKind::Field(ref x, _) | + ast::ExprKind::TupField(ref x, _) | + ast::ExprKind::Index(ref x, _) => { // &X { y: 1 }, X { y: 1 }.y contains_exterior_struct_lit(&**x) } - ast::ExprMethodCall(_, _, ref exprs) => { + ast::ExprKind::MethodCall(_, _, ref exprs) => { // X { y: 1 }.bar(...) contains_exterior_struct_lit(&*exprs[0]) } @@ -346,17 +346,18 @@ impl LintPass for UnusedParens { impl EarlyLintPass for UnusedParens { fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) { + use syntax::ast::ExprKind::*; let (value, msg, struct_lit_needs_parens) = match e.node { - ast::ExprIf(ref cond, _, _) => (cond, "`if` condition", true), - ast::ExprWhile(ref cond, _, _) => (cond, "`while` condition", true), - ast::ExprIfLet(_, ref cond, _, _) => (cond, "`if let` head expression", true), - ast::ExprWhileLet(_, ref cond, _, _) => (cond, "`while let` head expression", true), - ast::ExprForLoop(_, ref cond, _, _) => (cond, "`for` head expression", true), - ast::ExprMatch(ref head, _) => (head, "`match` head expression", true), - ast::ExprRet(Some(ref value)) => (value, "`return` value", false), - ast::ExprAssign(_, ref value) => (value, "assigned value", false), - ast::ExprAssignOp(_, _, ref value) => (value, "assigned value", false), - ast::ExprInPlace(_, ref value) => (value, "emplacement value", false), + If(ref cond, _, _) => (cond, "`if` condition", true), + While(ref cond, _, _) => (cond, "`while` condition", true), + IfLet(_, ref cond, _, _) => (cond, "`if let` head expression", true), + WhileLet(_, ref cond, _, _) => (cond, "`while let` head expression", true), + ForLoop(_, ref cond, _, _) => (cond, "`for` head expression", true), + Match(ref head, _) => (head, "`match` head expression", true), + Ret(Some(ref value)) => (value, "`return` value", false), + Assign(_, ref value) => (value, "assigned value", false), + AssignOp(_, _, ref value) => (value, "assigned value", false), + InPlace(_, ref value) => (value, "emplacement value", false), _ => return }; self.check_unused_parens_core(cx, &**value, msg, struct_lit_needs_parens); diff --git a/src/librustc_passes/const_fn.rs b/src/librustc_passes/const_fn.rs index 6d9c03bc824..5ec00439df2 100644 --- a/src/librustc_passes/const_fn.rs +++ b/src/librustc_passes/const_fn.rs @@ -38,7 +38,7 @@ impl<'a, 'v> Visitor<'v> for CheckBlock<'a> { CheckConstFn{ sess: self.sess}.visit_block(block); } fn visit_expr(&mut self, e: &'v ast::Expr) { - if let ast::ExprClosure(..) = e.node { + if let ast::ExprKind::Closure(..) = e.node { CheckConstFn{ sess: self.sess}.visit_expr(e); } else { visit::walk_expr(self, e); diff --git a/src/librustc_passes/no_asm.rs b/src/librustc_passes/no_asm.rs index 3022d9fb9e3..90f92c25b05 100644 --- a/src/librustc_passes/no_asm.rs +++ b/src/librustc_passes/no_asm.rs @@ -32,8 +32,8 @@ struct CheckNoAsm<'a> { impl<'a, 'v> Visitor<'v> for CheckNoAsm<'a> { fn visit_expr(&mut self, e: &ast::Expr) { match e.node { - ast::ExprInlineAsm(_) => span_err!(self.sess, e.span, E0472, - "asm! is unsupported on this target"), + ast::ExprKind::InlineAsm(_) => span_err!(self.sess, e.span, E0472, + "asm! is unsupported on this target"), _ => {}, } visit::walk_expr(self, e) diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index 9714e4f02b1..e8a0e4a8d42 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -1083,23 +1083,23 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { fn visit_expr(&mut self, ex: &ast::Expr) { self.process_macro_use(ex.span, ex.id); match ex.node { - ast::ExprCall(ref _f, ref _args) => { + ast::ExprKind::Call(ref _f, ref _args) => { // Don't need to do anything for function calls, // because just walking the callee path does what we want. visit::walk_expr(self, ex); } - ast::ExprPath(_, ref path) => { + ast::ExprKind::Path(_, ref path) => { self.process_path(ex.id, path, None); visit::walk_expr(self, ex); } - ast::ExprStruct(ref path, ref fields, ref base) => { + ast::ExprKind::Struct(ref path, ref fields, ref base) => { let hir_expr = lower_expr(self.save_ctxt.lcx, ex); let adt = self.tcx.expr_ty(&hir_expr).ty_adt_def().unwrap(); let def = self.tcx.resolve_expr(&hir_expr); self.process_struct_lit(ex, path, fields, adt.variant_of_def(def), base) } - ast::ExprMethodCall(_, _, ref args) => self.process_method_call(ex, args), - ast::ExprField(ref sub_ex, _) => { + ast::ExprKind::MethodCall(_, _, ref args) => self.process_method_call(ex, args), + ast::ExprKind::Field(ref sub_ex, _) => { self.visit_expr(&sub_ex); if let Some(field_data) = self.save_ctxt.get_expr_data(ex) { @@ -1111,7 +1111,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { field_data.scope); } } - ast::ExprTupField(ref sub_ex, idx) => { + ast::ExprKind::TupField(ref sub_ex, idx) => { self.visit_expr(&**sub_ex); let hir_node = lower_expr(self.save_ctxt.lcx, sub_ex); @@ -1131,7 +1131,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { ty)), } } - ast::ExprClosure(_, ref decl, ref body) => { + ast::ExprKind::Closure(_, ref decl, ref body) => { let mut id = String::from("$"); id.push_str(&ex.id.to_string()); self.process_formals(&decl.inputs, &id); @@ -1148,14 +1148,14 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { // walk the body self.nest(ex.id, |v| v.visit_block(&**body)); } - ast::ExprForLoop(ref pattern, ref subexpression, ref block, _) | - ast::ExprWhileLet(ref pattern, ref subexpression, ref block, _) => { + ast::ExprKind::ForLoop(ref pattern, ref subexpression, ref block, _) | + ast::ExprKind::WhileLet(ref pattern, ref subexpression, ref block, _) => { let value = self.span.snippet(mk_sp(ex.span.lo, subexpression.span.hi)); self.process_var_decl(pattern, value); visit::walk_expr(self, subexpression); visit::walk_block(self, block); } - ast::ExprIfLet(ref pattern, ref subexpression, ref block, ref opt_else) => { + ast::ExprKind::IfLet(ref pattern, ref subexpression, ref block, ref opt_else) => { let value = self.span.snippet(mk_sp(ex.span.lo, subexpression.span.hi)); self.process_var_decl(pattern, value); visit::walk_expr(self, subexpression); diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 11c82d30246..116051f6fe5 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -487,7 +487,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { return None; } match expr.node { - ast::ExprField(ref sub_ex, ident) => { + ast::ExprKind::Field(ref sub_ex, ident) => { let hir_node = lowering::lower_expr(self.lcx, sub_ex); match self.tcx.expr_ty_adjusted(&hir_node).sty { ty::TyStruct(def, _) => { @@ -507,7 +507,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } } - ast::ExprStruct(ref path, _, _) => { + ast::ExprKind::Struct(ref path, _, _) => { let hir_node = lowering::lower_expr(self.lcx, expr); match self.tcx.expr_ty_adjusted(&hir_node).sty { ty::TyStruct(def, _) => { @@ -527,7 +527,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } } - ast::ExprMethodCall(..) => { + ast::ExprKind::MethodCall(..) => { let method_call = ty::MethodCall::expr(expr.id); let method_id = self.tcx.tables.borrow().method_map[&method_call].def_id; let (def_id, decl_id) = match self.tcx.impl_or_trait_item(method_id).container() { @@ -544,7 +544,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { decl_id: decl_id, })) } - ast::ExprPath(_, ref path) => { + ast::ExprKind::Path(_, ref path) => { self.get_path_data(expr.id, path) } _ => { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 979c8568712..36543bd35ca 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,7 +10,6 @@ // The Rust abstract syntax tree. -pub use self::Expr_::*; pub use self::FloatTy::*; pub use self::ForeignItem_::*; pub use self::IntTy::*; @@ -880,7 +879,7 @@ pub enum UnsafeSource { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash,)] pub struct Expr { pub id: NodeId, - pub node: Expr_, + pub node: ExprKind, pub span: Span, pub attrs: ThinAttributes } @@ -901,18 +900,18 @@ impl fmt::Debug for Expr { } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum Expr_ { +pub enum ExprKind { /// A `box x` expression. - ExprBox(P), + Box(P), /// First expr is the place; second expr is the value. - ExprInPlace(P, P), + InPlace(P, P), /// An array (`[a, b, c, d]`) - ExprVec(Vec>), + Vec(Vec>), /// A function call /// /// The first field resolves to the function itself, /// and the second field is the list of arguments - ExprCall(P, Vec>), + Call(P, Vec>), /// A method call (`x.foo::(a, b, c, d)`) /// /// The `SpannedIdent` is the identifier for the method name. @@ -924,109 +923,109 @@ pub enum Expr_ { /// and the remaining elements are the rest of the arguments. /// /// Thus, `x.foo::(a, b, c, d)` is represented as - /// `ExprMethodCall(foo, [Bar, Baz], [x, a, b, c, d])`. - ExprMethodCall(SpannedIdent, Vec>, Vec>), + /// `ExprKind::MethodCall(foo, [Bar, Baz], [x, a, b, c, d])`. + MethodCall(SpannedIdent, Vec>, Vec>), /// A tuple (`(a, b, c ,d)`) - ExprTup(Vec>), + Tup(Vec>), /// A binary operation (For example: `a + b`, `a * b`) - ExprBinary(BinOp, P, P), + Binary(BinOp, P, P), /// A unary operation (For example: `!x`, `*x`) - ExprUnary(UnOp, P), + Unary(UnOp, P), /// A literal (For example: `1u8`, `"foo"`) - ExprLit(P), + Lit(P), /// A cast (`foo as f64`) - ExprCast(P, P), - ExprType(P, P), + Cast(P, P), + Type(P, P), /// An `if` block, with an optional else block /// /// `if expr { block } else { expr }` - ExprIf(P, P, Option>), + If(P, P, Option>), /// An `if let` expression with an optional else block /// /// `if let pat = expr { block } else { expr }` /// /// This is desugared to a `match` expression. - ExprIfLet(P, P, P, Option>), + IfLet(P, P, P, Option>), /// A while loop, with an optional label /// /// `'label: while expr { block }` - ExprWhile(P, P, Option), + While(P, P, Option), /// A while-let loop, with an optional label /// /// `'label: while let pat = expr { block }` /// /// This is desugared to a combination of `loop` and `match` expressions. - ExprWhileLet(P, P, P, Option), + WhileLet(P, P, P, Option), /// A for loop, with an optional label /// /// `'label: for pat in expr { block }` /// /// This is desugared to a combination of `loop` and `match` expressions. - ExprForLoop(P, P, P, Option), + ForLoop(P, P, P, Option), /// Conditionless loop (can be exited with break, continue, or return) /// /// `'label: loop { block }` - ExprLoop(P, Option), + Loop(P, Option), /// A `match` block. - ExprMatch(P, Vec), + Match(P, Vec), /// A closure (for example, `move |a, b, c| {a + b + c}`) - ExprClosure(CaptureBy, P, P), + Closure(CaptureBy, P, P), /// A block (`{ ... }`) - ExprBlock(P), + Block(P), /// An assignment (`a = foo()`) - ExprAssign(P, P), + Assign(P, P), /// An assignment with an operator /// /// For example, `a += 1`. - ExprAssignOp(BinOp, P, P), + AssignOp(BinOp, P, P), /// Access of a named struct field (`obj.foo`) - ExprField(P, SpannedIdent), + Field(P, SpannedIdent), /// Access of an unnamed field of a struct or tuple-struct /// /// For example, `foo.0`. - ExprTupField(P, Spanned), + TupField(P, Spanned), /// An indexing operation (`foo[2]`) - ExprIndex(P, P), + Index(P, P), /// A range (`1..2`, `1..`, or `..2`) - ExprRange(Option>, Option>), + Range(Option>, Option>), /// Variable reference, possibly containing `::` and/or type /// parameters, e.g. foo::bar::. /// /// Optionally "qualified", /// e.g. ` as SomeTrait>::SomeType`. - ExprPath(Option, Path), + Path(Option, Path), /// A referencing operation (`&a` or `&mut a`) - ExprAddrOf(Mutability, P), + AddrOf(Mutability, P), /// A `break`, with an optional label to break - ExprBreak(Option), + Break(Option), /// A `continue`, with an optional label - ExprAgain(Option), + Again(Option), /// A `return`, with an optional value to be returned - ExprRet(Option>), + Ret(Option>), /// Output of the `asm!()` macro - ExprInlineAsm(InlineAsm), + InlineAsm(InlineAsm), /// A macro invocation; pre-expansion - ExprMac(Mac), + Mac(Mac), /// A struct literal expression. /// /// For example, `Foo {x: 1, y: 2}`, or /// `Foo {x: 1, .. base}`, where `base` is the `Option`. - ExprStruct(Path, Vec, Option>), + Struct(Path, Vec, Option>), /// An array literal constructed from one repeated element. /// /// For example, `[1u8; 5]`. The first expression is the element /// to be repeated; the second is the number of times to repeat it. - ExprRepeat(P, P), + Repeat(P, P), /// No-op: used solely so we can pretty-print faithfully - ExprParen(P) + Paren(P), } /// The explicit Self type in a "qualified path". The actual diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 03dc25e1b3c..8ccff527b88 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -27,7 +27,7 @@ pub fn path_name_i(idents: &[Ident]) -> String { } pub fn is_path(e: P) -> bool { - match e.node { ExprPath(..) => true, _ => false } + match e.node { ExprKind::Path(..) => true, _ => false } } diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index e849de0b1c6..8d74990fc32 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -212,8 +212,8 @@ fn fold_expr(cx: &mut Context, expr: P) -> P where fold::noop_fold_expr(ast::Expr { id: id, node: match node { - ast::ExprMatch(m, arms) => { - ast::ExprMatch(m, arms.into_iter() + ast::ExprKind::Match(m, arms) => { + ast::ExprKind::Match(m, arms.into_iter() .filter(|a| (cx.in_cfg)(&a.attrs)) .collect()) } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 107626c54cc..33414a697a7 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -303,7 +303,7 @@ impl MacResult for MacEager { return Some(p); } if let Some(e) = self.expr { - if let ast::ExprLit(_) = e.node { + if let ast::ExprKind::Lit(_) = e.node { return Some(P(ast::Pat { id: ast::DUMMY_NODE_ID, span: e.span, @@ -349,7 +349,7 @@ impl DummyResult { pub fn raw_expr(sp: Span) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprLit(P(codemap::respan(sp, ast::LitBool(false)))), + node: ast::ExprKind::Lit(P(codemap::respan(sp, ast::LitBool(false)))), span: sp, attrs: None, }) @@ -773,7 +773,7 @@ pub fn expr_to_string(cx: &mut ExtCtxt, expr: P, err_msg: &str) // we want to be able to handle e.g. concat("foo", "bar") let expr = cx.expander().fold_expr(expr); match expr.node { - ast::ExprLit(ref l) => match l.node { + ast::ExprKind::Lit(ref l) => match l.node { ast::LitStr(ref s, style) => return Some(((*s).clone(), style)), _ => cx.span_err(l.span, err_msg) }, diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 3a69b84ab3c..446c90f310d 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -108,7 +108,7 @@ pub trait AstBuilder { expr: Option>) -> P; // expressions - fn expr(&self, span: Span, node: ast::Expr_) -> P; + fn expr(&self, span: Span, node: ast::ExprKind) -> P; fn expr_path(&self, path: ast::Path) -> P; fn expr_qpath(&self, span: Span, qself: ast::QSelf, path: ast::Path) -> P; fn expr_ident(&self, span: Span, id: ast::Ident) -> P; @@ -578,7 +578,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { }) } - fn expr(&self, span: Span, node: ast::Expr_) -> P { + fn expr(&self, span: Span, node: ast::ExprKind) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, node: node, @@ -588,12 +588,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn expr_path(&self, path: ast::Path) -> P { - self.expr(path.span, ast::ExprPath(None, path)) + self.expr(path.span, ast::ExprKind::Path(None, path)) } /// Constructs a QPath expression. fn expr_qpath(&self, span: Span, qself: ast::QSelf, path: ast::Path) -> P { - self.expr(span, ast::ExprPath(Some(qself), path)) + self.expr(span, ast::ExprKind::Path(Some(qself), path)) } fn expr_ident(&self, span: Span, id: ast::Ident) -> P { @@ -605,14 +605,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn expr_binary(&self, sp: Span, op: ast::BinOpKind, lhs: P, rhs: P) -> P { - self.expr(sp, ast::ExprBinary(Spanned { node: op, span: sp }, lhs, rhs)) + self.expr(sp, ast::ExprKind::Binary(Spanned { node: op, span: sp }, lhs, rhs)) } fn expr_deref(&self, sp: Span, e: P) -> P { self.expr_unary(sp, UnOp::Deref, e) } fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P) -> P { - self.expr(sp, ast::ExprUnary(op, e)) + self.expr(sp, ast::ExprKind::Unary(op, e)) } fn expr_field_access(&self, sp: Span, expr: P, ident: ast::Ident) -> P { @@ -623,7 +623,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { }; let id = Spanned { node: ident, span: field_span }; - self.expr(sp, ast::ExprField(expr, id)) + self.expr(sp, ast::ExprKind::Field(expr, id)) } fn expr_tup_field_access(&self, sp: Span, expr: P, idx: usize) -> P { let field_span = Span { @@ -633,21 +633,21 @@ impl<'a> AstBuilder for ExtCtxt<'a> { }; let id = Spanned { node: idx, span: field_span }; - self.expr(sp, ast::ExprTupField(expr, id)) + self.expr(sp, ast::ExprKind::TupField(expr, id)) } fn expr_addr_of(&self, sp: Span, e: P) -> P { - self.expr(sp, ast::ExprAddrOf(ast::MutImmutable, e)) + self.expr(sp, ast::ExprKind::AddrOf(ast::MutImmutable, e)) } fn expr_mut_addr_of(&self, sp: Span, e: P) -> P { - self.expr(sp, ast::ExprAddrOf(ast::MutMutable, e)) + self.expr(sp, ast::ExprKind::AddrOf(ast::MutMutable, e)) } fn expr_call(&self, span: Span, expr: P, args: Vec>) -> P { - self.expr(span, ast::ExprCall(expr, args)) + self.expr(span, ast::ExprKind::Call(expr, args)) } fn expr_call_ident(&self, span: Span, id: ast::Ident, args: Vec>) -> P { - self.expr(span, ast::ExprCall(self.expr_ident(span, id), args)) + self.expr(span, ast::ExprKind::Call(self.expr_ident(span, id), args)) } fn expr_call_global(&self, sp: Span, fn_path: Vec , args: Vec> ) -> P { @@ -660,16 +660,16 @@ impl<'a> AstBuilder for ExtCtxt<'a> { mut args: Vec> ) -> P { let id = Spanned { node: ident, span: span }; args.insert(0, expr); - self.expr(span, ast::ExprMethodCall(id, Vec::new(), args)) + self.expr(span, ast::ExprKind::MethodCall(id, Vec::new(), args)) } fn expr_block(&self, b: P) -> P { - self.expr(b.span, ast::ExprBlock(b)) + self.expr(b.span, ast::ExprKind::Block(b)) } fn field_imm(&self, span: Span, name: Ident, e: P) -> ast::Field { ast::Field { ident: respan(span, name), expr: e, span: span } } fn expr_struct(&self, span: Span, path: ast::Path, fields: Vec) -> P { - self.expr(span, ast::ExprStruct(path, fields, None)) + self.expr(span, ast::ExprKind::Struct(path, fields, None)) } fn expr_struct_ident(&self, span: Span, id: ast::Ident, fields: Vec) -> P { @@ -677,7 +677,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P { - self.expr(sp, ast::ExprLit(P(respan(sp, lit)))) + 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::TyUs))) @@ -697,7 +697,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn expr_vec(&self, sp: Span, exprs: Vec>) -> P { - self.expr(sp, ast::ExprVec(exprs)) + self.expr(sp, ast::ExprKind::Vec(exprs)) } fn expr_vec_ng(&self, sp: Span) -> P { self.expr_call_global(sp, self.std_path(&["vec", "Vec", "new"]), @@ -711,7 +711,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn expr_cast(&self, sp: Span, expr: P, ty: P) -> P { - self.expr(sp, ast::ExprCast(expr, ty)) + self.expr(sp, ast::ExprKind::Cast(expr, ty)) } @@ -728,12 +728,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn expr_break(&self, sp: Span) -> P { - self.expr(sp, ast::ExprBreak(None)) + self.expr(sp, ast::ExprKind::Break(None)) } fn expr_tuple(&self, sp: Span, exprs: Vec>) -> P { - self.expr(sp, ast::ExprTup(exprs)) + self.expr(sp, ast::ExprKind::Tup(exprs)) } fn expr_fail(&self, span: Span, msg: InternedString) -> P { @@ -785,7 +785,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { let err_inner_expr = self.expr_call(sp, self.expr_path(err_path), vec!(binding_expr.clone())); // return Err(__try_var) - let err_expr = self.expr(sp, ast::ExprRet(Some(err_inner_expr))); + let err_expr = self.expr(sp, ast::ExprKind::Ret(Some(err_inner_expr))); // Ok(__try_var) => __try_var let ok_arm = self.arm(sp, vec!(ok_pat), binding_expr); @@ -868,29 +868,29 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn expr_match(&self, span: Span, arg: P, arms: Vec) -> P { - self.expr(span, ast::ExprMatch(arg, arms)) + self.expr(span, ast::ExprKind::Match(arg, arms)) } fn expr_if(&self, span: Span, cond: P, then: P, els: Option>) -> P { let els = els.map(|x| self.expr_block(self.block_expr(x))); - self.expr(span, ast::ExprIf(cond, self.block_expr(then), els)) + self.expr(span, ast::ExprKind::If(cond, self.block_expr(then), els)) } fn expr_loop(&self, span: Span, block: P) -> P { - self.expr(span, ast::ExprLoop(block, None)) + self.expr(span, ast::ExprKind::Loop(block, None)) } fn lambda_fn_decl(&self, span: Span, fn_decl: P, blk: P) -> P { - self.expr(span, ast::ExprClosure(ast::CaptureBy::Ref, fn_decl, blk)) + self.expr(span, ast::ExprKind::Closure(ast::CaptureBy::Ref, fn_decl, blk)) } fn lambda(&self, span: Span, ids: Vec, blk: P) -> P { let fn_decl = self.fn_decl( ids.iter().map(|id| self.arg(span, *id, self.ty_infer(span))).collect(), self.ty_infer(span)); - self.expr(span, ast::ExprClosure(ast::CaptureBy::Ref, fn_decl, blk)) + self.expr(span, ast::ExprKind::Closure(ast::CaptureBy::Ref, fn_decl, blk)) } fn lambda0(&self, span: Span, blk: P) -> P { self.lambda(span, Vec::new(), blk) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 460d564a70e..69b932aa72b 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -42,7 +42,7 @@ pub fn expand_expr(e: P, fld: &mut MacroExpander) -> P { // expr_mac should really be expr_ext or something; it's the // entry-point for all syntax extensions. - ast::ExprMac(mac) => { + ast::ExprKind::Mac(mac) => { // Assert that we drop any macro attributes on the floor here drop(attrs); @@ -69,7 +69,7 @@ pub fn expand_expr(e: P, fld: &mut MacroExpander) -> P { }) } - ast::ExprInPlace(placer, value_expr) => { + ast::ExprKind::InPlace(placer, value_expr) => { // Ensure feature-gate is enabled feature_gate::check_for_placement_in( fld.cx.ecfg.features, @@ -78,18 +78,18 @@ pub fn expand_expr(e: P, fld: &mut MacroExpander) -> P { let placer = fld.fold_expr(placer); let value_expr = fld.fold_expr(value_expr); - fld.cx.expr(span, ast::ExprInPlace(placer, value_expr)) + fld.cx.expr(span, ast::ExprKind::InPlace(placer, value_expr)) .with_attrs(fold_thin_attrs(attrs, fld)) } - ast::ExprWhile(cond, body, opt_ident) => { + ast::ExprKind::While(cond, body, opt_ident) => { let cond = fld.fold_expr(cond); let (body, opt_ident) = expand_loop_block(body, opt_ident, fld); - fld.cx.expr(span, ast::ExprWhile(cond, body, opt_ident)) + fld.cx.expr(span, ast::ExprKind::While(cond, body, opt_ident)) .with_attrs(fold_thin_attrs(attrs, fld)) } - ast::ExprWhileLet(pat, expr, body, opt_ident) => { + ast::ExprKind::WhileLet(pat, expr, body, opt_ident) => { let pat = fld.fold_pat(pat); let expr = fld.fold_expr(expr); @@ -103,17 +103,17 @@ pub fn expand_expr(e: P, fld: &mut MacroExpander) -> P { }); assert!(rewritten_pats.len() == 1); - fld.cx.expr(span, ast::ExprWhileLet(rewritten_pats.remove(0), expr, body, opt_ident)) - .with_attrs(fold_thin_attrs(attrs, fld)) + let wl = ast::ExprKind::WhileLet(rewritten_pats.remove(0), expr, body, opt_ident); + fld.cx.expr(span, wl).with_attrs(fold_thin_attrs(attrs, fld)) } - ast::ExprLoop(loop_block, opt_ident) => { + ast::ExprKind::Loop(loop_block, opt_ident) => { let (loop_block, opt_ident) = expand_loop_block(loop_block, opt_ident, fld); - fld.cx.expr(span, ast::ExprLoop(loop_block, opt_ident)) + fld.cx.expr(span, ast::ExprKind::Loop(loop_block, opt_ident)) .with_attrs(fold_thin_attrs(attrs, fld)) } - ast::ExprForLoop(pat, head, body, opt_ident) => { + ast::ExprKind::ForLoop(pat, head, body, opt_ident) => { let pat = fld.fold_pat(pat); // Hygienic renaming of the for loop body (for loop binds its pattern). @@ -127,11 +127,11 @@ pub fn expand_expr(e: P, fld: &mut MacroExpander) -> P { assert!(rewritten_pats.len() == 1); let head = fld.fold_expr(head); - fld.cx.expr(span, ast::ExprForLoop(rewritten_pats.remove(0), head, body, opt_ident)) - .with_attrs(fold_thin_attrs(attrs, fld)) + let fl = ast::ExprKind::ForLoop(rewritten_pats.remove(0), head, body, opt_ident); + fld.cx.expr(span, fl).with_attrs(fold_thin_attrs(attrs, fld)) } - ast::ExprIfLet(pat, sub_expr, body, else_opt) => { + ast::ExprKind::IfLet(pat, sub_expr, body, else_opt) => { let pat = fld.fold_pat(pat); // Hygienic renaming of the body. @@ -146,14 +146,14 @@ pub fn expand_expr(e: P, fld: &mut MacroExpander) -> P { let else_opt = else_opt.map(|else_opt| fld.fold_expr(else_opt)); let sub_expr = fld.fold_expr(sub_expr); - fld.cx.expr(span, ast::ExprIfLet(rewritten_pats.remove(0), sub_expr, body, else_opt)) - .with_attrs(fold_thin_attrs(attrs, fld)) + let il = ast::ExprKind::IfLet(rewritten_pats.remove(0), sub_expr, body, else_opt); + fld.cx.expr(span, il).with_attrs(fold_thin_attrs(attrs, fld)) } - ast::ExprClosure(capture_clause, fn_decl, block) => { + ast::ExprKind::Closure(capture_clause, fn_decl, block) => { let (rewritten_fn_decl, rewritten_block) = expand_and_rename_fn_decl_and_block(fn_decl, block, fld); - let new_node = ast::ExprClosure(capture_clause, + let new_node = ast::ExprKind::Closure(capture_clause, rewritten_fn_decl, rewritten_block); P(ast::Expr{id:id, node: new_node, span: fld.new_span(span), @@ -1427,7 +1427,7 @@ mod tests { impl<'v> Visitor<'v> for PathExprFinderContext { fn visit_expr(&mut self, expr: &ast::Expr) { - if let ast::ExprPath(None, ref p) = expr.node { + if let ast::ExprKind::Path(None, ref p) = expr.node { self.path_accumulator.push(p.clone()); } visit::walk_expr(self, expr); @@ -1694,7 +1694,7 @@ mod tests { 0) } - // closure arg hygiene (ExprClosure) + // closure arg hygiene (ExprKind::Closure) // expands to fn f(){(|x_1 : i32| {(x_2 + x_1)})(3);} #[test] fn closure_arg_hygiene(){ diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index bc7dc67e1ba..d7a47b40506 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -240,7 +240,7 @@ pub mod rt { // FIXME: This is wrong P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprLit(P(self.clone())), + node: ast::ExprKind::Lit(P(self.clone())), span: DUMMY_SP, attrs: None, }).to_tokens(cx) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 55087c25703..17eb43e2068 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -815,11 +815,11 @@ impl<'a, 'v> Visitor<'v> for MacroVisitor<'a> { // But we keep these checks as a pre-expansion check to catch // uses in e.g. conditionalized code. - if let ast::ExprBox(_) = e.node { + if let ast::ExprKind::Box(_) = e.node { self.context.gate_feature("box_syntax", e.span, EXPLAIN_BOX_SYNTAX); } - if let ast::ExprInPlace(..) = e.node { + if let ast::ExprKind::InPlace(..) = e.node { self.context.gate_feature("placement_in_syntax", e.span, EXPLAIN_PLACEMENT_IN); } @@ -988,13 +988,13 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { fn visit_expr(&mut self, e: &ast::Expr) { match e.node { - ast::ExprBox(_) => { + ast::ExprKind::Box(_) => { self.gate_feature("box_syntax", e.span, "box expression syntax is experimental; \ you can call `Box::new` instead."); } - ast::ExprType(..) => { + ast::ExprKind::Type(..) => { self.gate_feature("type_ascription", e.span, "type ascription is experimental"); } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 3332941d0ad..8cd2d24102f 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1168,131 +1168,131 @@ pub fn noop_fold_expr(Expr {id, node, span, attrs}: Expr, folder: &mu Expr { id: folder.new_id(id), node: match node { - ExprBox(e) => { - ExprBox(folder.fold_expr(e)) + ExprKind::Box(e) => { + ExprKind::Box(folder.fold_expr(e)) } - ExprInPlace(p, e) => { - ExprInPlace(folder.fold_expr(p), folder.fold_expr(e)) + ExprKind::InPlace(p, e) => { + ExprKind::InPlace(folder.fold_expr(p), folder.fold_expr(e)) } - ExprVec(exprs) => { - ExprVec(folder.fold_exprs(exprs)) + ExprKind::Vec(exprs) => { + ExprKind::Vec(folder.fold_exprs(exprs)) } - ExprRepeat(expr, count) => { - ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count)) + ExprKind::Repeat(expr, count) => { + ExprKind::Repeat(folder.fold_expr(expr), folder.fold_expr(count)) } - ExprTup(exprs) => ExprTup(folder.fold_exprs(exprs)), - ExprCall(f, args) => { - ExprCall(folder.fold_expr(f), + ExprKind::Tup(exprs) => ExprKind::Tup(folder.fold_exprs(exprs)), + ExprKind::Call(f, args) => { + ExprKind::Call(folder.fold_expr(f), folder.fold_exprs(args)) } - ExprMethodCall(i, tps, args) => { - ExprMethodCall( + ExprKind::MethodCall(i, tps, args) => { + ExprKind::MethodCall( respan(folder.new_span(i.span), folder.fold_ident(i.node)), tps.move_map(|x| folder.fold_ty(x)), folder.fold_exprs(args)) } - ExprBinary(binop, lhs, rhs) => { - ExprBinary(binop, + ExprKind::Binary(binop, lhs, rhs) => { + ExprKind::Binary(binop, folder.fold_expr(lhs), folder.fold_expr(rhs)) } - ExprUnary(binop, ohs) => { - ExprUnary(binop, folder.fold_expr(ohs)) + ExprKind::Unary(binop, ohs) => { + ExprKind::Unary(binop, folder.fold_expr(ohs)) } - ExprLit(l) => ExprLit(l), - ExprCast(expr, ty) => { - ExprCast(folder.fold_expr(expr), folder.fold_ty(ty)) + ExprKind::Lit(l) => ExprKind::Lit(l), + ExprKind::Cast(expr, ty) => { + ExprKind::Cast(folder.fold_expr(expr), folder.fold_ty(ty)) } - ExprType(expr, ty) => { - ExprType(folder.fold_expr(expr), folder.fold_ty(ty)) + ExprKind::Type(expr, ty) => { + ExprKind::Type(folder.fold_expr(expr), folder.fold_ty(ty)) } - ExprAddrOf(m, ohs) => ExprAddrOf(m, folder.fold_expr(ohs)), - ExprIf(cond, tr, fl) => { - ExprIf(folder.fold_expr(cond), + ExprKind::AddrOf(m, ohs) => ExprKind::AddrOf(m, folder.fold_expr(ohs)), + ExprKind::If(cond, tr, fl) => { + ExprKind::If(folder.fold_expr(cond), folder.fold_block(tr), fl.map(|x| folder.fold_expr(x))) } - ExprIfLet(pat, expr, tr, fl) => { - ExprIfLet(folder.fold_pat(pat), + ExprKind::IfLet(pat, expr, tr, fl) => { + ExprKind::IfLet(folder.fold_pat(pat), folder.fold_expr(expr), folder.fold_block(tr), fl.map(|x| folder.fold_expr(x))) } - ExprWhile(cond, body, opt_ident) => { - ExprWhile(folder.fold_expr(cond), + ExprKind::While(cond, body, opt_ident) => { + ExprKind::While(folder.fold_expr(cond), folder.fold_block(body), opt_ident.map(|i| folder.fold_ident(i))) } - ExprWhileLet(pat, expr, body, opt_ident) => { - ExprWhileLet(folder.fold_pat(pat), + ExprKind::WhileLet(pat, expr, body, opt_ident) => { + ExprKind::WhileLet(folder.fold_pat(pat), folder.fold_expr(expr), folder.fold_block(body), opt_ident.map(|i| folder.fold_ident(i))) } - ExprForLoop(pat, iter, body, opt_ident) => { - ExprForLoop(folder.fold_pat(pat), + ExprKind::ForLoop(pat, iter, body, opt_ident) => { + ExprKind::ForLoop(folder.fold_pat(pat), folder.fold_expr(iter), folder.fold_block(body), opt_ident.map(|i| folder.fold_ident(i))) } - ExprLoop(body, opt_ident) => { - ExprLoop(folder.fold_block(body), + ExprKind::Loop(body, opt_ident) => { + ExprKind::Loop(folder.fold_block(body), opt_ident.map(|i| folder.fold_ident(i))) } - ExprMatch(expr, arms) => { - ExprMatch(folder.fold_expr(expr), + ExprKind::Match(expr, arms) => { + ExprKind::Match(folder.fold_expr(expr), arms.move_map(|x| folder.fold_arm(x))) } - ExprClosure(capture_clause, decl, body) => { - ExprClosure(capture_clause, + ExprKind::Closure(capture_clause, decl, body) => { + ExprKind::Closure(capture_clause, folder.fold_fn_decl(decl), folder.fold_block(body)) } - ExprBlock(blk) => ExprBlock(folder.fold_block(blk)), - ExprAssign(el, er) => { - ExprAssign(folder.fold_expr(el), folder.fold_expr(er)) + ExprKind::Block(blk) => ExprKind::Block(folder.fold_block(blk)), + ExprKind::Assign(el, er) => { + ExprKind::Assign(folder.fold_expr(el), folder.fold_expr(er)) } - ExprAssignOp(op, el, er) => { - ExprAssignOp(op, + ExprKind::AssignOp(op, el, er) => { + ExprKind::AssignOp(op, folder.fold_expr(el), folder.fold_expr(er)) } - ExprField(el, ident) => { - ExprField(folder.fold_expr(el), + ExprKind::Field(el, ident) => { + ExprKind::Field(folder.fold_expr(el), respan(folder.new_span(ident.span), folder.fold_ident(ident.node))) } - ExprTupField(el, ident) => { - ExprTupField(folder.fold_expr(el), + ExprKind::TupField(el, ident) => { + ExprKind::TupField(folder.fold_expr(el), respan(folder.new_span(ident.span), folder.fold_usize(ident.node))) } - ExprIndex(el, er) => { - ExprIndex(folder.fold_expr(el), folder.fold_expr(er)) + ExprKind::Index(el, er) => { + ExprKind::Index(folder.fold_expr(el), folder.fold_expr(er)) } - ExprRange(e1, e2) => { - ExprRange(e1.map(|x| folder.fold_expr(x)), + ExprKind::Range(e1, e2) => { + ExprKind::Range(e1.map(|x| folder.fold_expr(x)), e2.map(|x| folder.fold_expr(x))) } - ExprPath(qself, path) => { + ExprKind::Path(qself, path) => { let qself = qself.map(|QSelf { ty, position }| { QSelf { ty: folder.fold_ty(ty), position: position } }); - ExprPath(qself, folder.fold_path(path)) + ExprKind::Path(qself, folder.fold_path(path)) } - ExprBreak(opt_ident) => ExprBreak(opt_ident.map(|label| + ExprKind::Break(opt_ident) => ExprKind::Break(opt_ident.map(|label| respan(folder.new_span(label.span), folder.fold_ident(label.node))) ), - ExprAgain(opt_ident) => ExprAgain(opt_ident.map(|label| + ExprKind::Again(opt_ident) => ExprKind::Again(opt_ident.map(|label| respan(folder.new_span(label.span), folder.fold_ident(label.node))) ), - ExprRet(e) => ExprRet(e.map(|x| folder.fold_expr(x))), - ExprInlineAsm(InlineAsm { + ExprKind::Ret(e) => ExprKind::Ret(e.map(|x| folder.fold_expr(x))), + ExprKind::InlineAsm(InlineAsm { inputs, outputs, asm, @@ -1302,7 +1302,7 @@ pub fn noop_fold_expr(Expr {id, node, span, attrs}: Expr, folder: &mu alignstack, dialect, expn_id, - }) => ExprInlineAsm(InlineAsm { + }) => ExprKind::InlineAsm(InlineAsm { inputs: inputs.move_map(|(c, input)| { (c, folder.fold_expr(input)) }), @@ -1322,13 +1322,13 @@ pub fn noop_fold_expr(Expr {id, node, span, attrs}: Expr, folder: &mu dialect: dialect, expn_id: expn_id, }), - ExprMac(mac) => ExprMac(folder.fold_mac(mac)), - ExprStruct(path, fields, maybe_expr) => { - ExprStruct(folder.fold_path(path), + ExprKind::Mac(mac) => ExprKind::Mac(folder.fold_mac(mac)), + ExprKind::Struct(path, fields, maybe_expr) => { + ExprKind::Struct(folder.fold_path(path), fields.move_map(|x| folder.fold_field(x)), maybe_expr.map(|x| folder.fold_expr(x))) }, - ExprParen(ex) => ExprParen(folder.fold_expr(ex)) + ExprKind::Paren(ex) => ExprKind::Paren(folder.fold_expr(ex)) }, span: folder.new_span(span), attrs: attrs.map_thin_attrs(|v| fold_attrs(v, folder)), diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 82b8730e10f..325fe64203c 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -23,21 +23,21 @@ use ast::{self, BlockCheckMode}; /// isn't parsed as (if true {...} else {...} | x) | 5 pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool { match e.node { - ast::ExprIf(..) | - ast::ExprIfLet(..) | - ast::ExprMatch(..) | - ast::ExprBlock(_) | - ast::ExprWhile(..) | - ast::ExprWhileLet(..) | - ast::ExprLoop(..) | - ast::ExprForLoop(..) => false, + ast::ExprKind::If(..) | + ast::ExprKind::IfLet(..) | + ast::ExprKind::Match(..) | + ast::ExprKind::Block(_) | + ast::ExprKind::While(..) | + ast::ExprKind::WhileLet(..) | + ast::ExprKind::Loop(..) | + ast::ExprKind::ForLoop(..) => false, _ => true, } } pub fn expr_is_simple_block(e: &ast::Expr) -> bool { match e.node { - ast::ExprBlock(ref block) => block.rules == BlockCheckMode::Default, + ast::ExprKind::Block(ref block) => block.rules == BlockCheckMode::Default, _ => false, } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index a47ca51a98a..9ad5dafbf8b 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -703,7 +703,7 @@ mod tests { assert!(string_to_expr("a".to_string()) == P(ast::Expr{ id: ast::DUMMY_NODE_ID, - node: ast::ExprPath(None, ast::Path { + node: ast::ExprKind::Path(None, ast::Path { span: sp(0, 1), global: false, segments: vec!( @@ -722,7 +722,7 @@ mod tests { assert!(string_to_expr("::a::b".to_string()) == P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprPath(None, ast::Path { + node: ast::ExprKind::Path(None, ast::Path { span: sp(0, 6), global: true, segments: vec!( @@ -852,9 +852,9 @@ mod tests { assert!(string_to_expr("return d".to_string()) == P(ast::Expr{ id: ast::DUMMY_NODE_ID, - node:ast::ExprRet(Some(P(ast::Expr{ + node:ast::ExprKind::Ret(Some(P(ast::Expr{ id: ast::DUMMY_NODE_ID, - node:ast::ExprPath(None, ast::Path{ + node:ast::ExprKind::Path(None, ast::Path{ span: sp(7, 8), global: false, segments: vec!( @@ -877,7 +877,7 @@ mod tests { Some(P(Spanned{ node: ast::StmtExpr(P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprPath(None, ast::Path { + node: ast::ExprKind::Path(None, ast::Path { span:sp(0,1), global:false, segments: vec!( @@ -968,7 +968,7 @@ mod tests { stmts: vec!(P(Spanned{ node: ast::StmtSemi(P(ast::Expr{ id: ast::DUMMY_NODE_ID, - node: ast::ExprPath(None, + node: ast::ExprKind::Path(None, ast::Path{ span:sp(17,18), global:false, @@ -1110,7 +1110,7 @@ mod tests { "foo!( fn main() { body } )".to_string(), vec![], &sess); let tts = match expr.node { - ast::ExprMac(ref mac) => mac.node.tts.clone(), + ast::ExprKind::Mac(ref mac) => mac.node.tts.clone(), _ => panic!("not a macro"), }; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 98b1cc21ef8..df73e8815ed 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -20,14 +20,8 @@ use ast::{BlockCheckMode, CaptureBy}; use ast::{Constness, ConstTraitItem, Crate, CrateConfig}; use ast::{Decl, DeclKind}; use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf}; -use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; -use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox}; -use ast::{ExprBreak, ExprCall, ExprCast, ExprInPlace}; -use ast::{ExprField, ExprTupField, ExprClosure, ExprIf, ExprIfLet, ExprIndex}; -use ast::{ExprLit, ExprLoop, ExprMac, ExprRange}; -use ast::{ExprMethodCall, ExprParen, ExprPath}; -use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprType, ExprUnary}; -use ast::{ExprVec, ExprWhile, ExprWhileLet, ExprForLoop, Field, FnDecl}; +use ast::{Expr, ExprKind}; +use ast::{Field, FnDecl}; use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, FunctionRetTy}; use ast::{Ident, Inherited, ImplItem, Item, Item_, ItemStatic}; use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl, ItemConst}; @@ -140,7 +134,7 @@ macro_rules! maybe_whole_expr { _ => unreachable!() }; let span = $p.span; - Some($p.mk_expr(span.lo, span.hi, ExprPath(None, pt), None)) + Some($p.mk_expr(span.lo, span.hi, ExprKind::Path(None, pt), None)) } token::Interpolated(token::NtBlock(_)) => { // FIXME: The following avoids an issue with lexical borrowck scopes, @@ -150,7 +144,7 @@ macro_rules! maybe_whole_expr { _ => unreachable!() }; let span = $p.span; - Some($p.mk_expr(span.lo, span.hi, ExprBlock(b), None)) + Some($p.mk_expr(span.lo, span.hi, ExprKind::Block(b), None)) } _ => None }; @@ -508,7 +502,7 @@ impl<'a> Parser<'a> { pub fn commit_expr(&mut self, e: &Expr, edible: &[token::Token], inedible: &[token::Token]) -> PResult<'a, ()> { debug!("commit_expr {:?}", e); - if let ExprPath(..) = e.node { + if let ExprKind::Path(..) = e.node { // might be unit-struct construction; check for recoverableinput error. let expected = edible.iter() .cloned() @@ -1529,7 +1523,7 @@ impl<'a> Parser<'a> { match *tok { token::Interpolated(token::NtExpr(ref v)) => { match v.node { - ExprLit(ref lit) => { Ok(lit.node.clone()) } + ExprKind::Lit(ref lit) => { Ok(lit.node.clone()) } _ => { return self.unexpected_last(tok); } } } @@ -1605,7 +1599,7 @@ impl<'a> Parser<'a> { let lo = self.span.lo; let literal = P(try!(self.parse_lit())); let hi = self.last_span.hi; - let expr = self.mk_expr(lo, hi, ExprLit(literal), None); + let expr = self.mk_expr(lo, hi, ExprKind::Lit(literal), None); if minus_present { let minus_hi = self.last_span.hi; @@ -1957,7 +1951,7 @@ impl<'a> Parser<'a> { } pub fn mk_expr(&mut self, lo: BytePos, hi: BytePos, - node: Expr_, attrs: ThinAttributes) -> P { + node: ExprKind, attrs: ThinAttributes) -> P { P(Expr { id: ast::DUMMY_NODE_ID, node: node, @@ -1966,55 +1960,55 @@ impl<'a> Parser<'a> { }) } - pub fn mk_unary(&mut self, unop: ast::UnOp, expr: P) -> ast::Expr_ { - ExprUnary(unop, expr) + pub fn mk_unary(&mut self, unop: ast::UnOp, expr: P) -> ast::ExprKind { + ExprKind::Unary(unop, expr) } - pub fn mk_binary(&mut self, binop: ast::BinOp, lhs: P, rhs: P) -> ast::Expr_ { - ExprBinary(binop, lhs, rhs) + pub fn mk_binary(&mut self, binop: ast::BinOp, lhs: P, rhs: P) -> ast::ExprKind { + ExprKind::Binary(binop, lhs, rhs) } - pub fn mk_call(&mut self, f: P, args: Vec>) -> ast::Expr_ { - ExprCall(f, args) + pub fn mk_call(&mut self, f: P, args: Vec>) -> ast::ExprKind { + ExprKind::Call(f, args) } fn mk_method_call(&mut self, ident: ast::SpannedIdent, tps: Vec>, args: Vec>) - -> ast::Expr_ { - ExprMethodCall(ident, tps, args) + -> ast::ExprKind { + ExprKind::MethodCall(ident, tps, args) } - pub fn mk_index(&mut self, expr: P, idx: P) -> ast::Expr_ { - ExprIndex(expr, idx) + pub fn mk_index(&mut self, expr: P, idx: P) -> ast::ExprKind { + ExprKind::Index(expr, idx) } pub fn mk_range(&mut self, start: Option>, end: Option>) - -> ast::Expr_ { - ExprRange(start, end) + -> ast::ExprKind { + ExprKind::Range(start, end) } - pub fn mk_field(&mut self, expr: P, ident: ast::SpannedIdent) -> ast::Expr_ { - ExprField(expr, ident) + pub fn mk_field(&mut self, expr: P, ident: ast::SpannedIdent) -> ast::ExprKind { + ExprKind::Field(expr, ident) } - pub fn mk_tup_field(&mut self, expr: P, idx: codemap::Spanned) -> ast::Expr_ { - ExprTupField(expr, idx) + pub fn mk_tup_field(&mut self, expr: P, idx: codemap::Spanned) -> ast::ExprKind { + ExprKind::TupField(expr, idx) } pub fn mk_assign_op(&mut self, binop: ast::BinOp, - lhs: P, rhs: P) -> ast::Expr_ { - ExprAssignOp(binop, lhs, rhs) + lhs: P, rhs: P) -> ast::ExprKind { + ExprKind::AssignOp(binop, lhs, rhs) } pub fn mk_mac_expr(&mut self, lo: BytePos, hi: BytePos, m: Mac_, attrs: ThinAttributes) -> P { P(Expr { id: ast::DUMMY_NODE_ID, - node: ExprMac(codemap::Spanned {node: m, span: mk_sp(lo, hi)}), + node: ExprKind::Mac(codemap::Spanned {node: m, span: mk_sp(lo, hi)}), span: mk_sp(lo, hi), attrs: attrs, }) @@ -2029,7 +2023,7 @@ impl<'a> Parser<'a> { P(Expr { id: ast::DUMMY_NODE_ID, - node: ExprLit(lv_lit), + node: ExprKind::Lit(lv_lit), span: *span, attrs: attrs, }) @@ -2066,7 +2060,7 @@ impl<'a> Parser<'a> { let lo = self.span.lo; let mut hi = self.span.hi; - let ex: Expr_; + let ex: ExprKind; // Note: when adding new syntax here, don't forget to adjust Token::can_begin_expr(). match self.token { @@ -2098,9 +2092,9 @@ impl<'a> Parser<'a> { hi = self.last_span.hi; return if es.len() == 1 && !trailing_comma { - Ok(self.mk_expr(lo, hi, ExprParen(es.into_iter().nth(0).unwrap()), attrs)) + Ok(self.mk_expr(lo, hi, ExprKind::Paren(es.into_iter().nth(0).unwrap()), attrs)) } else { - Ok(self.mk_expr(lo, hi, ExprTup(es), attrs)) + Ok(self.mk_expr(lo, hi, ExprKind::Tup(es), attrs)) } }, token::OpenDelim(token::Brace) => { @@ -2116,7 +2110,7 @@ impl<'a> Parser<'a> { }, token::Plain) => { self.bump(); let path = ast_util::ident_to_path(mk_sp(lo, hi), id); - ex = ExprPath(None, path); + ex = ExprKind::Path(None, path); hi = self.last_span.hi; } token::OpenDelim(token::Bracket) => { @@ -2129,7 +2123,7 @@ impl<'a> Parser<'a> { if self.check(&token::CloseDelim(token::Bracket)) { // Empty vector. self.bump(); - ex = ExprVec(Vec::new()); + ex = ExprKind::Vec(Vec::new()); } else { // Nonempty vector. let first_expr = try!(self.parse_expr()); @@ -2138,7 +2132,7 @@ impl<'a> Parser<'a> { self.bump(); let count = try!(self.parse_expr()); try!(self.expect(&token::CloseDelim(token::Bracket))); - ex = ExprRepeat(first_expr, count); + ex = ExprKind::Repeat(first_expr, count); } else if self.check(&token::Comma) { // Vector with two or more elements. self.bump(); @@ -2149,11 +2143,11 @@ impl<'a> Parser<'a> { )); let mut exprs = vec!(first_expr); exprs.extend(remaining_exprs); - ex = ExprVec(exprs); + ex = ExprKind::Vec(exprs); } else { // Vector with one element. try!(self.expect(&token::CloseDelim(token::Bracket))); - ex = ExprVec(vec!(first_expr)); + ex = ExprKind::Vec(vec!(first_expr)); } } hi = self.last_span.hi; @@ -2163,7 +2157,7 @@ impl<'a> Parser<'a> { let (qself, path) = try!(self.parse_qualified_path(LifetimeAndTypesWithColons)); hi = path.span.hi; - return Ok(self.mk_expr(lo, hi, ExprPath(Some(qself), path), attrs)); + return Ok(self.mk_expr(lo, hi, ExprKind::Path(Some(qself), path), attrs)); } if self.eat_keyword(keywords::Move) { let lo = self.last_span.lo; @@ -2202,14 +2196,14 @@ impl<'a> Parser<'a> { } if self.eat_keyword(keywords::Continue) { let ex = if self.token.is_lifetime() { - let ex = ExprAgain(Some(Spanned{ + let ex = ExprKind::Again(Some(Spanned{ node: self.get_lifetime(), span: self.span })); self.bump(); ex } else { - ExprAgain(None) + ExprKind::Again(None) }; let hi = self.last_span.hi; return Ok(self.mk_expr(lo, hi, ex, attrs)); @@ -2227,19 +2221,19 @@ impl<'a> Parser<'a> { if self.token.can_begin_expr() { let e = try!(self.parse_expr()); hi = e.span.hi; - ex = ExprRet(Some(e)); + ex = ExprKind::Ret(Some(e)); } else { - ex = ExprRet(None); + ex = ExprKind::Ret(None); } } else if self.eat_keyword(keywords::Break) { if self.token.is_lifetime() { - ex = ExprBreak(Some(Spanned { + ex = ExprKind::Break(Some(Spanned { node: self.get_lifetime(), span: self.span })); self.bump(); } else { - ex = ExprBreak(None); + ex = ExprKind::Break(None); } hi = self.last_span.hi; } else if self.token.is_keyword(keywords::Let) { @@ -2302,18 +2296,18 @@ impl<'a> Parser<'a> { hi = self.span.hi; try!(self.expect(&token::CloseDelim(token::Brace))); - ex = ExprStruct(pth, fields, base); + ex = ExprKind::Struct(pth, fields, base); return Ok(self.mk_expr(lo, hi, ex, attrs)); } } hi = pth.span.hi; - ex = ExprPath(None, pth); + ex = ExprKind::Path(None, pth); } else { // other literal expression let lit = try!(self.parse_lit()); hi = lit.span.hi; - ex = ExprLit(P(lit)); + ex = ExprKind::Lit(P(lit)); } } } @@ -2343,7 +2337,7 @@ impl<'a> Parser<'a> { let attrs = outer_attrs.append(inner_attrs); let blk = try!(self.parse_block_tail(lo, blk_mode)); - return Ok(self.mk_expr(blk.span.lo, blk.span.hi, ExprBlock(blk), attrs)); + return Ok(self.mk_expr(blk.span.lo, blk.span.hi, ExprKind::Block(blk), attrs)); } /// parse a.b or a(13) or a[4] or just a @@ -2370,7 +2364,7 @@ impl<'a> Parser<'a> { expr.map(|mut expr| { expr.attrs.update(|a| a.prepend(attrs)); match expr.node { - ExprIf(..) | ExprIfLet(..) => { + ExprKind::If(..) | ExprKind::IfLet(..) => { if !expr.attrs.as_attr_slice().is_empty() { // Just point to the first attribute in there... let span = expr.attrs.as_attr_slice()[0].span; @@ -2763,7 +2757,7 @@ impl<'a> Parser<'a> { let e = self.parse_prefix_expr(None); let (span, e) = try!(self.interpolated_or_expr_span(e)); hi = span.hi; - ExprAddrOf(m, e) + ExprKind::AddrOf(m, e) } token::Ident(..) if self.token.is_keyword(keywords::In) => { self.bump(); @@ -2774,16 +2768,16 @@ impl<'a> Parser<'a> { let blk = try!(self.parse_block()); let span = blk.span; hi = span.hi; - let blk_expr = self.mk_expr(span.lo, span.hi, ExprBlock(blk), + let blk_expr = self.mk_expr(span.lo, span.hi, ExprKind::Block(blk), None); - ExprInPlace(place, blk_expr) + ExprKind::InPlace(place, blk_expr) } token::Ident(..) if self.token.is_keyword(keywords::Box) => { self.bump(); let e = self.parse_prefix_expr(None); let (span, e) = try!(self.interpolated_or_expr_span(e)); hi = span.hi; - ExprBox(e) + ExprKind::Box(e) } _ => return self.parse_dot_or_call_expr(Some(attrs)) }; @@ -2850,12 +2844,12 @@ impl<'a> Parser<'a> { if op == AssocOp::As { let rhs = try!(self.parse_ty()); lhs = self.mk_expr(lhs_span.lo, rhs.span.hi, - ExprCast(lhs, rhs), None); + ExprKind::Cast(lhs, rhs), None); continue } else if op == AssocOp::Colon { let rhs = try!(self.parse_ty()); lhs = self.mk_expr(lhs_span.lo, rhs.span.hi, - ExprType(lhs, rhs), None); + ExprKind::Type(lhs, rhs), None); continue } else if op == AssocOp::DotDot { // If we didn’t have to handle `x..`, it would be pretty easy to generalise @@ -2921,9 +2915,9 @@ impl<'a> Parser<'a> { self.mk_expr(lhs_span.lo, rhs_span.hi, binary, None) } AssocOp::Assign => - self.mk_expr(lhs_span.lo, rhs.span.hi, ExprAssign(lhs, rhs), None), + self.mk_expr(lhs_span.lo, rhs.span.hi, ExprKind::Assign(lhs, rhs), None), AssocOp::Inplace => - self.mk_expr(lhs_span.lo, rhs.span.hi, ExprInPlace(lhs, rhs), None), + self.mk_expr(lhs_span.lo, rhs.span.hi, ExprKind::InPlace(lhs, rhs), None), AssocOp::AssignOp(k) => { let aop = match k { token::Plus => BinOpKind::Add, @@ -2957,7 +2951,7 @@ impl<'a> Parser<'a> { fn check_no_chained_comparison(&mut self, lhs: &Expr, outer_op: &AssocOp) { debug_assert!(outer_op.is_comparison()); match lhs.node { - ExprBinary(op, _, _) if op.node.is_comparison() => { + ExprKind::Binary(op, _, _) if op.node.is_comparison() => { // respan to include both operators let op_span = mk_sp(op.span.lo, self.span.hi); let mut err = self.diagnostic().struct_span_err(op_span, @@ -3024,7 +3018,7 @@ impl<'a> Parser<'a> { hi = elexpr.span.hi; els = Some(elexpr); } - Ok(self.mk_expr(lo, hi, ExprIf(cond, thn, els), attrs)) + Ok(self.mk_expr(lo, hi, ExprKind::If(cond, thn, els), attrs)) } /// Parse an 'if let' expression ('if' token already eaten) @@ -3042,7 +3036,7 @@ impl<'a> Parser<'a> { } else { (thn.span.hi, None) }; - Ok(self.mk_expr(lo, hi, ExprIfLet(pat, expr, thn, els), attrs)) + Ok(self.mk_expr(lo, hi, ExprKind::IfLet(pat, expr, thn, els), attrs)) } // `|args| expr` @@ -3075,7 +3069,7 @@ impl<'a> Parser<'a> { Ok(self.mk_expr( lo, body.span.hi, - ExprClosure(capture_clause, decl, body), attrs)) + ExprKind::Closure(capture_clause, decl, body), attrs)) } // `else` token already eaten @@ -3084,7 +3078,7 @@ impl<'a> Parser<'a> { return self.parse_if_expr(None); } else { let blk = try!(self.parse_block()); - return Ok(self.mk_expr(blk.span.lo, blk.span.hi, ExprBlock(blk), None)); + return Ok(self.mk_expr(blk.span.lo, blk.span.hi, ExprKind::Block(blk), None)); } } @@ -3103,7 +3097,7 @@ impl<'a> Parser<'a> { let hi = self.last_span.hi; Ok(self.mk_expr(span_lo, hi, - ExprForLoop(pat, expr, loop_block, opt_ident), + ExprKind::ForLoop(pat, expr, loop_block, opt_ident), attrs)) } @@ -3118,7 +3112,7 @@ impl<'a> Parser<'a> { let (iattrs, body) = try!(self.parse_inner_attrs_and_block()); let attrs = attrs.append(iattrs.into_thin_attrs()); let hi = body.span.hi; - return Ok(self.mk_expr(span_lo, hi, ExprWhile(cond, body, opt_ident), + return Ok(self.mk_expr(span_lo, hi, ExprKind::While(cond, body, opt_ident), attrs)); } @@ -3133,7 +3127,7 @@ impl<'a> Parser<'a> { let (iattrs, body) = try!(self.parse_inner_attrs_and_block()); let attrs = attrs.append(iattrs.into_thin_attrs()); let hi = body.span.hi; - return Ok(self.mk_expr(span_lo, hi, ExprWhileLet(pat, expr, body, opt_ident), attrs)); + return Ok(self.mk_expr(span_lo, hi, ExprKind::WhileLet(pat, expr, body, opt_ident), attrs)); } // parse `loop {...}`, `loop` token already eaten @@ -3143,7 +3137,7 @@ impl<'a> Parser<'a> { let (iattrs, body) = try!(self.parse_inner_attrs_and_block()); let attrs = attrs.append(iattrs.into_thin_attrs()); let hi = body.span.hi; - Ok(self.mk_expr(span_lo, hi, ExprLoop(body, opt_ident), attrs)) + Ok(self.mk_expr(span_lo, hi, ExprKind::Loop(body, opt_ident), attrs)) } // `match` token already eaten @@ -3167,7 +3161,7 @@ impl<'a> Parser<'a> { } let hi = self.span.hi; self.bump(); - return Ok(self.mk_expr(lo, hi, ExprMatch(discriminant, arms), attrs)); + return Ok(self.mk_expr(lo, hi, ExprKind::Match(discriminant, arms), attrs)); } pub fn parse_arm(&mut self) -> PResult<'a, Arm> { @@ -3407,7 +3401,7 @@ impl<'a> Parser<'a> { (None, try!(self.parse_path(LifetimeAndTypesWithColons))) }; let hi = self.last_span.hi; - Ok(self.mk_expr(lo, hi, ExprPath(qself, path), None)) + Ok(self.mk_expr(lo, hi, ExprKind::Path(qself, path), None)) } else { self.parse_pat_literal_maybe_minus() } @@ -3509,7 +3503,7 @@ impl<'a> Parser<'a> { token::DotDotDot => { // Parse range let hi = self.last_span.hi; - let begin = self.mk_expr(lo, hi, ExprPath(qself, path), None); + let begin = self.mk_expr(lo, hi, ExprKind::Path(qself, path), None); self.bump(); let end = try!(self.parse_pat_range_end()); pat = PatRange(begin, end); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 68e9266a2b0..736af70091a 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -441,10 +441,10 @@ pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String { fn needs_parentheses(expr: &ast::Expr) -> bool { match expr.node { - ast::ExprAssign(..) | ast::ExprBinary(..) | - ast::ExprClosure(..) | - ast::ExprAssignOp(..) | ast::ExprCast(..) | - ast::ExprInPlace(..) | ast::ExprType(..) => true, + ast::ExprKind::Assign(..) | ast::ExprKind::Binary(..) | + ast::ExprKind::Closure(..) | + ast::ExprKind::AssignOp(..) | ast::ExprKind::Cast(..) | + ast::ExprKind::InPlace(..) | ast::ExprKind::Type(..) => true, _ => false, } } @@ -1713,7 +1713,7 @@ impl<'a> State<'a> { Some(_else) => { match _else.node { // "another else-if" - ast::ExprIf(ref i, ref then, ref e) => { + ast::ExprKind::If(ref i, ref then, ref e) => { try!(self.cbox(INDENT_UNIT - 1)); try!(self.ibox(0)); try!(word(&mut self.s, " else if ")); @@ -1723,7 +1723,7 @@ impl<'a> State<'a> { self.print_else(e.as_ref().map(|e| &**e)) } // "another else-if-let" - ast::ExprIfLet(ref pat, ref expr, ref then, ref e) => { + ast::ExprKind::IfLet(ref pat, ref expr, ref then, ref e) => { try!(self.cbox(INDENT_UNIT - 1)); try!(self.ibox(0)); try!(word(&mut self.s, " else if let ")); @@ -1736,7 +1736,7 @@ impl<'a> State<'a> { self.print_else(e.as_ref().map(|e| &**e)) } // "final else" - ast::ExprBlock(ref b) => { + ast::ExprKind::Block(ref b) => { try!(self.cbox(INDENT_UNIT - 1)); try!(self.ibox(0)); try!(word(&mut self.s, " else ")); @@ -1803,7 +1803,7 @@ impl<'a> State<'a> { pub fn check_expr_bin_needs_paren(&mut self, sub_expr: &ast::Expr, binop: ast::BinOp) -> bool { match sub_expr.node { - ast::ExprBinary(ref sub_op, _, _) => { + ast::ExprKind::Binary(ref sub_op, _, _) => { if AssocOp::from_ast_binop(sub_op.node).precedence() < AssocOp::from_ast_binop(binop.node).precedence() { true @@ -1985,45 +1985,45 @@ impl<'a> State<'a> { try!(self.ibox(INDENT_UNIT)); try!(self.ann.pre(self, NodeExpr(expr))); match expr.node { - ast::ExprBox(ref expr) => { + ast::ExprKind::Box(ref expr) => { try!(self.word_space("box")); try!(self.print_expr(expr)); } - ast::ExprInPlace(ref place, ref expr) => { + ast::ExprKind::InPlace(ref place, ref expr) => { try!(self.print_expr_in_place(place, expr)); } - ast::ExprVec(ref exprs) => { + ast::ExprKind::Vec(ref exprs) => { try!(self.print_expr_vec(&exprs[..], attrs)); } - ast::ExprRepeat(ref element, ref count) => { + ast::ExprKind::Repeat(ref element, ref count) => { try!(self.print_expr_repeat(&**element, &**count, attrs)); } - ast::ExprStruct(ref path, ref fields, ref wth) => { + ast::ExprKind::Struct(ref path, ref fields, ref wth) => { try!(self.print_expr_struct(path, &fields[..], wth, attrs)); } - ast::ExprTup(ref exprs) => { + ast::ExprKind::Tup(ref exprs) => { try!(self.print_expr_tup(&exprs[..], attrs)); } - ast::ExprCall(ref func, ref args) => { + ast::ExprKind::Call(ref func, ref args) => { try!(self.print_expr_call(&**func, &args[..])); } - ast::ExprMethodCall(ident, ref tys, ref args) => { + ast::ExprKind::MethodCall(ident, ref tys, ref args) => { try!(self.print_expr_method_call(ident, &tys[..], &args[..])); } - ast::ExprBinary(op, ref lhs, ref rhs) => { + ast::ExprKind::Binary(op, ref lhs, ref rhs) => { try!(self.print_expr_binary(op, &**lhs, &**rhs)); } - ast::ExprUnary(op, ref expr) => { + ast::ExprKind::Unary(op, ref expr) => { try!(self.print_expr_unary(op, &**expr)); } - ast::ExprAddrOf(m, ref expr) => { + ast::ExprKind::AddrOf(m, ref expr) => { try!(self.print_expr_addr_of(m, &**expr)); } - ast::ExprLit(ref lit) => { + ast::ExprKind::Lit(ref lit) => { try!(self.print_literal(&**lit)); } - ast::ExprCast(ref expr, ref ty) => { - if let ast::ExprCast(..) = expr.node { + ast::ExprKind::Cast(ref expr, ref ty) => { + if let ast::ExprKind::Cast(..) = expr.node { try!(self.print_expr(&**expr)); } else { try!(self.print_expr_maybe_paren(&**expr)); @@ -2032,18 +2032,18 @@ impl<'a> State<'a> { try!(self.word_space("as")); try!(self.print_type(&**ty)); } - ast::ExprType(ref expr, ref ty) => { + ast::ExprKind::Type(ref expr, ref ty) => { try!(self.print_expr(&**expr)); try!(self.word_space(":")); try!(self.print_type(&**ty)); } - ast::ExprIf(ref test, ref blk, ref elseopt) => { + ast::ExprKind::If(ref test, ref blk, ref elseopt) => { try!(self.print_if(&**test, &**blk, elseopt.as_ref().map(|e| &**e))); } - ast::ExprIfLet(ref pat, ref expr, ref blk, ref elseopt) => { + ast::ExprKind::IfLet(ref pat, ref expr, ref blk, ref elseopt) => { try!(self.print_if_let(&**pat, &**expr, &** blk, elseopt.as_ref().map(|e| &**e))); } - ast::ExprWhile(ref test, ref blk, opt_ident) => { + ast::ExprKind::While(ref test, ref blk, opt_ident) => { if let Some(ident) = opt_ident { try!(self.print_ident(ident)); try!(self.word_space(":")); @@ -2053,7 +2053,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)); try!(self.print_block_with_attrs(&**blk, attrs)); } - ast::ExprWhileLet(ref pat, ref expr, ref blk, opt_ident) => { + ast::ExprKind::WhileLet(ref pat, ref expr, ref blk, opt_ident) => { if let Some(ident) = opt_ident { try!(self.print_ident(ident)); try!(self.word_space(":")); @@ -2066,7 +2066,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)); try!(self.print_block_with_attrs(&**blk, attrs)); } - ast::ExprForLoop(ref pat, ref iter, ref blk, opt_ident) => { + ast::ExprKind::ForLoop(ref pat, ref iter, ref blk, opt_ident) => { if let Some(ident) = opt_ident { try!(self.print_ident(ident)); try!(self.word_space(":")); @@ -2079,7 +2079,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)); try!(self.print_block_with_attrs(&**blk, attrs)); } - ast::ExprLoop(ref blk, opt_ident) => { + ast::ExprKind::Loop(ref blk, opt_ident) => { if let Some(ident) = opt_ident { try!(self.print_ident(ident)); try!(self.word_space(":")); @@ -2088,7 +2088,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)); try!(self.print_block_with_attrs(&**blk, attrs)); } - ast::ExprMatch(ref expr, ref arms) => { + ast::ExprKind::Match(ref expr, ref arms) => { try!(self.cbox(INDENT_UNIT)); try!(self.ibox(4)); try!(self.word_nbsp("match")); @@ -2101,7 +2101,7 @@ impl<'a> State<'a> { } try!(self.bclose_(expr.span, INDENT_UNIT)); } - ast::ExprClosure(capture_clause, ref decl, ref body) => { + ast::ExprKind::Closure(capture_clause, ref decl, ref body) => { try!(self.print_capture_clause(capture_clause)); try!(self.print_fn_block_args(&**decl)); @@ -2118,7 +2118,7 @@ impl<'a> State<'a> { // we extract the block, so as not to create another set of boxes let i_expr = body.expr.as_ref().unwrap(); match i_expr.node { - ast::ExprBlock(ref blk) => { + ast::ExprKind::Block(ref blk) => { try!(self.print_block_unclosed_with_attrs( &**blk, i_expr.attrs.as_attr_slice())); @@ -2135,43 +2135,43 @@ impl<'a> State<'a> { // empty box to satisfy the close. try!(self.ibox(0)); } - ast::ExprBlock(ref blk) => { + ast::ExprKind::Block(ref blk) => { // containing cbox, will be closed by print-block at } try!(self.cbox(INDENT_UNIT)); // head-box, will be closed by print-block after { try!(self.ibox(0)); try!(self.print_block_with_attrs(&**blk, attrs)); } - ast::ExprAssign(ref lhs, ref rhs) => { + ast::ExprKind::Assign(ref lhs, ref rhs) => { try!(self.print_expr(&**lhs)); try!(space(&mut self.s)); try!(self.word_space("=")); try!(self.print_expr(&**rhs)); } - ast::ExprAssignOp(op, ref lhs, ref rhs) => { + ast::ExprKind::AssignOp(op, ref lhs, ref rhs) => { try!(self.print_expr(&**lhs)); try!(space(&mut self.s)); try!(word(&mut self.s, op.node.to_string())); try!(self.word_space("=")); try!(self.print_expr(&**rhs)); } - ast::ExprField(ref expr, id) => { + ast::ExprKind::Field(ref expr, id) => { try!(self.print_expr(&**expr)); try!(word(&mut self.s, ".")); try!(self.print_ident(id.node)); } - ast::ExprTupField(ref expr, id) => { + ast::ExprKind::TupField(ref expr, id) => { try!(self.print_expr(&**expr)); try!(word(&mut self.s, ".")); try!(self.print_usize(id.node)); } - ast::ExprIndex(ref expr, ref index) => { + ast::ExprKind::Index(ref expr, ref index) => { try!(self.print_expr(&**expr)); try!(word(&mut self.s, "[")); try!(self.print_expr(&**index)); try!(word(&mut self.s, "]")); } - ast::ExprRange(ref start, ref end) => { + ast::ExprKind::Range(ref start, ref end) => { if let &Some(ref e) = start { try!(self.print_expr(&**e)); } @@ -2180,13 +2180,13 @@ impl<'a> State<'a> { try!(self.print_expr(&**e)); } } - ast::ExprPath(None, ref path) => { + ast::ExprKind::Path(None, ref path) => { try!(self.print_path(path, true, 0)) } - ast::ExprPath(Some(ref qself), ref path) => { + ast::ExprKind::Path(Some(ref qself), ref path) => { try!(self.print_qpath(path, qself, true)) } - ast::ExprBreak(opt_ident) => { + ast::ExprKind::Break(opt_ident) => { try!(word(&mut self.s, "break")); try!(space(&mut self.s)); if let Some(ident) = opt_ident { @@ -2194,7 +2194,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)); } } - ast::ExprAgain(opt_ident) => { + ast::ExprKind::Again(opt_ident) => { try!(word(&mut self.s, "continue")); try!(space(&mut self.s)); if let Some(ident) = opt_ident { @@ -2202,7 +2202,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)) } } - ast::ExprRet(ref result) => { + ast::ExprKind::Ret(ref result) => { try!(word(&mut self.s, "return")); match *result { Some(ref expr) => { @@ -2212,7 +2212,7 @@ impl<'a> State<'a> { _ => () } } - ast::ExprInlineAsm(ref a) => { + ast::ExprKind::InlineAsm(ref a) => { try!(word(&mut self.s, "asm!")); try!(self.popen()); try!(self.print_string(&a.asm, a.asm_str_style)); @@ -2275,8 +2275,8 @@ impl<'a> State<'a> { try!(self.pclose()); } - ast::ExprMac(ref m) => try!(self.print_mac(m, token::Paren)), - ast::ExprParen(ref e) => { + ast::ExprKind::Mac(ref m) => try!(self.print_mac(m, token::Paren)), + ast::ExprKind::Paren(ref e) => { try!(self.popen()); try!(self.print_inner_attributes_inline(attrs)); try!(self.print_expr(&**e)); @@ -2605,7 +2605,7 @@ impl<'a> State<'a> { try!(self.word_space("=>")); match arm.body.node { - ast::ExprBlock(ref blk) => { + ast::ExprKind::Block(ref blk) => { // the block will close the pattern's ibox try!(self.print_block_unclosed_indent(&**blk, INDENT_UNIT)); diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index 0504c313c91..6190cf73464 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -17,7 +17,7 @@ //! //! * **Identity**: sharing AST nodes is problematic for the various analysis //! passes (e.g. one may be able to bypass the borrow checker with a shared -//! `ExprAddrOf` node taking a mutable borrow). The only reason `@T` in the +//! `ExprKind::AddrOf` node taking a mutable borrow). The only reason `@T` in the //! AST hasn't caused issues is because of inefficient folding passes which //! would always deduplicate any such shared nodes. Even if the AST were to //! switch to an arena, this would still hold, i.e. it couldn't use `&'a T`, diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 8b2d9bd9aaf..dbdc1bfcbaa 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -613,10 +613,10 @@ fn mk_test_descs(cx: &TestCtxt) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprAddrOf(ast::MutImmutable, + node: ast::ExprKind::AddrOf(ast::MutImmutable, P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprVec(cx.testfns.iter().map(|test| { + node: ast::ExprKind::Vec(cx.testfns.iter().map(|test| { mk_test_desc_and_fn_rec(cx, test) }).collect()), span: DUMMY_SP, diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index e38997931aa..90cc403961e 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -651,21 +651,21 @@ pub fn walk_mac<'v, V: Visitor<'v>>(_: &mut V, _: &'v Mac) { pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { match expression.node { - ExprBox(ref subexpression) => { + ExprKind::Box(ref subexpression) => { visitor.visit_expr(subexpression) } - ExprInPlace(ref place, ref subexpression) => { + ExprKind::InPlace(ref place, ref subexpression) => { visitor.visit_expr(place); visitor.visit_expr(subexpression) } - ExprVec(ref subexpressions) => { + ExprKind::Vec(ref subexpressions) => { walk_list!(visitor, visit_expr, subexpressions); } - ExprRepeat(ref element, ref count) => { + ExprKind::Repeat(ref element, ref count) => { visitor.visit_expr(element); visitor.visit_expr(count) } - ExprStruct(ref path, ref fields, ref optional_base) => { + ExprKind::Struct(ref path, ref fields, ref optional_base) => { visitor.visit_path(path, expression.id); for field in fields { visitor.visit_ident(field.ident.span, field.ident.node); @@ -673,116 +673,116 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { } walk_list!(visitor, visit_expr, optional_base); } - ExprTup(ref subexpressions) => { + ExprKind::Tup(ref subexpressions) => { walk_list!(visitor, visit_expr, subexpressions); } - ExprCall(ref callee_expression, ref arguments) => { + ExprKind::Call(ref callee_expression, ref arguments) => { walk_list!(visitor, visit_expr, arguments); visitor.visit_expr(callee_expression) } - ExprMethodCall(ref ident, ref types, ref arguments) => { + ExprKind::MethodCall(ref ident, ref types, ref arguments) => { visitor.visit_ident(ident.span, ident.node); walk_list!(visitor, visit_expr, arguments); walk_list!(visitor, visit_ty, types); } - ExprBinary(_, ref left_expression, ref right_expression) => { + ExprKind::Binary(_, ref left_expression, ref right_expression) => { visitor.visit_expr(left_expression); visitor.visit_expr(right_expression) } - ExprAddrOf(_, ref subexpression) | ExprUnary(_, ref subexpression) => { + ExprKind::AddrOf(_, ref subexpression) | ExprKind::Unary(_, ref subexpression) => { visitor.visit_expr(subexpression) } - ExprLit(_) => {} - ExprCast(ref subexpression, ref typ) | ExprType(ref subexpression, ref typ) => { + ExprKind::Lit(_) => {} + ExprKind::Cast(ref subexpression, ref typ) | ExprKind::Type(ref subexpression, ref typ) => { visitor.visit_expr(subexpression); visitor.visit_ty(typ) } - ExprIf(ref head_expression, ref if_block, ref optional_else) => { + ExprKind::If(ref head_expression, ref if_block, ref optional_else) => { visitor.visit_expr(head_expression); visitor.visit_block(if_block); walk_list!(visitor, visit_expr, optional_else); } - ExprWhile(ref subexpression, ref block, opt_ident) => { + ExprKind::While(ref subexpression, ref block, opt_ident) => { visitor.visit_expr(subexpression); visitor.visit_block(block); walk_opt_ident(visitor, expression.span, opt_ident) } - ExprIfLet(ref pattern, ref subexpression, ref if_block, ref optional_else) => { + ExprKind::IfLet(ref pattern, ref subexpression, ref if_block, ref optional_else) => { visitor.visit_pat(pattern); visitor.visit_expr(subexpression); visitor.visit_block(if_block); walk_list!(visitor, visit_expr, optional_else); } - ExprWhileLet(ref pattern, ref subexpression, ref block, opt_ident) => { + ExprKind::WhileLet(ref pattern, ref subexpression, ref block, opt_ident) => { visitor.visit_pat(pattern); visitor.visit_expr(subexpression); visitor.visit_block(block); walk_opt_ident(visitor, expression.span, opt_ident) } - ExprForLoop(ref pattern, ref subexpression, ref block, opt_ident) => { + ExprKind::ForLoop(ref pattern, ref subexpression, ref block, opt_ident) => { visitor.visit_pat(pattern); visitor.visit_expr(subexpression); visitor.visit_block(block); walk_opt_ident(visitor, expression.span, opt_ident) } - ExprLoop(ref block, opt_ident) => { + ExprKind::Loop(ref block, opt_ident) => { visitor.visit_block(block); walk_opt_ident(visitor, expression.span, opt_ident) } - ExprMatch(ref subexpression, ref arms) => { + ExprKind::Match(ref subexpression, ref arms) => { visitor.visit_expr(subexpression); walk_list!(visitor, visit_arm, arms); } - ExprClosure(_, ref function_declaration, ref body) => { + ExprKind::Closure(_, ref function_declaration, ref body) => { visitor.visit_fn(FnKind::Closure, function_declaration, body, expression.span, expression.id) } - ExprBlock(ref block) => visitor.visit_block(block), - ExprAssign(ref left_hand_expression, ref right_hand_expression) => { + ExprKind::Block(ref block) => visitor.visit_block(block), + ExprKind::Assign(ref left_hand_expression, ref right_hand_expression) => { visitor.visit_expr(right_hand_expression); visitor.visit_expr(left_hand_expression) } - ExprAssignOp(_, ref left_expression, ref right_expression) => { + ExprKind::AssignOp(_, ref left_expression, ref right_expression) => { visitor.visit_expr(right_expression); visitor.visit_expr(left_expression) } - ExprField(ref subexpression, ref ident) => { + ExprKind::Field(ref subexpression, ref ident) => { visitor.visit_expr(subexpression); visitor.visit_ident(ident.span, ident.node); } - ExprTupField(ref subexpression, _) => { + ExprKind::TupField(ref subexpression, _) => { visitor.visit_expr(subexpression); } - ExprIndex(ref main_expression, ref index_expression) => { + ExprKind::Index(ref main_expression, ref index_expression) => { visitor.visit_expr(main_expression); visitor.visit_expr(index_expression) } - ExprRange(ref start, ref end) => { + ExprKind::Range(ref start, ref end) => { walk_list!(visitor, visit_expr, start); walk_list!(visitor, visit_expr, end); } - ExprPath(ref maybe_qself, ref path) => { + ExprKind::Path(ref maybe_qself, ref path) => { if let Some(ref qself) = *maybe_qself { visitor.visit_ty(&qself.ty); } visitor.visit_path(path, expression.id) } - ExprBreak(ref opt_sp_ident) | ExprAgain(ref opt_sp_ident) => { + ExprKind::Break(ref opt_sp_ident) | ExprKind::Again(ref opt_sp_ident) => { for sp_ident in opt_sp_ident { visitor.visit_ident(sp_ident.span, sp_ident.node); } } - ExprRet(ref optional_expression) => { + ExprKind::Ret(ref optional_expression) => { walk_list!(visitor, visit_expr, optional_expression); } - ExprMac(ref mac) => visitor.visit_mac(mac), - ExprParen(ref subexpression) => { + ExprKind::Mac(ref mac) => visitor.visit_mac(mac), + ExprKind::Paren(ref subexpression) => { visitor.visit_expr(subexpression) } - ExprInlineAsm(ref ia) => { + ExprKind::InlineAsm(ref ia) => { for &(_, ref input) in &ia.inputs { visitor.visit_expr(&input) } diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index 2f50f610d2b..b9ba1f107ad 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -247,7 +247,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) MacEager::expr(P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprInlineAsm(ast::InlineAsm { + node: ast::ExprKind::InlineAsm(ast::InlineAsm { asm: token::intern_and_get_ident(&asm), asm_str_style: asm_str_style.unwrap(), outputs: outputs, diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs index de913fe0431..f5c2805c4ca 100644 --- a/src/libsyntax_ext/concat.rs +++ b/src/libsyntax_ext/concat.rs @@ -27,7 +27,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, let mut accumulator = String::new(); for e in es { match e.node { - ast::ExprLit(ref lit) => { + ast::ExprKind::Lit(ref lit) => { match lit.node { ast::LitStr(ref s, _) | ast::LitFloat(ref s, _) | diff --git a/src/libsyntax_ext/concat_idents.rs b/src/libsyntax_ext/concat_idents.rs index 9702b24ffd4..85453f6dfcb 100644 --- a/src/libsyntax_ext/concat_idents.rs +++ b/src/libsyntax_ext/concat_idents.rs @@ -54,7 +54,7 @@ pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) let e = P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprPath(None, + node: ast::ExprKind::Path(None, ast::Path { span: sp, global: false, diff --git a/src/libsyntax_ext/deriving/encodable.rs b/src/libsyntax_ext/deriving/encodable.rs index 02747d38c00..14631659b0b 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, ExprRet, MutMutable}; +use syntax::ast::{MetaItem, Expr, ExprKind, MutMutable}; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt,Annotatable}; use syntax::ext::build::AstBuilder; @@ -208,16 +208,15 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span, let call = if i != last { cx.expr_try(span, call) } else { - cx.expr(span, ExprRet(Some(call))) + cx.expr(span, ExprKind::Ret(Some(call))) }; stmts.push(cx.stmt_expr(call)); } // unit structs have no fields and need to return Ok() if stmts.is_empty() { - let ret_ok = cx.expr(trait_span, - ExprRet(Some(cx.expr_ok(trait_span, - cx.expr_tuple(trait_span, vec![]))))); + let ok = cx.expr_ok(trait_span, cx.expr_tuple(trait_span, vec![])); + let ret_ok = cx.expr(trait_span, ExprKind::Ret(Some(ok))); stmts.push(cx.stmt_expr(ret_ok)); } @@ -254,14 +253,13 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span, let call = if i != last { cx.expr_try(span, call) } else { - cx.expr(span, ExprRet(Some(call))) + cx.expr(span, ExprKind::Ret(Some(call))) }; stmts.push(cx.stmt_expr(call)); } } else { - let ret_ok = cx.expr(trait_span, - ExprRet(Some(cx.expr_ok(trait_span, - cx.expr_tuple(trait_span, vec![]))))); + let ok = cx.expr_ok(trait_span, cx.expr_tuple(trait_span, vec![])); + let ret_ok = cx.expr(trait_span, ExprKind::Ret(Some(ok))); stmts.push(cx.stmt_expr(ret_ok)); } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 3903f6a8085..82002b0be29 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -1311,7 +1311,7 @@ impl<'a> MethodDef<'a> { // expression; here add a layer of borrowing, turning // `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`. let borrowed_self_args = self_args.move_map(|self_arg| cx.expr_addr_of(sp, self_arg)); - let match_arg = cx.expr(sp, ast::ExprTup(borrowed_self_args)); + let match_arg = cx.expr(sp, ast::ExprKind::Tup(borrowed_self_args)); //Lastly we create an expression which branches on all discriminants being equal // if discriminant_test { @@ -1389,7 +1389,7 @@ impl<'a> MethodDef<'a> { // expression; here add a layer of borrowing, turning // `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`. let borrowed_self_args = self_args.move_map(|self_arg| cx.expr_addr_of(sp, self_arg)); - let match_arg = cx.expr(sp, ast::ExprTup(borrowed_self_args)); + let match_arg = cx.expr(sp, ast::ExprKind::Tup(borrowed_self_args)); cx.expr_match(sp, match_arg, match_arms) } } @@ -1509,8 +1509,8 @@ impl<'a> TraitDef<'a> { }; let ident = cx.ident_of(&format!("{}_{}", prefix, i)); paths.push(codemap::Spanned{span: sp, node: ident}); - let val = cx.expr( - sp, ast::ExprParen(cx.expr_deref(sp, cx.expr_path(cx.path_ident(sp,ident))))); + let val = cx.expr_deref(sp, cx.expr_path(cx.path_ident(sp,ident))); + let val = cx.expr(sp, ast::ExprKind::Paren(val)); ident_expr.push((sp, opt_id, val, &struct_field.node.attrs[..])); } diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 449be3bc50c..986cdef49b2 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -559,7 +559,7 @@ impl<'a, 'b> Context<'a, 'b> { // as series of let's; the first approach does. let pat = self.ecx.pat_tuple(self.fmtsp, pats); let arm = self.ecx.arm(self.fmtsp, vec!(pat), args_array); - let head = self.ecx.expr(self.fmtsp, ast::ExprTup(heads)); + let head = self.ecx.expr(self.fmtsp, ast::ExprKind::Tup(heads)); let result = self.ecx.expr_match(self.fmtsp, head, vec!(arm)); let args_slice = self.ecx.expr_addr_of(self.fmtsp, result); -- cgit 1.4.1-3-g733a5 From 05d4cefd630cd9ae104555e69ceb3b1566298a6a Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 8 Feb 2016 16:53:21 +0100 Subject: [breaking-change] don't pub export ast::Ty_ variants --- src/librustc_front/lowering.rs | 27 +++++++++-------- src/librustc_trans/save/dump_csv.rs | 2 +- src/librustc_trans/save/mod.rs | 2 +- src/libsyntax/ast.rs | 35 +++++++++++----------- src/libsyntax/diagnostics/plugin.rs | 4 +-- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/build.rs | 14 ++++----- src/libsyntax/ext/expand.rs | 4 +-- src/libsyntax/fold.rs | 42 +++++++++++++------------- src/libsyntax/parse/mod.rs | 2 +- src/libsyntax/parse/parser.rs | 50 +++++++++++++++---------------- src/libsyntax/print/pprust.rs | 30 +++++++++---------- src/libsyntax/test.rs | 8 ++--- src/libsyntax/visit.rs | 24 +++++++-------- src/libsyntax_ext/deriving/generic/mod.rs | 4 +-- src/libsyntax_ext/deriving/generic/ty.rs | 2 +- src/libsyntax_ext/format.rs | 2 +- 17 files changed, 126 insertions(+), 128 deletions(-) (limited to 'src/libsyntax_ext/format.rs') diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index fe44ba7a646..813a7f71fe9 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -268,16 +268,17 @@ pub fn lower_ty_binding(lctx: &LoweringContext, b: &TypeBinding) -> hir::TypeBin } pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P { + use syntax::ast::TyKind::*; P(hir::Ty { id: t.id, node: match t.node { - TyInfer => hir::TyInfer, - TyVec(ref ty) => hir::TyVec(lower_ty(lctx, ty)), - TyPtr(ref mt) => hir::TyPtr(lower_mt(lctx, mt)), - TyRptr(ref region, ref mt) => { + Infer => hir::TyInfer, + Vec(ref ty) => hir::TyVec(lower_ty(lctx, ty)), + Ptr(ref mt) => hir::TyPtr(lower_mt(lctx, mt)), + Rptr(ref region, ref mt) => { hir::TyRptr(lower_opt_lifetime(lctx, region), lower_mt(lctx, mt)) } - TyBareFn(ref f) => { + BareFn(ref f) => { hir::TyBareFn(P(hir::BareFnTy { lifetimes: lower_lifetime_defs(lctx, &f.lifetimes), unsafety: lower_unsafety(lctx, f.unsafety), @@ -285,11 +286,11 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P { decl: lower_fn_decl(lctx, &f.decl), })) } - TyTup(ref tys) => hir::TyTup(tys.iter().map(|ty| lower_ty(lctx, ty)).collect()), - TyParen(ref ty) => { + Tup(ref tys) => hir::TyTup(tys.iter().map(|ty| lower_ty(lctx, ty)).collect()), + Paren(ref ty) => { return lower_ty(lctx, ty); } - TyPath(ref qself, ref path) => { + Path(ref qself, ref path) => { let qself = qself.as_ref().map(|&QSelf { ref ty, position }| { hir::QSelf { ty: lower_ty(lctx, ty), @@ -298,19 +299,19 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P { }); hir::TyPath(qself, lower_path(lctx, path)) } - TyObjectSum(ref ty, ref bounds) => { + ObjectSum(ref ty, ref bounds) => { hir::TyObjectSum(lower_ty(lctx, ty), lower_bounds(lctx, bounds)) } - TyFixedLengthVec(ref ty, ref e) => { + FixedLengthVec(ref ty, ref e) => { hir::TyFixedLengthVec(lower_ty(lctx, ty), lower_expr(lctx, e)) } - TyTypeof(ref expr) => { + Typeof(ref expr) => { hir::TyTypeof(lower_expr(lctx, expr)) } - TyPolyTraitRef(ref bounds) => { + PolyTraitRef(ref bounds) => { hir::TyPolyTraitRef(bounds.iter().map(|b| lower_ty_param_bound(lctx, b)).collect()) } - TyMac(_) => panic!("TyMac should have been expanded by now."), + Mac(_) => panic!("TyMac should have been expanded by now."), }, span: t.span, }) diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index e8a0e4a8d42..10840933c01 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -1063,7 +1063,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { fn visit_ty(&mut self, t: &ast::Ty) { self.process_macro_use(t.span, t.id); match t.node { - ast::TyPath(_, ref path) => { + ast::TyKind::Path(_, ref path) => { match self.lookup_type_ref(t.id) { Some(id) => { let sub_span = self.span.sub_span_for_type_name(t.span); diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 116051f6fe5..53fa1bfff38 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -316,7 +316,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { match typ.node { // Common case impl for a struct or something basic. - ast::TyPath(None, ref path) => { + ast::TyKind::Path(None, ref path) => { sub_span = self.span_utils.sub_span_for_type_name(path.span); filter!(self.span_utils, sub_span, path.span, None); type_data = self.lookup_ref_id(typ.id).map(|id| { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index d06ed4be978..5752cbda9b9 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -24,7 +24,6 @@ pub use self::Stmt_::*; pub use self::StrStyle::*; pub use self::StructFieldKind::*; pub use self::TraitItem_::*; -pub use self::Ty_::*; pub use self::TyParamBound::*; pub use self::UnsafeSource::*; pub use self::ViewPath_::*; @@ -1523,7 +1522,7 @@ pub struct TypeBinding { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] pub struct Ty { pub id: NodeId, - pub node: Ty_, + pub node: TyKind, pub span: Span, } @@ -1543,36 +1542,36 @@ pub struct BareFnTy { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] /// The different kinds of types recognized by the compiler -pub enum Ty_ { - TyVec(P), +pub enum TyKind { + Vec(P), /// A fixed length array (`[T; n]`) - TyFixedLengthVec(P, P), + FixedLengthVec(P, P), /// A raw pointer (`*const T` or `*mut T`) - TyPtr(MutTy), + Ptr(MutTy), /// A reference (`&'a T` or `&'a mut T`) - TyRptr(Option, MutTy), + Rptr(Option, MutTy), /// A bare function (e.g. `fn(usize) -> bool`) - TyBareFn(P), + BareFn(P), /// A tuple (`(A, B, C, D,...)`) - TyTup(Vec> ), + Tup(Vec> ), /// A path (`module::module::...::Type`), optionally /// "qualified", e.g. ` as SomeTrait>::SomeType`. /// /// Type parameters are stored in the Path itself - TyPath(Option, Path), + Path(Option, Path), /// Something like `A+B`. Note that `B` must always be a path. - TyObjectSum(P, TyParamBounds), + ObjectSum(P, TyParamBounds), /// A type like `for<'a> Foo<&'a Bar>` - TyPolyTraitRef(TyParamBounds), + PolyTraitRef(TyParamBounds), /// No-op; kept solely so that we can pretty-print faithfully - TyParen(P), + Paren(P), /// Unused for now - TyTypeof(P), - /// TyInfer means the type should be inferred instead of it having been + Typeof(P), + /// TyKind::Infer means the type should be inferred instead of it having been /// specified. This can appear anywhere in a type. - TyInfer, + Infer, // A macro in the type position. - TyMac(Mac) + Mac(Mac), } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] @@ -1617,7 +1616,7 @@ impl Arg { // HACK(eddyb) fake type for the self argument. ty: P(Ty { id: DUMMY_NODE_ID, - node: TyInfer, + node: TyKind::Infer, span: DUMMY_SP, }), pat: P(Pat { diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 6e389e83591..4e6fde10ade 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -212,10 +212,10 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, let ty = ecx.ty( span, - ast::TyFixedLengthVec( + ast::TyKind::FixedLengthVec( ecx.ty( span, - ast::TyTup(vec![ty_str.clone(), ty_str]) + ast::TyKind::Tup(vec![ty_str.clone(), ty_str]) ), ecx.expr_usize(span, count), ), diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 33414a697a7..b58f8007e0a 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -367,7 +367,7 @@ impl DummyResult { pub fn raw_ty(sp: Span) -> P { P(ast::Ty { id: ast::DUMMY_NODE_ID, - node: ast::TyInfer, + node: ast::TyKind::Infer, span: sp }) } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 1c2d1cebf3d..241ea976eee 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -52,7 +52,7 @@ pub trait AstBuilder { // types fn ty_mt(&self, ty: P, mutbl: ast::Mutability) -> ast::MutTy; - fn ty(&self, span: Span, ty: ast::Ty_) -> P; + fn ty(&self, span: Span, ty: ast::TyKind) -> P; fn ty_path(&self, ast::Path) -> P; fn ty_sum(&self, ast::Path, ast::TyParamBounds) -> P; fn ty_ident(&self, span: Span, idents: ast::Ident) -> P; @@ -385,7 +385,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } } - fn ty(&self, span: Span, ty: ast::Ty_) -> P { + fn ty(&self, span: Span, ty: ast::TyKind) -> P { P(ast::Ty { id: ast::DUMMY_NODE_ID, span: span, @@ -394,12 +394,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn ty_path(&self, path: ast::Path) -> P { - self.ty(path.span, ast::TyPath(None, path)) + self.ty(path.span, ast::TyKind::Path(None, path)) } fn ty_sum(&self, path: ast::Path, bounds: ast::TyParamBounds) -> P { self.ty(path.span, - ast::TyObjectSum(self.ty_path(path), + ast::TyKind::ObjectSum(self.ty_path(path), bounds)) } @@ -417,7 +417,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { mutbl: ast::Mutability) -> P { self.ty(span, - ast::TyRptr(lifetime, self.ty_mt(ty, mutbl))) + ast::TyKind::Rptr(lifetime, self.ty_mt(ty, mutbl))) } fn ty_ptr(&self, @@ -426,7 +426,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { mutbl: ast::Mutability) -> P { self.ty(span, - ast::TyPtr(self.ty_mt(ty, mutbl))) + ast::TyKind::Ptr(self.ty_mt(ty, mutbl))) } fn ty_option(&self, ty: P) -> P { @@ -440,7 +440,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn ty_infer(&self, span: Span) -> P { - self.ty(span, ast::TyInfer) + self.ty(span, ast::TyKind::Infer) } fn typaram(&self, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 69b932aa72b..9b31465b547 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -562,7 +562,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE DeclKind::Local(local) => { // take it apart: let rewritten_local = local.map(|Local {id, pat, ty, init, span, attrs}| { - // expand the ty since TyFixedLengthVec contains an Expr + // expand the ty since TyKind::FixedLengthVec contains an Expr // and thus may have a macro use let expanded_ty = ty.map(|t| fld.fold_ty(t)); // expand the pat (it might contain macro uses): @@ -1133,7 +1133,7 @@ fn expand_and_rename_method(sig: ast::MethodSig, body: P, pub fn expand_type(t: P, fld: &mut MacroExpander) -> P { let t = match t.node.clone() { - ast::Ty_::TyMac(mac) => { + ast::TyKind::Mac(mac) => { if fld.cx.ecfg.features.unwrap().type_macros { let expanded_ty = match expand_mac_invoc(mac, t.span, |r| r.make_ty(), diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 8cd2d24102f..1a6171e1981 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -380,46 +380,46 @@ pub fn noop_fold_ty(t: P, fld: &mut T) -> P { t.map(|Ty {id, node, span}| Ty { id: fld.new_id(id), node: match node { - TyInfer => node, - TyVec(ty) => TyVec(fld.fold_ty(ty)), - TyPtr(mt) => TyPtr(fld.fold_mt(mt)), - TyRptr(region, mt) => { - TyRptr(fld.fold_opt_lifetime(region), fld.fold_mt(mt)) + TyKind::Infer => node, + TyKind::Vec(ty) => TyKind::Vec(fld.fold_ty(ty)), + TyKind::Ptr(mt) => TyKind::Ptr(fld.fold_mt(mt)), + TyKind::Rptr(region, mt) => { + TyKind::Rptr(fld.fold_opt_lifetime(region), fld.fold_mt(mt)) } - TyBareFn(f) => { - TyBareFn(f.map(|BareFnTy {lifetimes, unsafety, abi, decl}| BareFnTy { + TyKind::BareFn(f) => { + TyKind::BareFn(f.map(|BareFnTy {lifetimes, unsafety, abi, decl}| BareFnTy { lifetimes: fld.fold_lifetime_defs(lifetimes), unsafety: unsafety, abi: abi, decl: fld.fold_fn_decl(decl) })) } - TyTup(tys) => TyTup(tys.move_map(|ty| fld.fold_ty(ty))), - TyParen(ty) => TyParen(fld.fold_ty(ty)), - TyPath(qself, path) => { + TyKind::Tup(tys) => TyKind::Tup(tys.move_map(|ty| fld.fold_ty(ty))), + TyKind::Paren(ty) => TyKind::Paren(fld.fold_ty(ty)), + TyKind::Path(qself, path) => { let qself = qself.map(|QSelf { ty, position }| { QSelf { ty: fld.fold_ty(ty), position: position } }); - TyPath(qself, fld.fold_path(path)) + TyKind::Path(qself, fld.fold_path(path)) } - TyObjectSum(ty, bounds) => { - TyObjectSum(fld.fold_ty(ty), + TyKind::ObjectSum(ty, bounds) => { + TyKind::ObjectSum(fld.fold_ty(ty), fld.fold_bounds(bounds)) } - TyFixedLengthVec(ty, e) => { - TyFixedLengthVec(fld.fold_ty(ty), fld.fold_expr(e)) + TyKind::FixedLengthVec(ty, e) => { + TyKind::FixedLengthVec(fld.fold_ty(ty), fld.fold_expr(e)) } - TyTypeof(expr) => { - TyTypeof(fld.fold_expr(expr)) + TyKind::Typeof(expr) => { + TyKind::Typeof(fld.fold_expr(expr)) } - TyPolyTraitRef(bounds) => { - TyPolyTraitRef(bounds.move_map(|b| fld.fold_ty_param_bound(b))) + TyKind::PolyTraitRef(bounds) => { + TyKind::PolyTraitRef(bounds.move_map(|b| fld.fold_ty_param_bound(b))) } - TyMac(mac) => { - TyMac(fld.fold_mac(mac)) + TyKind::Mac(mac) => { + TyKind::Mac(fld.fold_mac(mac)) } }, span: fld.new_span(span) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index d800b6925c0..d467405e089 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -916,7 +916,7 @@ mod tests { node: ast::ItemFn(P(ast::FnDecl { inputs: vec!(ast::Arg{ ty: P(ast::Ty{id: ast::DUMMY_NODE_ID, - node: ast::TyPath(None, ast::Path{ + node: ast::TyKind::Path(None, ast::Path{ span:sp(10,13), global:false, segments: vec!( diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 99db01a915e..1a8b1cbc374 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -42,10 +42,7 @@ use ast::{StmtExpr, StmtSemi, StmtMac, VariantData, StructField}; use ast::StrStyle; use ast::SelfKind; use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef}; -use ast::{Ty, Ty_, TypeBinding, TyMac}; -use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer}; -use ast::{TyParam, TyParamBounds, TyParen, TyPath, TyPtr}; -use ast::{TyRptr, TyTup, TyVec}; +use ast::{Ty, TyKind, TypeBinding, TyParam, TyParamBounds}; use ast::TypeTraitItem; use ast::UnnamedField; use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; @@ -1058,7 +1055,7 @@ impl<'a> Parser<'a> { } } - pub fn parse_for_in_type(&mut self) -> PResult<'a, Ty_> { + pub fn parse_for_in_type(&mut self) -> PResult<'a, TyKind> { /* Parses whatever can come after a `for` keyword in a type. The `for` has already been consumed. @@ -1097,16 +1094,17 @@ impl<'a> Parser<'a> { Some(TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)).into_iter() .chain(other_bounds.into_vec()) .collect(); - Ok(ast::TyPolyTraitRef(all_bounds)) + Ok(ast::TyKind::PolyTraitRef(all_bounds)) } } - pub fn parse_ty_path(&mut self) -> PResult<'a, Ty_> { - Ok(TyPath(None, try!(self.parse_path(LifetimeAndTypesWithoutColons)))) + pub fn parse_ty_path(&mut self) -> PResult<'a, TyKind> { + Ok(TyKind::Path(None, try!(self.parse_path(LifetimeAndTypesWithoutColons)))) } - /// parse a TyBareFn type: - pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec) -> PResult<'a, Ty_> { + /// parse a TyKind::BareFn type: + pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec) + -> PResult<'a, TyKind> { /* [unsafe] [extern "ABI"] fn <'lt> (S) -> T @@ -1134,7 +1132,7 @@ impl<'a> Parser<'a> { output: ret_ty, variadic: variadic }); - Ok(TyBareFn(P(BareFnTy { + Ok(TyKind::BareFn(P(BareFnTy { abi: abi, unsafety: unsafety, lifetimes: lifetime_defs, @@ -1308,7 +1306,7 @@ impl<'a> Parser<'a> { } let sp = mk_sp(lo, self.last_span.hi); - let sum = ast::TyObjectSum(lhs, bounds); + let sum = ast::TyKind::ObjectSum(lhs, bounds); Ok(P(Ty {id: ast::DUMMY_NODE_ID, node: sum, span: sp})) } @@ -1339,14 +1337,14 @@ impl<'a> Parser<'a> { try!(self.expect(&token::CloseDelim(token::Paren))); if ts.len() == 1 && !last_comma { - TyParen(ts.into_iter().nth(0).unwrap()) + TyKind::Paren(ts.into_iter().nth(0).unwrap()) } else { - TyTup(ts) + TyKind::Tup(ts) } } else if self.check(&token::BinOp(token::Star)) { // STAR POINTER (bare pointer?) self.bump(); - TyPtr(try!(self.parse_ptr())) + TyKind::Ptr(try!(self.parse_ptr())) } else if self.check(&token::OpenDelim(token::Bracket)) { // VECTOR try!(self.expect(&token::OpenDelim(token::Bracket))); @@ -1355,8 +1353,8 @@ impl<'a> Parser<'a> { // Parse the `; e` in `[ i32; e ]` // where `e` is a const expression let t = match try!(self.maybe_parse_fixed_length_of_vec()) { - None => TyVec(t), - Some(suffix) => TyFixedLengthVec(t, suffix) + None => TyKind::Vec(t), + Some(suffix) => TyKind::FixedLengthVec(t, suffix) }; try!(self.expect(&token::CloseDelim(token::Bracket))); t @@ -1376,13 +1374,13 @@ impl<'a> Parser<'a> { try!(self.expect(&token::OpenDelim(token::Paren))); let e = try!(self.parse_expr()); try!(self.expect(&token::CloseDelim(token::Paren))); - TyTypeof(e) + TyKind::Typeof(e) } else if self.eat_lt() { let (qself, path) = try!(self.parse_qualified_path(NoTypesAllowed)); - TyPath(Some(qself), path) + TyKind::Path(Some(qself), path) } else if self.check(&token::ModSep) || self.token.is_ident() || self.token.is_path() { @@ -1395,14 +1393,14 @@ impl<'a> Parser<'a> { seq_sep_none(), |p| p.parse_token_tree())); let hi = self.span.hi; - TyMac(spanned(lo, hi, Mac_ { path: path, tts: tts, ctxt: EMPTY_CTXT })) + TyKind::Mac(spanned(lo, hi, Mac_ { path: path, tts: tts, ctxt: EMPTY_CTXT })) } else { // NAMED TYPE - TyPath(None, path) + TyKind::Path(None, path) } } else if self.eat(&token::Underscore) { // TYPE TO BE INFERRED - TyInfer + TyKind::Infer } else { let this_token_str = self.this_token_to_string(); let msg = format!("expected type, found `{}`", this_token_str); @@ -1413,12 +1411,12 @@ impl<'a> Parser<'a> { Ok(P(Ty {id: ast::DUMMY_NODE_ID, node: t, span: sp})) } - pub fn parse_borrowed_pointee(&mut self) -> PResult<'a, Ty_> { + pub fn parse_borrowed_pointee(&mut self) -> PResult<'a, TyKind> { // look for `&'lt` or `&'foo ` and interpret `foo` as the region name: let opt_lifetime = try!(self.parse_opt_lifetime()); let mt = try!(self.parse_mt()); - return Ok(TyRptr(opt_lifetime, mt)); + return Ok(TyKind::Rptr(opt_lifetime, mt)); } pub fn parse_ptr(&mut self) -> PResult<'a, MutTy> { @@ -1498,7 +1496,7 @@ impl<'a> Parser<'a> { } else { P(Ty { id: ast::DUMMY_NODE_ID, - node: TyInfer, + node: TyKind::Infer, span: mk_sp(self.span.lo, self.span.hi), }) }; @@ -4809,7 +4807,7 @@ impl<'a> Parser<'a> { let opt_trait = if could_be_trait && self.eat_keyword(keywords::For) { // New-style trait. Reinterpret the type as a trait. match ty.node { - TyPath(None, ref path) => { + TyKind::Path(None, ref path) => { Some(TraitRef { path: (*path).clone(), ref_id: ty.id, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 1df73014b85..1e57d347f5a 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -957,12 +957,12 @@ impl<'a> State<'a> { try!(self.maybe_print_comment(ty.span.lo)); try!(self.ibox(0)); match ty.node { - ast::TyVec(ref ty) => { + ast::TyKind::Vec(ref ty) => { try!(word(&mut self.s, "[")); try!(self.print_type(&**ty)); try!(word(&mut self.s, "]")); } - ast::TyPtr(ref mt) => { + ast::TyKind::Ptr(ref mt) => { try!(word(&mut self.s, "*")); match mt.mutbl { ast::MutMutable => try!(self.word_nbsp("mut")), @@ -970,12 +970,12 @@ impl<'a> State<'a> { } try!(self.print_type(&*mt.ty)); } - ast::TyRptr(ref lifetime, ref mt) => { + ast::TyKind::Rptr(ref lifetime, ref mt) => { try!(word(&mut self.s, "&")); try!(self.print_opt_lifetime(lifetime)); try!(self.print_mt(mt)); } - ast::TyTup(ref elts) => { + ast::TyKind::Tup(ref elts) => { try!(self.popen()); try!(self.commasep(Inconsistent, &elts[..], |s, ty| s.print_type(&**ty))); @@ -984,12 +984,12 @@ impl<'a> State<'a> { } try!(self.pclose()); } - ast::TyParen(ref typ) => { + ast::TyKind::Paren(ref typ) => { try!(self.popen()); try!(self.print_type(&**typ)); try!(self.pclose()); } - ast::TyBareFn(ref f) => { + ast::TyKind::BareFn(ref f) => { let generics = ast::Generics { lifetimes: f.lifetimes.clone(), ty_params: P::empty(), @@ -1005,35 +1005,35 @@ impl<'a> State<'a> { &generics, None)); } - ast::TyPath(None, ref path) => { + ast::TyKind::Path(None, ref path) => { try!(self.print_path(path, false, 0)); } - ast::TyPath(Some(ref qself), ref path) => { + ast::TyKind::Path(Some(ref qself), ref path) => { try!(self.print_qpath(path, qself, false)) } - ast::TyObjectSum(ref ty, ref bounds) => { + ast::TyKind::ObjectSum(ref ty, ref bounds) => { try!(self.print_type(&**ty)); try!(self.print_bounds("+", &bounds[..])); } - ast::TyPolyTraitRef(ref bounds) => { + ast::TyKind::PolyTraitRef(ref bounds) => { try!(self.print_bounds("", &bounds[..])); } - ast::TyFixedLengthVec(ref ty, ref v) => { + ast::TyKind::FixedLengthVec(ref ty, ref v) => { try!(word(&mut self.s, "[")); try!(self.print_type(&**ty)); try!(word(&mut self.s, "; ")); try!(self.print_expr(&**v)); try!(word(&mut self.s, "]")); } - ast::TyTypeof(ref e) => { + ast::TyKind::Typeof(ref e) => { try!(word(&mut self.s, "typeof(")); try!(self.print_expr(&**e)); try!(word(&mut self.s, ")")); } - ast::TyInfer => { + ast::TyKind::Infer => { try!(word(&mut self.s, "_")); } - ast::TyMac(ref m) => { + ast::TyKind::Mac(ref m) => { try!(self.print_mac(m, token::Paren)); } } @@ -2959,7 +2959,7 @@ impl<'a> State<'a> { pub fn print_arg(&mut self, input: &ast::Arg, is_closure: bool) -> io::Result<()> { try!(self.ibox(INDENT_UNIT)); match input.ty.node { - ast::TyInfer if is_closure => try!(self.print_pat(&*input.pat)), + ast::TyKind::Infer if is_closure => try!(self.print_pat(&*input.pat)), _ => { match input.pat.node { ast::PatIdent(_, ref path1, _) if diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index dbdc1bfcbaa..24890d2cbed 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -358,7 +358,7 @@ fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool { ast::ItemFn(ref decl, _, _, _, ref generics, _) => { let no_output = match decl.output { ast::FunctionRetTy::Default(..) => true, - ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyTup(vec![]) => true, + ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyKind::Tup(vec![]) => true, _ => false }; if decl.inputs.is_empty() @@ -395,7 +395,7 @@ fn is_bench_fn(cx: &TestCtxt, i: &ast::Item) -> bool { let input_cnt = decl.inputs.len(); let no_output = match decl.output { ast::FunctionRetTy::Default(..) => true, - ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyTup(vec![]) => true, + ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyKind::Tup(vec![]) => true, _ => false }; let tparm_cnt = generics.ty_params.len(); @@ -494,7 +494,7 @@ fn mk_main(cx: &mut TestCtxt) -> P { let main_meta = ecx.meta_word(sp, token::intern_and_get_ident("main")); let main_attr = ecx.attribute(sp, main_meta); // pub fn main() { ... } - let main_ret_ty = ecx.ty(sp, ast::TyTup(vec![])); + let main_ret_ty = ecx.ty(sp, ast::TyKind::Tup(vec![])); let main_body = ecx.block_all(sp, vec![call_test_main], None); let main = ast::ItemFn(ecx.fn_decl(vec![], main_ret_ty), ast::Unsafety::Normal, @@ -591,7 +591,7 @@ fn mk_tests(cx: &TestCtxt) -> P { let static_lt = ecx.lifetime(sp, token::special_idents::static_lifetime.name); // &'static [self::test::TestDescAndFn] let static_type = ecx.ty_rptr(sp, - ecx.ty(sp, ast::TyVec(struct_type)), + ecx.ty(sp, ast::TyKind::Vec(struct_type)), Some(static_lt), ast::MutImmutable); // static TESTS: $static_type = &[...]; diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 90cc403961e..44b3e581849 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -328,45 +328,45 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V, pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { match typ.node { - TyVec(ref ty) | TyParen(ref ty) => { + TyKind::Vec(ref ty) | TyKind::Paren(ref ty) => { visitor.visit_ty(ty) } - TyPtr(ref mutable_type) => { + TyKind::Ptr(ref mutable_type) => { visitor.visit_ty(&mutable_type.ty) } - TyRptr(ref opt_lifetime, ref mutable_type) => { + TyKind::Rptr(ref opt_lifetime, ref mutable_type) => { walk_list!(visitor, visit_lifetime, opt_lifetime); visitor.visit_ty(&mutable_type.ty) } - TyTup(ref tuple_element_types) => { + TyKind::Tup(ref tuple_element_types) => { walk_list!(visitor, visit_ty, tuple_element_types); } - TyBareFn(ref function_declaration) => { + TyKind::BareFn(ref function_declaration) => { walk_fn_decl(visitor, &function_declaration.decl); walk_list!(visitor, visit_lifetime_def, &function_declaration.lifetimes); } - TyPath(ref maybe_qself, ref path) => { + TyKind::Path(ref maybe_qself, ref path) => { if let Some(ref qself) = *maybe_qself { visitor.visit_ty(&qself.ty); } visitor.visit_path(path, typ.id); } - TyObjectSum(ref ty, ref bounds) => { + TyKind::ObjectSum(ref ty, ref bounds) => { visitor.visit_ty(ty); walk_list!(visitor, visit_ty_param_bound, bounds); } - TyFixedLengthVec(ref ty, ref expression) => { + TyKind::FixedLengthVec(ref ty, ref expression) => { visitor.visit_ty(ty); visitor.visit_expr(expression) } - TyPolyTraitRef(ref bounds) => { + TyKind::PolyTraitRef(ref bounds) => { walk_list!(visitor, visit_ty_param_bound, bounds); } - TyTypeof(ref expression) => { + TyKind::Typeof(ref expression) => { visitor.visit_expr(expression) } - TyInfer => {} - TyMac(ref mac) => { + TyKind::Infer => {} + TyKind::Mac(ref mac) => { visitor.visit_mac(mac) } } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 950c2f48bac..e54ff637f25 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -354,7 +354,7 @@ fn find_type_parameters(ty: &ast::Ty, ty_param_names: &[ast::Name]) -> Vec visit::Visitor<'a> for Visitor<'a> { fn visit_ty(&mut self, ty: &'a ast::Ty) { match ty.node { - ast::TyPath(_, ref path) if !path.global => { + ast::TyKind::Path(_, ref path) if !path.global => { match path.segments.first() { Some(segment) => { if self.ty_param_names.contains(&segment.identifier.name) { @@ -557,7 +557,7 @@ impl<'a> TraitDef<'a> { for ty in tys { // if we have already handled this type, skip it - if let ast::TyPath(_, ref p) = ty.node { + if let ast::TyKind::Path(_, ref p) = ty.node { if p.segments.len() == 1 && ty_param_names.contains(&p.segments[0].identifier.name) || processed_field_types.contains(&p.segments) { diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index 543beeb5da0..e5b82fa1afc 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -153,7 +153,7 @@ impl<'a> Ty<'a> { cx.ty_path(self.to_path(cx, span, self_ty, self_generics)) } Tuple(ref fields) => { - let ty = ast::TyTup(fields.iter() + let ty = ast::TyKind::Tup(fields.iter() .map(|f| f.to_ty(cx, span, self_ty, self_generics)) .collect()); cx.ty(span, ty) diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 986cdef49b2..21b32153ed9 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -448,7 +448,7 @@ impl<'a, 'b> Context<'a, 'b> { -> P { let sp = piece_ty.span; let ty = ecx.ty_rptr(sp, - ecx.ty(sp, ast::TyVec(piece_ty)), + ecx.ty(sp, ast::TyKind::Vec(piece_ty)), Some(ecx.lifetime(sp, special_idents::static_lifetime.name)), ast::MutImmutable); let slice = ecx.expr_vec_slice(sp, pieces); -- 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/format.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/format.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 019614f03d106324ab50a37746b556c41e66c099 Mon Sep 17 00:00:00 2001 From: Oliver 'ker' Schneider Date: Tue, 9 Feb 2016 11:36:51 +0100 Subject: [breaking-change] don't glob export ast::Item_ variants --- src/librustc/front/check_attr.rs | 6 +-- src/librustc_driver/pretty.rs | 8 ++-- src/librustc_front/lowering.rs | 32 +++++++-------- src/librustc_metadata/creader.rs | 2 +- src/librustc_metadata/macro_import.rs | 4 +- src/librustc_passes/const_fn.rs | 4 +- src/librustc_trans/save/dump_csv.rs | 25 ++++++------ src/librustc_trans/save/mod.rs | 12 +++--- src/libsyntax/ast.rs | 65 +++++++++++++++---------------- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/config.rs | 24 ++++++------ src/libsyntax/diagnostics/plugin.rs | 2 +- src/libsyntax/entry.rs | 4 +- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/build.rs | 20 +++++----- src/libsyntax/ext/expand.rs | 24 ++++++------ src/libsyntax/feature_gate.rs | 12 +++--- src/libsyntax/fold.rs | 62 ++++++++++++++--------------- src/libsyntax/parse/mod.rs | 2 +- src/libsyntax/parse/parser.rs | 45 ++++++++++----------- src/libsyntax/print/pprust.rs | 30 +++++++------- src/libsyntax/std_inject.rs | 4 +- src/libsyntax/test.rs | 20 +++++----- src/libsyntax/visit.rs | 28 ++++++------- src/libsyntax_ext/deriving/generic/mod.rs | 16 ++++---- src/libsyntax_ext/format.rs | 2 +- src/test/auxiliary/macro_crate_test.rs | 6 +-- 27 files changed, 230 insertions(+), 233 deletions(-) (limited to 'src/libsyntax_ext/format.rs') diff --git a/src/librustc/front/check_attr.rs b/src/librustc/front/check_attr.rs index 27785a072a6..cfd9d5bdaa7 100644 --- a/src/librustc/front/check_attr.rs +++ b/src/librustc/front/check_attr.rs @@ -26,9 +26,9 @@ enum Target { impl Target { fn from_item(item: &ast::Item) -> Target { match item.node { - ast::ItemFn(..) => Target::Fn, - ast::ItemStruct(..) => Target::Struct, - ast::ItemEnum(..) => Target::Enum, + ast::ItemKind::Fn(..) => Target::Fn, + ast::ItemKind::Struct(..) => Target::Struct, + ast::ItemKind::Enum(..) => Target::Enum, _ => Target::Other, } } diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 0f6ba63d54b..e0a948f7661 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -600,16 +600,16 @@ impl ReplaceBodyWithLoop { } impl fold::Folder for ReplaceBodyWithLoop { - fn fold_item_underscore(&mut self, i: ast::Item_) -> ast::Item_ { + fn fold_item_kind(&mut self, i: ast::ItemKind) -> ast::ItemKind { match i { - ast::ItemStatic(..) | ast::ItemConst(..) => { + ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => { self.within_static_or_const = true; - let ret = fold::noop_fold_item_underscore(i, self); + let ret = fold::noop_fold_item_kind(i, self); self.within_static_or_const = false; return ret; } _ => { - fold::noop_fold_item_underscore(i, self) + fold::noop_fold_item_kind(i, self) } } } diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index 781008db129..d04f4c96504 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -654,21 +654,21 @@ pub fn lower_block(lctx: &LoweringContext, b: &Block) -> P { }) } -pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ { +pub fn lower_item_kind(lctx: &LoweringContext, i: &ItemKind) -> hir::Item_ { match *i { - ItemExternCrate(string) => hir::ItemExternCrate(string), - ItemUse(ref view_path) => { + ItemKind::ExternCrate(string) => hir::ItemExternCrate(string), + ItemKind::Use(ref view_path) => { hir::ItemUse(lower_view_path(lctx, view_path)) } - ItemStatic(ref t, m, ref e) => { + ItemKind::Static(ref t, m, ref e) => { hir::ItemStatic(lower_ty(lctx, t), lower_mutability(lctx, m), lower_expr(lctx, e)) } - ItemConst(ref t, ref e) => { + ItemKind::Const(ref t, ref e) => { hir::ItemConst(lower_ty(lctx, t), lower_expr(lctx, e)) } - ItemFn(ref decl, unsafety, constness, abi, ref generics, ref body) => { + ItemKind::Fn(ref decl, unsafety, constness, abi, ref generics, ref body) => { hir::ItemFn(lower_fn_decl(lctx, decl), lower_unsafety(lctx, unsafety), lower_constness(lctx, constness), @@ -676,12 +676,12 @@ pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ { lower_generics(lctx, generics), lower_block(lctx, body)) } - ItemMod(ref m) => hir::ItemMod(lower_mod(lctx, m)), - ItemForeignMod(ref nm) => hir::ItemForeignMod(lower_foreign_mod(lctx, nm)), - ItemTy(ref t, ref generics) => { + ItemKind::Mod(ref m) => hir::ItemMod(lower_mod(lctx, m)), + ItemKind::ForeignMod(ref nm) => hir::ItemForeignMod(lower_foreign_mod(lctx, nm)), + ItemKind::Ty(ref t, ref generics) => { hir::ItemTy(lower_ty(lctx, t), lower_generics(lctx, generics)) } - ItemEnum(ref enum_definition, ref generics) => { + ItemKind::Enum(ref enum_definition, ref generics) => { hir::ItemEnum(hir::EnumDef { variants: enum_definition.variants .iter() @@ -690,15 +690,15 @@ pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ { }, lower_generics(lctx, generics)) } - ItemStruct(ref struct_def, ref generics) => { + ItemKind::Struct(ref struct_def, ref generics) => { let struct_def = lower_variant_data(lctx, struct_def); hir::ItemStruct(struct_def, lower_generics(lctx, generics)) } - ItemDefaultImpl(unsafety, ref trait_ref) => { + ItemKind::DefaultImpl(unsafety, ref trait_ref) => { hir::ItemDefaultImpl(lower_unsafety(lctx, unsafety), lower_trait_ref(lctx, trait_ref)) } - ItemImpl(unsafety, polarity, ref generics, ref ifce, ref ty, ref impl_items) => { + ItemKind::Impl(unsafety, polarity, ref generics, ref ifce, ref ty, ref impl_items) => { let new_impl_items = impl_items.iter() .map(|item| lower_impl_item(lctx, item)) .collect(); @@ -710,7 +710,7 @@ pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ { lower_ty(lctx, ty), new_impl_items) } - ItemTrait(unsafety, ref generics, ref bounds, ref items) => { + ItemKind::Trait(unsafety, ref generics, ref bounds, ref items) => { let bounds = lower_bounds(lctx, bounds); let items = items.iter().map(|item| lower_trait_item(lctx, item)).collect(); hir::ItemTrait(lower_unsafety(lctx, unsafety), @@ -718,7 +718,7 @@ pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ { bounds, items) } - ItemMac(_) => panic!("Shouldn't still be around"), + ItemKind::Mac(_) => panic!("Shouldn't still be around"), } } @@ -820,7 +820,7 @@ pub fn lower_item_id(_lctx: &LoweringContext, i: &Item) -> hir::ItemId { } pub fn lower_item(lctx: &LoweringContext, i: &Item) -> hir::Item { - let node = lower_item_underscore(lctx, &i.node); + let node = lower_item_kind(lctx, &i.node); hir::Item { id: i.id, diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index d5aa091886e..52456251f96 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -157,7 +157,7 @@ impl<'a> CrateReader<'a> { fn extract_crate_info(&self, i: &ast::Item) -> Option { match i.node { - ast::ItemExternCrate(ref path_opt) => { + ast::ItemKind::ExternCrate(ref path_opt) => { debug!("resolving extern crate stmt. ident: {} path_opt: {:?}", i.ident, path_opt); let name = match *path_opt { diff --git a/src/librustc_metadata/macro_import.rs b/src/librustc_metadata/macro_import.rs index d67fc3a0eab..b2395ac355f 100644 --- a/src/librustc_metadata/macro_import.rs +++ b/src/librustc_metadata/macro_import.rs @@ -56,7 +56,7 @@ pub fn read_macro_defs(sess: &Session, cstore: &CStore, krate: &ast::Crate) // crate root, because `$crate` won't work properly. Identify these by // spans, because the crate map isn't set up yet. for item in &krate.module.items { - if let ast::ItemExternCrate(_) = item.node { + if let ast::ItemKind::ExternCrate(_) = item.node { loader.span_whitelist.insert(item.span); } } @@ -73,7 +73,7 @@ impl<'a, 'v> Visitor<'v> for MacroLoader<'a> { fn visit_item(&mut self, item: &ast::Item) { // We're only interested in `extern crate`. match item.node { - ast::ItemExternCrate(_) => {} + ast::ItemKind::ExternCrate(_) => {} _ => { visit::walk_item(self, item); return; diff --git a/src/librustc_passes/const_fn.rs b/src/librustc_passes/const_fn.rs index ec9fa1afb55..98346f538b0 100644 --- a/src/librustc_passes/const_fn.rs +++ b/src/librustc_passes/const_fn.rs @@ -78,10 +78,10 @@ impl<'a, 'v> Visitor<'v> for CheckConstFn<'a> { fn visit_item(&mut self, i: &'v ast::Item) { visit::walk_item(self, i); match i.node { - ast::ItemConst(_, ref e) => { + ast::ItemKind::Const(_, ref e) => { CheckBlock{ sess: self.sess, kind: "constant"}.visit_expr(e) }, - ast::ItemStatic(_, _, ref e) => { + ast::ItemKind::Static(_, _, ref e) => { CheckBlock{ sess: self.sess, kind: "static"}.visit_expr(e) }, _ => {}, diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index 10840933c01..d8f21fd4dd6 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -864,9 +864,10 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { fn visit_item(&mut self, item: &ast::Item) { + use syntax::ast::ItemKind::*; self.process_macro_use(item.span, item.id); match item.node { - ast::ItemUse(ref use_item) => { + Use(ref use_item) => { match use_item.node { ast::ViewPathSimple(ident, ref path) => { let sub_span = self.span.span_for_last_ident(path.span); @@ -950,7 +951,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { } } } - ast::ItemExternCrate(ref s) => { + ExternCrate(ref s) => { let location = match *s { Some(s) => s.to_string(), None => item.ident.to_string(), @@ -968,28 +969,28 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { &location, self.cur_scope); } - ast::ItemFn(ref decl, _, _, _, ref ty_params, ref body) => + Fn(ref decl, _, _, _, ref ty_params, ref body) => self.process_fn(item, &**decl, ty_params, &**body), - ast::ItemStatic(ref typ, _, ref expr) => + Static(ref typ, _, ref expr) => self.process_static_or_const_item(item, typ, expr), - ast::ItemConst(ref typ, ref expr) => + Const(ref typ, ref expr) => self.process_static_or_const_item(item, &typ, &expr), - ast::ItemStruct(ref def, ref ty_params) => self.process_struct(item, def, ty_params), - ast::ItemEnum(ref def, ref ty_params) => self.process_enum(item, def, ty_params), - ast::ItemImpl(_, _, + Struct(ref def, ref ty_params) => self.process_struct(item, def, ty_params), + Enum(ref def, ref ty_params) => self.process_enum(item, def, ty_params), + Impl(_, _, ref ty_params, ref trait_ref, ref typ, ref impl_items) => { self.process_impl(item, ty_params, trait_ref, &typ, impl_items) } - ast::ItemTrait(_, ref generics, ref trait_refs, ref methods) => + Trait(_, ref generics, ref trait_refs, ref methods) => self.process_trait(item, generics, trait_refs, methods), - ast::ItemMod(ref m) => { + Mod(ref m) => { self.process_mod(item); self.nest(item.id, |v| visit::walk_mod(v, m)); } - ast::ItemTy(ref ty, ref ty_params) => { + Ty(ref ty, ref ty_params) => { let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); let value = ty_to_string(&**ty); let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Type); @@ -998,7 +999,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { self.visit_ty(&**ty); self.process_generic_params(ty_params, item.span, &qualname, item.id); } - ast::ItemMac(_) => (), + Mac(_) => (), _ => visit::walk_item(self, item), } } diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 53fa1bfff38..1790da39ad0 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -229,7 +229,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { pub fn get_item_data(&self, item: &ast::Item) -> Option { match item.node { - ast::ItemFn(..) => { + ast::ItemKind::Fn(..) => { let name = self.tcx.map.path_to_string(item.id); let qualname = format!("::{}", name); let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Fn); @@ -243,7 +243,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { scope: self.enclosing_scope(item.id), })) } - ast::ItemStatic(ref typ, mt, ref expr) => { + ast::ItemKind::Static(ref typ, mt, ref expr) => { let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); // If the variable is immutable, save the initialising expression. @@ -264,7 +264,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { type_value: ty_to_string(&typ), })) } - ast::ItemConst(ref typ, ref expr) => { + ast::ItemKind::Const(ref typ, ref expr) => { let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Const); filter!(self.span_utils, sub_span, item.span, None); @@ -278,7 +278,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { type_value: ty_to_string(&typ), })) } - ast::ItemMod(ref m) => { + ast::ItemKind::Mod(ref m) => { let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); let cm = self.tcx.sess.codemap(); @@ -295,7 +295,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { filename: filename, })) } - ast::ItemEnum(..) => { + ast::ItemKind::Enum(..) => { let enum_name = format!("::{}", self.tcx.map.path_to_string(item.id)); let val = self.span_utils.snippet(item.span); let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Enum); @@ -308,7 +308,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { scope: self.enclosing_scope(item.id), })) } - ast::ItemImpl(_, _, _, ref trait_ref, ref typ, _) => { + ast::ItemKind::Impl(_, _, _, ref trait_ref, ref typ, _) => { let mut type_data = None; let sub_span; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index f2225ff2c09..7519def1503 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,7 +10,6 @@ // The Rust abstract syntax tree. -pub use self::Item_::*; pub use self::KleeneOp::*; pub use self::MacStmtStyle::*; pub use self::MetaItem_::*; @@ -1828,7 +1827,7 @@ pub struct Attribute_ { /// /// resolve maps each TraitRef's ref_id to its defining trait; that's all /// that the ref_id is for. The impl_id maps to the "self type" of this impl. -/// If this impl is an ItemImpl, the impl_id is redundant (it could be the +/// If this impl is an ItemKind::Impl, the impl_id is redundant (it could be the /// same as the impl's node id). #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct TraitRef { @@ -1956,7 +1955,7 @@ pub struct Item { pub ident: Ident, pub attrs: Vec, pub id: NodeId, - pub node: Item_, + pub node: ItemKind, pub vis: Visibility, pub span: Span, } @@ -1968,32 +1967,32 @@ impl Item { } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum Item_ { +pub enum ItemKind { /// An`extern crate` item, with optional original crate name, /// /// e.g. `extern crate foo` or `extern crate foo_bar as foo` - ItemExternCrate(Option), + ExternCrate(Option), /// A `use` or `pub use` item - ItemUse(P), + Use(P), /// A `static` item - ItemStatic(P, Mutability, P), + Static(P, Mutability, P), /// A `const` item - ItemConst(P, P), + Const(P, P), /// A function declaration - ItemFn(P, Unsafety, Constness, Abi, Generics, P), + Fn(P, Unsafety, Constness, Abi, Generics, P), /// A module - ItemMod(Mod), + Mod(Mod), /// An external module - ItemForeignMod(ForeignMod), + ForeignMod(ForeignMod), /// A type alias, e.g. `type Foo = Bar` - ItemTy(P, Generics), + Ty(P, Generics), /// An enum definition, e.g. `enum Foo {C, D}` - ItemEnum(EnumDef, Generics), + Enum(EnumDef, Generics), /// A struct definition, e.g. `struct Foo {x: A}` - ItemStruct(VariantData, Generics), + Struct(VariantData, Generics), /// Represents a Trait Declaration - ItemTrait(Unsafety, + Trait(Unsafety, Generics, TyParamBounds, Vec>), @@ -2001,35 +2000,35 @@ pub enum Item_ { // Default trait implementations /// // `impl Trait for .. {}` - ItemDefaultImpl(Unsafety, TraitRef), + DefaultImpl(Unsafety, TraitRef), /// An implementation, eg `impl Trait for Foo { .. }` - ItemImpl(Unsafety, + Impl(Unsafety, ImplPolarity, Generics, Option, // (optional) trait this impl implements P, // self Vec>), /// A macro invocation (which includes macro definition) - ItemMac(Mac), + Mac(Mac), } -impl Item_ { +impl ItemKind { pub fn descriptive_variant(&self) -> &str { match *self { - ItemExternCrate(..) => "extern crate", - ItemUse(..) => "use", - ItemStatic(..) => "static item", - ItemConst(..) => "constant item", - ItemFn(..) => "function", - ItemMod(..) => "module", - ItemForeignMod(..) => "foreign module", - ItemTy(..) => "type alias", - ItemEnum(..) => "enum", - ItemStruct(..) => "struct", - ItemTrait(..) => "trait", - ItemMac(..) | - ItemImpl(..) | - ItemDefaultImpl(..) => "item" + ItemKind::ExternCrate(..) => "extern crate", + ItemKind::Use(..) => "use", + ItemKind::Static(..) => "static item", + ItemKind::Const(..) => "constant item", + ItemKind::Fn(..) => "function", + ItemKind::Mod(..) => "module", + ItemKind::ForeignMod(..) => "foreign module", + ItemKind::Ty(..) => "type alias", + ItemKind::Enum(..) => "enum", + ItemKind::Struct(..) => "struct", + ItemKind::Trait(..) => "trait", + ItemKind::Mac(..) | + ItemKind::Impl(..) | + ItemKind::DefaultImpl(..) => "item" } } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 8ccff527b88..270133ad599 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -173,7 +173,7 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> { self.operation.visit_id(item.id); match item.node { - ItemUse(ref view_path) => { + ItemKind::Use(ref view_path) => { match view_path.node { ViewPathSimple(_, _) | ViewPathGlob(_) => {} diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 840acff73ad..57416bce3cb 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -52,8 +52,8 @@ impl<'a, F> fold::Folder for Context<'a, F> where F: FnMut(&[ast::Attribute]) -> fn fold_foreign_mod(&mut self, foreign_mod: ast::ForeignMod) -> ast::ForeignMod { fold_foreign_mod(self, foreign_mod) } - fn fold_item_underscore(&mut self, item: ast::Item_) -> ast::Item_ { - fold_item_underscore(self, item) + fn fold_item_kind(&mut self, item: ast::ItemKind) -> ast::ItemKind { + fold_item_kind(self, item) } fn fold_expr(&mut self, expr: P) -> P { // If an expr is valid to cfg away it will have been removed by the @@ -129,26 +129,26 @@ fn fold_item(cx: &mut Context, item: P) -> SmallVector(cx: &mut Context, item: ast::Item_) -> ast::Item_ where +fn fold_item_kind(cx: &mut Context, item: ast::ItemKind) -> ast::ItemKind where F: FnMut(&[ast::Attribute]) -> bool { let item = match item { - ast::ItemImpl(u, o, a, b, c, impl_items) => { + ast::ItemKind::Impl(u, o, a, b, c, impl_items) => { let impl_items = impl_items.into_iter() .filter(|ii| (cx.in_cfg)(&ii.attrs)) .collect(); - ast::ItemImpl(u, o, a, b, c, impl_items) + ast::ItemKind::Impl(u, o, a, b, c, impl_items) } - ast::ItemTrait(u, a, b, methods) => { + ast::ItemKind::Trait(u, a, b, methods) => { let methods = methods.into_iter() .filter(|ti| (cx.in_cfg)(&ti.attrs)) .collect(); - ast::ItemTrait(u, a, b, methods) + ast::ItemKind::Trait(u, a, b, methods) } - ast::ItemStruct(def, generics) => { - ast::ItemStruct(fold_struct(cx, def), generics) + ast::ItemKind::Struct(def, generics) => { + ast::ItemKind::Struct(fold_struct(cx, def), generics) } - ast::ItemEnum(def, generics) => { + ast::ItemKind::Enum(def, generics) => { let variants = def.variants.into_iter().filter_map(|v| { if !(cx.in_cfg)(&v.node.attrs) { None @@ -167,14 +167,14 @@ fn fold_item_underscore(cx: &mut Context, item: ast::Item_) -> ast::Item_ })) } }); - ast::ItemEnum(ast::EnumDef { + ast::ItemKind::Enum(ast::EnumDef { variants: variants.collect(), }, generics) } item => item, }; - fold::noop_fold_item_underscore(item, cx) + fold::noop_fold_item_kind(item, cx) } fn fold_struct(cx: &mut Context, vdata: ast::VariantData) -> ast::VariantData where diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 4e6fde10ade..e8a4bb59bdc 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -226,7 +226,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, ident: name.clone(), attrs: Vec::new(), id: ast::DUMMY_NODE_ID, - node: ast::ItemConst( + node: ast::ItemKind::Const( ty, expr, ), diff --git a/src/libsyntax/entry.rs b/src/libsyntax/entry.rs index ddc4443a77c..7014e576e2b 100644 --- a/src/libsyntax/entry.rs +++ b/src/libsyntax/entry.rs @@ -9,7 +9,7 @@ // except according to those terms. use attr; -use ast::{Item, ItemFn}; +use ast::{Item, ItemKind}; pub enum EntryPointType { None, @@ -23,7 +23,7 @@ pub enum EntryPointType { // them in sync. pub fn entry_point_type(item: &Item, depth: usize) -> EntryPointType { match item.node { - ItemFn(..) => { + ItemKind::Fn(..) => { if attr::contains_name(&item.attrs, "start") { EntryPointType::Start } else if attr::contains_name(&item.attrs, "main") { diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index ceb7cf69680..381d952ea88 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -120,7 +120,7 @@ impl MultiItemDecorator for F } } -// A more flexible ItemModifier (ItemModifier should go away, eventually, FIXME). +// A more flexible ItemKind::Modifier (ItemKind::Modifier should go away, eventually, FIXME). // meta_item is the annotation, item is the item being modified, parent_item // is the impl or trait item is declared in if item is part of such a thing. // FIXME Decorators should follow the same pattern too. diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 76071cc71e6..256825eacf2 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -213,7 +213,7 @@ pub trait AstBuilder { // items fn item(&self, span: Span, - name: Ident, attrs: Vec , node: ast::Item_) -> P; + name: Ident, attrs: Vec , node: ast::ItemKind) -> P; fn arg(&self, span: Span, name: Ident, ty: P) -> ast::Arg; // FIXME unused self @@ -951,7 +951,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn item(&self, span: Span, name: Ident, - attrs: Vec, node: ast::Item_) -> P { + attrs: Vec, node: ast::ItemKind) -> P { // FIXME: Would be nice if our generated code didn't violate // Rust coding conventions P(ast::Item { @@ -974,7 +974,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.item(span, name, Vec::new(), - ast::ItemFn(self.fn_decl(inputs, output), + ast::ItemKind::Fn(self.fn_decl(inputs, output), ast::Unsafety::Normal, ast::Constness::NotConst, Abi::Rust, @@ -1026,7 +1026,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn item_enum_poly(&self, span: Span, name: Ident, enum_definition: ast::EnumDef, generics: Generics) -> P { - self.item(span, name, Vec::new(), ast::ItemEnum(enum_definition, generics)) + self.item(span, name, Vec::new(), ast::ItemKind::Enum(enum_definition, generics)) } fn item_enum(&self, span: Span, name: Ident, @@ -1047,7 +1047,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn item_struct_poly(&self, span: Span, name: Ident, struct_def: ast::VariantData, generics: Generics) -> P { - self.item(span, name, Vec::new(), ast::ItemStruct(struct_def, generics)) + self.item(span, name, Vec::new(), ast::ItemKind::Struct(struct_def, generics)) } fn item_mod(&self, span: Span, inner_span: Span, name: Ident, @@ -1057,7 +1057,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { span, name, attrs, - ast::ItemMod(ast::Mod { + ast::ItemKind::Mod(ast::Mod { inner: inner_span, items: items, }) @@ -1071,7 +1071,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { mutbl: ast::Mutability, expr: P) -> P { - self.item(span, name, Vec::new(), ast::ItemStatic(ty, mutbl, expr)) + self.item(span, name, Vec::new(), ast::ItemKind::Static(ty, mutbl, expr)) } fn item_const(&self, @@ -1080,12 +1080,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ty: P, expr: P) -> P { - self.item(span, name, Vec::new(), ast::ItemConst(ty, expr)) + self.item(span, name, Vec::new(), ast::ItemKind::Const(ty, expr)) } fn item_ty_poly(&self, span: Span, name: Ident, ty: P, generics: Generics) -> P { - self.item(span, name, Vec::new(), ast::ItemTy(ty, generics)) + self.item(span, name, Vec::new(), ast::ItemKind::Ty(ty, generics)) } fn item_ty(&self, span: Span, name: Ident, ty: P) -> P { @@ -1125,7 +1125,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { id: ast::DUMMY_NODE_ID, ident: special_idents::invalid, attrs: vec![], - node: ast::ItemUse(vp), + node: ast::ItemKind::Use(vp), vis: vis, span: sp }) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 78bc4e2c735..bcd02fb8cb3 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -10,7 +10,7 @@ use ast::{Block, Crate, DeclKind, PatMac}; use ast::{Local, Ident, Mac_, Name}; -use ast::{ItemMac, MacStmtWithSemicolon, Mrk, Stmt, StmtKind}; +use ast::{MacStmtStyle, Mrk, Stmt, StmtKind, ItemKind}; use ast::TokenTree; use ast; use ext::mtwt; @@ -315,17 +315,17 @@ pub fn expand_item(it: P, fld: &mut MacroExpander) .into_iter().map(|i| i.expect_item()).collect() } -/// Expand item_underscore -fn expand_item_underscore(item: ast::Item_, fld: &mut MacroExpander) -> ast::Item_ { +/// Expand item_kind +fn expand_item_kind(item: ast::ItemKind, fld: &mut MacroExpander) -> ast::ItemKind { match item { - ast::ItemFn(decl, unsafety, constness, abi, generics, body) => { + ast::ItemKind::Fn(decl, unsafety, constness, abi, generics, body) => { let (rewritten_fn_decl, rewritten_body) = expand_and_rename_fn_decl_and_block(decl, body, fld); let expanded_generics = fold::noop_fold_generics(generics,fld); - ast::ItemFn(rewritten_fn_decl, unsafety, constness, abi, + ast::ItemKind::Fn(rewritten_fn_decl, unsafety, constness, abi, expanded_generics, rewritten_body) } - _ => noop_fold_item_underscore(item, fld) + _ => noop_fold_item_kind(item, fld) } } @@ -362,7 +362,7 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool pub fn expand_item_mac(it: P, fld: &mut MacroExpander) -> SmallVector> { let (extname, path_span, tts, span, attrs, ident) = it.and_then(|it| match it.node { - ItemMac(codemap::Spanned { node: Mac_ { path, tts, .. }, .. }) => + ItemKind::Mac(codemap::Spanned { node: Mac_ { path, tts, .. }, .. }) => (path.segments[0].identifier.name, path.span, tts, it.span, it.attrs, it.ident), _ => fld.cx.span_bug(it.span, "invalid item macro invocation") }); @@ -890,10 +890,10 @@ fn expand_annotatable(a: Annotatable, let mut new_items: SmallVector = match a { Annotatable::Item(it) => match it.node { - ast::ItemMac(..) => { + ast::ItemKind::Mac(..) => { expand_item_mac(it, fld).into_iter().map(|i| Annotatable::Item(i)).collect() } - ast::ItemMod(_) | ast::ItemForeignMod(_) => { + ast::ItemKind::Mod(_) | ast::ItemKind::ForeignMod(_) => { let valid_ident = it.ident.name != parse::token::special_idents::invalid.name; @@ -1048,7 +1048,7 @@ fn expand_item_multi_modifier(mut it: Annotatable, } } - // Expansion may have added new ItemModifiers. + // Expansion may have added new ItemKind::Modifiers. expand_item_multi_modifier(it, fld) } @@ -1194,8 +1194,8 @@ impl<'a, 'b> Folder for MacroExpander<'a, 'b> { expand_item(item, self) } - fn fold_item_underscore(&mut self, item: ast::Item_) -> ast::Item_ { - expand_item_underscore(item, self) + fn fold_item_kind(&mut self, item: ast::ItemKind) -> ast::ItemKind { + expand_item_kind(item, self) } fn fold_stmt(&mut self, stmt: P) -> SmallVector> { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 17eb43e2068..6dc0da1eb09 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -855,7 +855,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { fn visit_item(&mut self, i: &ast::Item) { match i.node { - ast::ItemExternCrate(_) => { + ast::ItemKind::ExternCrate(_) => { if attr::contains_name(&i.attrs[..], "macro_reexport") { self.gate_feature("macro_reexport", i.span, "macros reexports are experimental \ @@ -863,7 +863,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { } } - ast::ItemForeignMod(ref foreign_module) => { + ast::ItemKind::ForeignMod(ref foreign_module) => { if attr::contains_name(&i.attrs[..], "link_args") { self.gate_feature("link_args", i.span, "the `link_args` attribute is not portable \ @@ -888,7 +888,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { } } - ast::ItemFn(..) => { + ast::ItemKind::Fn(..) => { if attr::contains_name(&i.attrs[..], "plugin_registrar") { self.gate_feature("plugin_registrar", i.span, "compiler plugins are experimental and possibly buggy"); @@ -907,7 +907,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { } } - ast::ItemStruct(..) => { + ast::ItemKind::Struct(..) => { if attr::contains_name(&i.attrs[..], "simd") { self.gate_feature("simd", i.span, "SIMD types are experimental and possibly buggy"); @@ -928,14 +928,14 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { } } - ast::ItemDefaultImpl(..) => { + ast::ItemKind::DefaultImpl(..) => { self.gate_feature("optin_builtin_traits", i.span, "default trait implementations are experimental \ and possibly buggy"); } - ast::ItemImpl(_, polarity, _, _, _, _) => { + ast::ItemKind::Impl(_, polarity, _, _, _, _) => { match polarity { ast::ImplPolarity::Negative => { self.gate_feature("optin_builtin_traits", diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 8c39c48bbc7..8bb915362e8 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -71,8 +71,8 @@ pub trait Folder : Sized { noop_fold_struct_field(sf, self) } - fn fold_item_underscore(&mut self, i: Item_) -> Item_ { - noop_fold_item_underscore(i, self) + fn fold_item_kind(&mut self, i: ItemKind) -> ItemKind { + noop_fold_item_kind(i, self) } fn fold_trait_item(&mut self, i: P) -> SmallVector> { @@ -890,20 +890,20 @@ pub fn noop_fold_block(b: P, folder: &mut T) -> P { }) } -pub fn noop_fold_item_underscore(i: Item_, folder: &mut T) -> Item_ { +pub fn noop_fold_item_kind(i: ItemKind, folder: &mut T) -> ItemKind { match i { - ItemExternCrate(string) => ItemExternCrate(string), - ItemUse(view_path) => { - ItemUse(folder.fold_view_path(view_path)) + ItemKind::ExternCrate(string) => ItemKind::ExternCrate(string), + ItemKind::Use(view_path) => { + ItemKind::Use(folder.fold_view_path(view_path)) } - ItemStatic(t, m, e) => { - ItemStatic(folder.fold_ty(t), m, folder.fold_expr(e)) + ItemKind::Static(t, m, e) => { + ItemKind::Static(folder.fold_ty(t), m, folder.fold_expr(e)) } - ItemConst(t, e) => { - ItemConst(folder.fold_ty(t), folder.fold_expr(e)) + ItemKind::Const(t, e) => { + ItemKind::Const(folder.fold_ty(t), folder.fold_expr(e)) } - ItemFn(decl, unsafety, constness, abi, generics, body) => { - ItemFn( + ItemKind::Fn(decl, unsafety, constness, abi, generics, body) => { + ItemKind::Fn( folder.fold_fn_decl(decl), unsafety, constness, @@ -912,26 +912,26 @@ pub fn noop_fold_item_underscore(i: Item_, folder: &mut T) -> Item_ { folder.fold_block(body) ) } - ItemMod(m) => ItemMod(folder.fold_mod(m)), - ItemForeignMod(nm) => ItemForeignMod(folder.fold_foreign_mod(nm)), - ItemTy(t, generics) => { - ItemTy(folder.fold_ty(t), folder.fold_generics(generics)) + ItemKind::Mod(m) => ItemKind::Mod(folder.fold_mod(m)), + ItemKind::ForeignMod(nm) => ItemKind::ForeignMod(folder.fold_foreign_mod(nm)), + ItemKind::Ty(t, generics) => { + ItemKind::Ty(folder.fold_ty(t), folder.fold_generics(generics)) } - ItemEnum(enum_definition, generics) => { - ItemEnum( + ItemKind::Enum(enum_definition, generics) => { + ItemKind::Enum( ast::EnumDef { variants: enum_definition.variants.move_map(|x| folder.fold_variant(x)), }, folder.fold_generics(generics)) } - ItemStruct(struct_def, generics) => { + ItemKind::Struct(struct_def, generics) => { let struct_def = folder.fold_variant_data(struct_def); - ItemStruct(struct_def, folder.fold_generics(generics)) + ItemKind::Struct(struct_def, folder.fold_generics(generics)) } - ItemDefaultImpl(unsafety, ref trait_ref) => { - ItemDefaultImpl(unsafety, folder.fold_trait_ref((*trait_ref).clone())) + ItemKind::DefaultImpl(unsafety, ref trait_ref) => { + ItemKind::DefaultImpl(unsafety, folder.fold_trait_ref((*trait_ref).clone())) } - ItemImpl(unsafety, polarity, generics, ifce, ty, impl_items) => { + ItemKind::Impl(unsafety, polarity, generics, ifce, ty, impl_items) => { let new_impl_items = impl_items.move_flat_map(|item| { folder.fold_impl_item(item) }); @@ -941,24 +941,24 @@ pub fn noop_fold_item_underscore(i: Item_, folder: &mut T) -> Item_ { Some(folder.fold_trait_ref((*trait_ref).clone())) } }; - ItemImpl(unsafety, + ItemKind::Impl(unsafety, polarity, folder.fold_generics(generics), ifce, folder.fold_ty(ty), new_impl_items) } - ItemTrait(unsafety, generics, bounds, items) => { + ItemKind::Trait(unsafety, generics, bounds, items) => { let bounds = folder.fold_bounds(bounds); let items = items.move_flat_map(|item| { folder.fold_trait_item(item) }); - ItemTrait(unsafety, + ItemKind::Trait(unsafety, folder.fold_generics(generics), bounds, items) } - ItemMac(m) => ItemMac(folder.fold_mac(m)), + ItemKind::Mac(m) => ItemKind::Mac(folder.fold_mac(m)), } } @@ -1025,7 +1025,7 @@ pub fn noop_fold_crate(Crate {module, attrs, config, mut exported_mac id: ast::DUMMY_NODE_ID, vis: ast::Public, span: span, - node: ast::ItemMod(module), + node: ast::ItemKind::Mod(module), })).into_iter(); let (module, attrs, span) = match items.next() { @@ -1034,7 +1034,7 @@ pub fn noop_fold_crate(Crate {module, attrs, config, mut exported_mac "a crate cannot expand to more than one item"); item.and_then(|ast::Item { attrs, span, node, .. }| { match node { - ast::ItemMod(m) => (m, attrs, span), + ast::ItemKind::Mod(m) => (m, attrs, span), _ => panic!("fold converted a module to not a module"), } }) @@ -1067,10 +1067,10 @@ pub fn noop_fold_item(i: P, folder: &mut T) -> SmallVector(Item {id, ident, attrs, node, vis, span}: Item, folder: &mut T) -> Item { let id = folder.new_id(id); - let node = folder.fold_item_underscore(node); + let node = folder.fold_item_kind(node); let ident = match node { // The node may have changed, recompute the "pretty" impl name. - ItemImpl(_, _, _, ref maybe_trait, ref ty, _) => { + ItemKind::Impl(_, _, _, ref maybe_trait, ref ty, _) => { ast_util::impl_pretty_name(maybe_trait, Some(&**ty)) } _ => ident diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 2bbf1699662..a505b27e9db 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -913,7 +913,7 @@ mod tests { P(ast::Item{ident:str_to_ident("a"), attrs:Vec::new(), id: ast::DUMMY_NODE_ID, - node: ast::ItemFn(P(ast::FnDecl { + node: ast::ItemKind::Fn(P(ast::FnDecl { inputs: vec!(ast::Arg{ ty: P(ast::Ty{id: ast::DUMMY_NODE_ID, node: ast::TyKind::Path(None, ast::Path{ diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4faad48f5b7..4133c024f85 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -23,10 +23,7 @@ use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf}; use ast::{Expr, ExprKind}; use ast::{Field, FnDecl}; use ast::{ForeignItem, ForeignItemKind, FunctionRetTy}; -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::{Ident, Inherited, ImplItem, Item, ItemKind}; use ast::{Lit, LitKind, UintTy}; use ast::Local; use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces}; @@ -80,7 +77,7 @@ bitflags! { } } -type ItemInfo = (Ident, Item_, Option >); +type ItemInfo = (Ident, ItemKind, Option >); /// How to parse a path. There are four different kinds of paths, all of which /// are parsed somewhat differently. @@ -3750,7 +3747,7 @@ impl<'a> Parser<'a> { P(spanned(lo, hi, DeclKind::Item( self.mk_item( lo, hi, id /*id is good here*/, - ItemMac(spanned(lo, hi, + ItemKind::Mac(spanned(lo, hi, Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT })), Inherited, attrs)))), ast::DUMMY_NODE_ID)) @@ -4590,7 +4587,7 @@ impl<'a> Parser<'a> { } fn mk_item(&mut self, lo: BytePos, hi: BytePos, ident: Ident, - node: Item_, vis: Visibility, + node: ItemKind, vis: Visibility, attrs: Vec) -> P { P(Item { ident: ident, @@ -4612,7 +4609,7 @@ impl<'a> Parser<'a> { let decl = try!(self.parse_fn_decl(false)); generics.where_clause = try!(self.parse_where_clause()); let (inner_attrs, body) = try!(self.parse_inner_attrs_and_block()); - Ok((ident, ItemFn(decl, unsafety, constness, abi, generics, body), Some(inner_attrs))) + Ok((ident, ItemKind::Fn(decl, unsafety, constness, abi, generics, body), Some(inner_attrs))) } /// true if we are looking at `const ID`, false for things like `const fn` etc @@ -4772,7 +4769,7 @@ impl<'a> Parser<'a> { tps.where_clause = try!(self.parse_where_clause()); let meths = try!(self.parse_trait_items()); - Ok((ident, ItemTrait(unsafety, tps, bounds, meths), None)) + Ok((ident, ItemKind::Trait(unsafety, tps, bounds, meths), None)) } /// Parses items implementations variants @@ -4835,7 +4832,7 @@ impl<'a> Parser<'a> { try!(self.expect(&token::OpenDelim(token::Brace))); try!(self.expect(&token::CloseDelim(token::Brace))); Ok((ast_util::impl_pretty_name(&opt_trait, None), - ItemDefaultImpl(unsafety, opt_trait.unwrap()), None)) + ItemKind::DefaultImpl(unsafety, opt_trait.unwrap()), None)) } else { if opt_trait.is_some() { ty = try!(self.parse_ty_sum()); @@ -4851,7 +4848,7 @@ impl<'a> Parser<'a> { } Ok((ast_util::impl_pretty_name(&opt_trait, Some(&*ty)), - ItemImpl(unsafety, polarity, generics, opt_trait, ty, impl_items), + ItemKind::Impl(unsafety, polarity, generics, opt_trait, ty, impl_items), Some(attrs))) } } @@ -4936,7 +4933,7 @@ impl<'a> Parser<'a> { name, found `{}`", token_str))) }; - Ok((class_name, ItemStruct(vdata, generics), None)) + Ok((class_name, ItemKind::Struct(vdata, generics), None)) } pub fn parse_record_struct_body(&mut self, @@ -5066,8 +5063,8 @@ impl<'a> Parser<'a> { let e = try!(self.parse_expr()); try!(self.commit_expr_expecting(&*e, token::Semi)); let item = match m { - Some(m) => ItemStatic(ty, m, e), - None => ItemConst(ty, e), + Some(m) => ItemKind::Static(ty, m, e), + None => ItemKind::Const(ty, e), }; Ok((id, item, None)) } @@ -5091,7 +5088,7 @@ impl<'a> Parser<'a> { let m = try!(self.parse_mod_items(&token::CloseDelim(token::Brace), mod_inner_lo)); self.owns_directory = old_owns_directory; self.pop_mod_path(); - Ok((id, ItemMod(m), Some(attrs))) + Ok((id, ItemKind::Mod(m), Some(attrs))) } } @@ -5197,7 +5194,7 @@ impl<'a> Parser<'a> { id: ast::Ident, outer_attrs: &[ast::Attribute], id_sp: Span) - -> PResult<'a, (ast::Item_, Vec )> { + -> PResult<'a, (ast::ItemKind, Vec )> { let ModulePathSuccess { path, owns_directory } = try!(self.submod_path(id, outer_attrs, id_sp)); @@ -5212,7 +5209,7 @@ impl<'a> Parser<'a> { path: PathBuf, owns_directory: bool, name: String, - id_sp: Span) -> PResult<'a, (ast::Item_, Vec )> { + id_sp: Span) -> PResult<'a, (ast::ItemKind, Vec )> { let mut included_mod_stack = self.sess.included_mod_stack.borrow_mut(); match included_mod_stack.iter().position(|p| *p == path) { Some(i) => { @@ -5240,7 +5237,7 @@ impl<'a> Parser<'a> { let mod_attrs = try!(p0.parse_inner_attributes()); let m0 = try!(p0.parse_mod_items(&token::Eof, mod_inner_lo)); self.sess.included_mod_stack.borrow_mut().pop(); - Ok((ast::ItemMod(m0), mod_attrs)) + Ok((ast::ItemKind::Mod(m0), mod_attrs)) } /// Parse a function declaration from a foreign module @@ -5315,7 +5312,7 @@ impl<'a> Parser<'a> { Ok(self.mk_item(lo, last_span.hi, ident, - ItemExternCrate(maybe_path), + ItemKind::ExternCrate(maybe_path), visibility, attrs)) } @@ -5356,7 +5353,7 @@ impl<'a> Parser<'a> { Ok(self.mk_item(lo, last_span.hi, special_idents::invalid, - ItemForeignMod(m), + ItemKind::ForeignMod(m), visibility, attrs)) } @@ -5369,7 +5366,7 @@ impl<'a> Parser<'a> { try!(self.expect(&token::Eq)); let ty = try!(self.parse_ty_sum()); try!(self.expect(&token::Semi)); - Ok((ident, ItemTy(ty, tps), None)) + Ok((ident, ItemKind::Ty(ty, tps), None)) } /// Parse the part of an "enum" decl following the '{' @@ -5430,7 +5427,7 @@ impl<'a> Parser<'a> { try!(self.expect(&token::OpenDelim(token::Brace))); let enum_definition = try!(self.parse_enum_def(&generics)); - Ok((id, ItemEnum(enum_definition, generics), None)) + Ok((id, ItemKind::Enum(enum_definition, generics), None)) } /// Parses a string as an ABI spec on an extern type or module. Consumes @@ -5488,7 +5485,7 @@ impl<'a> Parser<'a> { if self.eat_keyword(keywords::Use) { // USE ITEM - let item_ = ItemUse(try!(self.parse_view_path())); + let item_ = ItemKind::Use(try!(self.parse_view_path())); try!(self.expect(&token::Semi)); let last_span = self.last_span; @@ -5804,7 +5801,7 @@ impl<'a> Parser<'a> { } } - let item_ = ItemMac(m); + let item_ = ItemKind::Mac(m); let last_span = self.last_span; let item = self.mk_item(lo, last_span.hi, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index becf2d2bc14..167df26f433 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1117,7 +1117,7 @@ impl<'a> State<'a> { try!(self.print_outer_attributes(&item.attrs)); try!(self.ann.pre(self, NodeItem(item))); match item.node { - ast::ItemExternCrate(ref optional_path) => { + ast::ItemKind::ExternCrate(ref optional_path) => { try!(self.head(&visibility_qualified(item.vis, "extern crate"))); if let Some(p) = *optional_path { @@ -1136,7 +1136,7 @@ impl<'a> State<'a> { try!(self.end()); // end inner head-block try!(self.end()); // end outer head-block } - ast::ItemUse(ref vp) => { + ast::ItemKind::Use(ref vp) => { try!(self.head(&visibility_qualified(item.vis, "use"))); try!(self.print_view_path(&**vp)); @@ -1144,7 +1144,7 @@ impl<'a> State<'a> { try!(self.end()); // end inner head-block try!(self.end()); // end outer head-block } - ast::ItemStatic(ref ty, m, ref expr) => { + ast::ItemKind::Static(ref ty, m, ref expr) => { try!(self.head(&visibility_qualified(item.vis, "static"))); if m == ast::MutMutable { @@ -1161,7 +1161,7 @@ impl<'a> State<'a> { try!(word(&mut self.s, ";")); try!(self.end()); // end the outer cbox } - ast::ItemConst(ref ty, ref expr) => { + ast::ItemKind::Const(ref ty, ref expr) => { try!(self.head(&visibility_qualified(item.vis, "const"))); try!(self.print_ident(item.ident)); @@ -1175,7 +1175,7 @@ impl<'a> State<'a> { try!(word(&mut self.s, ";")); try!(self.end()); // end the outer cbox } - ast::ItemFn(ref decl, unsafety, constness, abi, ref typarams, ref body) => { + ast::ItemKind::Fn(ref decl, unsafety, constness, abi, ref typarams, ref body) => { try!(self.head("")); try!(self.print_fn( decl, @@ -1190,7 +1190,7 @@ impl<'a> State<'a> { try!(word(&mut self.s, " ")); try!(self.print_block_with_attrs(&**body, &item.attrs)); } - ast::ItemMod(ref _mod) => { + ast::ItemKind::Mod(ref _mod) => { try!(self.head(&visibility_qualified(item.vis, "mod"))); try!(self.print_ident(item.ident)); @@ -1199,14 +1199,14 @@ impl<'a> State<'a> { try!(self.print_mod(_mod, &item.attrs)); try!(self.bclose(item.span)); } - ast::ItemForeignMod(ref nmod) => { + ast::ItemKind::ForeignMod(ref nmod) => { try!(self.head("extern")); try!(self.word_nbsp(&nmod.abi.to_string())); try!(self.bopen()); try!(self.print_foreign_mod(nmod, &item.attrs)); try!(self.bclose(item.span)); } - ast::ItemTy(ref ty, ref params) => { + ast::ItemKind::Ty(ref ty, ref params) => { try!(self.ibox(INDENT_UNIT)); try!(self.ibox(0)); try!(self.word_nbsp(&visibility_qualified(item.vis, "type"))); @@ -1221,7 +1221,7 @@ impl<'a> State<'a> { try!(word(&mut self.s, ";")); try!(self.end()); // end the outer ibox } - ast::ItemEnum(ref enum_definition, ref params) => { + ast::ItemKind::Enum(ref enum_definition, ref params) => { try!(self.print_enum_def( enum_definition, params, @@ -1230,12 +1230,12 @@ impl<'a> State<'a> { item.vis )); } - ast::ItemStruct(ref struct_def, ref generics) => { + ast::ItemKind::Struct(ref struct_def, ref generics) => { try!(self.head(&visibility_qualified(item.vis,"struct"))); try!(self.print_struct(&struct_def, generics, item.ident, item.span, true)); } - ast::ItemDefaultImpl(unsafety, ref trait_ref) => { + ast::ItemKind::DefaultImpl(unsafety, ref trait_ref) => { try!(self.head("")); try!(self.print_visibility(item.vis)); try!(self.print_unsafety(unsafety)); @@ -1247,7 +1247,7 @@ impl<'a> State<'a> { try!(self.bopen()); try!(self.bclose(item.span)); } - ast::ItemImpl(unsafety, + ast::ItemKind::Impl(unsafety, polarity, ref generics, ref opt_trait, @@ -1290,7 +1290,7 @@ impl<'a> State<'a> { } try!(self.bclose(item.span)); } - ast::ItemTrait(unsafety, ref generics, ref bounds, ref trait_items) => { + ast::ItemKind::Trait(unsafety, ref generics, ref bounds, ref trait_items) => { try!(self.head("")); try!(self.print_visibility(item.vis)); try!(self.print_unsafety(unsafety)); @@ -1316,7 +1316,7 @@ impl<'a> State<'a> { } try!(self.bclose(item.span)); } - ast::ItemMac(codemap::Spanned { ref node, .. }) => { + ast::ItemKind::Mac(codemap::Spanned { ref node, .. }) => { try!(self.print_visibility(item.vis)); try!(self.print_path(&node.path, false, 0)); try!(word(&mut self.s, "! ")); @@ -1596,7 +1596,7 @@ impl<'a> State<'a> { try!(self.print_associated_type(ii.ident, None, Some(ty))); } ast::ImplItemKind::Macro(codemap::Spanned { ref node, .. }) => { - // code copied from ItemMac: + // code copied from ItemKind::Mac: try!(self.print_path(&node.path, false, 0)); try!(word(&mut self.s, "! ")); try!(self.cbox(INDENT_UNIT)); diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 345adff2344..828896d422c 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -89,7 +89,7 @@ impl fold::Folder for CrateInjector { attrs: vec!( attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item( InternedString::new("macro_use")))), - node: ast::ItemExternCrate(Some(self.crate_name)), + node: ast::ItemKind::ExternCrate(Some(self.crate_name)), vis: ast::Inherited, span: DUMMY_SP })); @@ -149,7 +149,7 @@ impl fold::Folder for PreludeInjector { mod_.items.insert(0, P(ast::Item { id: ast::DUMMY_NODE_ID, ident: special_idents::invalid, - node: ast::ItemUse(vp), + node: ast::ItemKind::Use(vp), attrs: vec![ast::Attribute { span: self.span, node: ast::Attribute_ { diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 24890d2cbed..a817eb62af8 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -125,7 +125,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { let i = if is_test_fn(&self.cx, &*i) || is_bench_fn(&self.cx, &*i) { match i.node { - ast::ItemFn(_, ast::Unsafety::Unsafe, _, _, _, _) => { + ast::ItemKind::Fn(_, ast::Unsafety::Unsafe, _, _, _, _) => { let diag = self.cx.span_diagnostic; panic!(diag.span_fatal(i.span, "unsafe functions cannot be used for tests")); } @@ -159,7 +159,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { // We don't want to recurse into anything other than mods, since // mods or tests inside of functions will break things let res = match i.node { - ast::ItemMod(..) => fold::noop_fold_item(i, self), + ast::ItemKind::Mod(..) => fold::noop_fold_item(i, self), _ => SmallVector::one(i), }; if ident.name != token::special_idents::invalid.name { @@ -262,7 +262,7 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec, ident: sym.clone(), attrs: Vec::new(), id: ast::DUMMY_NODE_ID, - node: ast::ItemMod(reexport_mod), + node: ast::ItemKind::Mod(reexport_mod), vis: ast::Public, span: DUMMY_SP, }); @@ -355,7 +355,7 @@ fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool { fn has_test_signature(i: &ast::Item) -> HasTestSignature { match i.node { - ast::ItemFn(ref decl, _, _, _, ref generics, _) => { + ast::ItemKind::Fn(ref decl, _, _, _, ref generics, _) => { let no_output = match decl.output { ast::FunctionRetTy::Default(..) => true, ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyKind::Tup(vec![]) => true, @@ -391,7 +391,7 @@ fn is_bench_fn(cx: &TestCtxt, i: &ast::Item) -> bool { fn has_test_signature(i: &ast::Item) -> bool { match i.node { - ast::ItemFn(ref decl, _, _, _, ref generics, _) => { + ast::ItemKind::Fn(ref decl, _, _, _, ref generics, _) => { let input_cnt = decl.inputs.len(); let no_output = match decl.output { ast::FunctionRetTy::Default(..) => true, @@ -453,12 +453,12 @@ mod __test { fn mk_std(cx: &TestCtxt) -> P { let id_test = token::str_to_ident("test"); let (vi, vis, ident) = if cx.is_test_crate { - (ast::ItemUse( + (ast::ItemKind::Use( P(nospan(ast::ViewPathSimple(id_test, path_node(vec!(id_test)))))), ast::Public, token::special_idents::invalid) } else { - (ast::ItemExternCrate(None), ast::Inherited, id_test) + (ast::ItemKind::ExternCrate(None), ast::Inherited, id_test) }; P(ast::Item { id: ast::DUMMY_NODE_ID, @@ -496,7 +496,7 @@ fn mk_main(cx: &mut TestCtxt) -> P { // pub fn main() { ... } let main_ret_ty = ecx.ty(sp, ast::TyKind::Tup(vec![])); let main_body = ecx.block_all(sp, vec![call_test_main], None); - let main = ast::ItemFn(ecx.fn_decl(vec![], main_ret_ty), + let main = ast::ItemKind::Fn(ecx.fn_decl(vec![], main_ret_ty), ast::Unsafety::Normal, ast::Constness::NotConst, ::abi::Abi::Rust, ast::Generics::default(), main_body); @@ -527,7 +527,7 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P, Option>) { inner: DUMMY_SP, items: vec![import, mainfn, tests], }; - let item_ = ast::ItemMod(testmod); + let item_ = ast::ItemKind::Mod(testmod); let mod_ident = token::gensym_ident("__test"); let item = P(ast::Item { @@ -550,7 +550,7 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P, Option>) { id: ast::DUMMY_NODE_ID, ident: token::special_idents::invalid, attrs: vec![], - node: ast::ItemUse(P(use_path)), + node: ast::ItemKind::Use(P(use_path)), vis: ast::Inherited, span: DUMMY_SP }) diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 54b3eccefc6..4082bcbe38e 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -230,10 +230,10 @@ pub fn walk_trait_ref<'v,V>(visitor: &mut V, pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { visitor.visit_ident(item.span, item.ident); match item.node { - ItemExternCrate(opt_name) => { + ItemKind::ExternCrate(opt_name) => { walk_opt_name(visitor, item.span, opt_name) } - ItemUse(ref vp) => { + ItemKind::Use(ref vp) => { match vp.node { ViewPathSimple(ident, ref path) => { visitor.visit_ident(vp.span, ident); @@ -253,12 +253,12 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { } } } - ItemStatic(ref typ, _, ref expr) | - ItemConst(ref typ, ref expr) => { + ItemKind::Static(ref typ, _, ref expr) | + ItemKind::Const(ref typ, ref expr) => { visitor.visit_ty(typ); visitor.visit_expr(expr); } - ItemFn(ref declaration, unsafety, constness, abi, ref generics, ref body) => { + ItemKind::Fn(ref declaration, unsafety, constness, abi, ref generics, ref body) => { visitor.visit_fn(FnKind::ItemFn(item.ident, generics, unsafety, constness, abi, item.vis), declaration, @@ -266,24 +266,24 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { item.span, item.id) } - ItemMod(ref module) => { + ItemKind::Mod(ref module) => { visitor.visit_mod(module, item.span, item.id) } - ItemForeignMod(ref foreign_module) => { + ItemKind::ForeignMod(ref foreign_module) => { walk_list!(visitor, visit_foreign_item, &foreign_module.items); } - ItemTy(ref typ, ref type_parameters) => { + ItemKind::Ty(ref typ, ref type_parameters) => { visitor.visit_ty(typ); visitor.visit_generics(type_parameters) } - ItemEnum(ref enum_definition, ref type_parameters) => { + ItemKind::Enum(ref enum_definition, ref type_parameters) => { visitor.visit_generics(type_parameters); visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span) } - ItemDefaultImpl(_, ref trait_ref) => { + ItemKind::DefaultImpl(_, ref trait_ref) => { visitor.visit_trait_ref(trait_ref) } - ItemImpl(_, _, + ItemKind::Impl(_, _, ref type_parameters, ref opt_trait_reference, ref typ, @@ -293,17 +293,17 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { visitor.visit_ty(typ); walk_list!(visitor, visit_impl_item, impl_items); } - ItemStruct(ref struct_definition, ref generics) => { + ItemKind::Struct(ref struct_definition, ref generics) => { visitor.visit_generics(generics); visitor.visit_variant_data(struct_definition, item.ident, generics, item.id, item.span); } - ItemTrait(_, ref generics, ref bounds, ref methods) => { + ItemKind::Trait(_, ref generics, ref bounds, ref methods) => { visitor.visit_generics(generics); walk_list!(visitor, visit_ty_param_bound, bounds); walk_list!(visitor, visit_trait_item, methods); } - ItemMac(ref mac) => visitor.visit_mac(mac), + ItemKind::Mac(ref mac) => visitor.visit_mac(mac), } walk_list!(visitor, visit_attribute, &item.attrs); } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index e54ff637f25..51091b84672 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -391,13 +391,13 @@ impl<'a> TraitDef<'a> { match *item { Annotatable::Item(ref item) => { let newitem = match item.node { - ast::ItemStruct(ref struct_def, ref generics) => { + ast::ItemKind::Struct(ref struct_def, ref generics) => { self.expand_struct_def(cx, &struct_def, item.ident, generics) } - ast::ItemEnum(ref enum_def, ref generics) => { + ast::ItemKind::Enum(ref enum_def, ref generics) => { self.expand_enum_def(cx, enum_def, &item.attrs, @@ -637,12 +637,12 @@ impl<'a> TraitDef<'a> { self.span, ident, a, - ast::ItemImpl(unsafety, - ast::ImplPolarity::Positive, - trait_generics, - opt_trait_ref, - self_type, - methods.into_iter().chain(associated_types).collect())) + ast::ItemKind::Impl(unsafety, + ast::ImplPolarity::Positive, + trait_generics, + opt_trait_ref, + self_type, + methods.into_iter().chain(associated_types).collect())) } fn expand_struct_def(&self, diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 831a6250c9f..a5ad143f15b 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -453,7 +453,7 @@ impl<'a, 'b> Context<'a, 'b> { ast::MutImmutable); 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::ItemStatic(ty, ast::MutImmutable, slice); + let st = ast::ItemKind::Static(ty, ast::MutImmutable, slice); let name = ecx.ident_of(name); let item = ecx.item(sp, name, vec![], st); diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index fe61c80b4c3..2c68296b634 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -16,7 +16,7 @@ extern crate syntax; extern crate rustc; extern crate rustc_plugin; -use syntax::ast::{self, TokenTree, Item, MetaItem, ImplItem, TraitItem}; +use syntax::ast::{self, TokenTree, Item, MetaItem, ImplItem, TraitItem, ItemKind}; use syntax::codemap::Span; use syntax::ext::base::*; use syntax::parse::{self, token}; @@ -73,7 +73,7 @@ fn expand_into_foo_multi(cx: &mut ExtCtxt, Annotatable::ImplItem(it) => { quote_item!(cx, impl X { fn foo(&self) -> i32 { 42 } }).unwrap().and_then(|i| { match i.node { - ast::ItemImpl(_, _, _, _, _, mut items) => { + ItemKind::Impl(_, _, _, _, _, mut items) => { Annotatable::ImplItem(items.pop().expect("impl method not found")) } _ => unreachable!("impl parsed to something other than impl") @@ -83,7 +83,7 @@ fn expand_into_foo_multi(cx: &mut ExtCtxt, Annotatable::TraitItem(it) => { quote_item!(cx, trait X { fn foo(&self) -> i32 { 0 } }).unwrap().and_then(|i| { match i.node { - ast::ItemTrait(_, _, _, mut items) => { + ItemKind::Trait(_, _, _, mut items) => { Annotatable::TraitItem(items.pop().expect("trait method not found")) } _ => unreachable!("trait parsed to something other than trait") -- 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/format.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