[breaking-change] don't pub export ast::Stmt_ variants
This commit is contained in:
parent
498a2e416e
commit
8290c950a8
|
@ -1534,25 +1534,25 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
|||
|
||||
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"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<Stmt_>;
|
||||
pub type Stmt = Spanned<StmtKind>;
|
||||
|
||||
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<Decl>, NodeId),
|
||||
Decl(P<Decl>, NodeId),
|
||||
|
||||
/// Expr without trailing semi-colon (must have unit type):
|
||||
StmtExpr(P<Expr>, NodeId),
|
||||
Expr(P<Expr>, NodeId),
|
||||
|
||||
/// Expr with trailing semi-colon (may have any type):
|
||||
StmtSemi(P<Expr>, NodeId),
|
||||
Semi(P<Expr>, NodeId),
|
||||
|
||||
StmtMac(P<Mac>, MacStmtStyle, ThinAttributes),
|
||||
Mac(P<Mac>, MacStmtStyle, ThinAttributes),
|
||||
}
|
||||
|
||||
impl Stmt_ {
|
||||
impl StmtKind {
|
||||
pub fn id(&self) -> Option<NodeId> {
|
||||
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) => &[],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Stmt> {
|
|||
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)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<DummyResult>) -> Option<SmallVector<P<ast::Stmt>>> {
|
||||
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)))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -506,7 +506,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
}
|
||||
|
||||
fn stmt_expr(&self, expr: P<ast::Expr>) -> P<ast::Stmt> {
|
||||
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<P<ast::Stmt>>,
|
||||
|
@ -559,7 +559,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
|
||||
fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> P<ast::Stmt> {
|
||||
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<ast::Expr>) -> P<ast::Block> {
|
||||
|
|
|
@ -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<ast::Item>,
|
|||
fn expand_stmt(stmt: P<Stmt>, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> {
|
||||
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<Stmt>, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> {
|
|||
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<P<Stmt>> {
|
||||
// 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
|
||||
}),
|
||||
|
|
|
@ -1347,39 +1347,39 @@ pub fn noop_fold_stmt<T: Folder>(Spanned {node, span}: Stmt, folder: &mut T)
|
|||
-> SmallVector<P<Stmt>> {
|
||||
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
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)))
|
||||
}
|
||||
|
|
|
@ -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))))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue