diff options
| author | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-02-08 17:23:13 +0100 |
|---|---|---|
| committer | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-02-11 12:34:48 +0100 |
| commit | 8290c950a8b4cdc70038736abcf29f41dede6e0c (patch) | |
| tree | 7b027cdb71d631399b70d968e6e88d9028195916 /src/libsyntax/parse | |
| parent | 498a2e416e693fa22042d3ae81c5c969fc87fe5c (diff) | |
| download | rust-8290c950a8b4cdc70038736abcf29f41dede6e0c.tar.gz rust-8290c950a8b4cdc70038736abcf29f41dede6e0c.zip | |
[breaking-change] don't pub export ast::Stmt_ variants
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/classify.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 35 |
3 files changed, 23 insertions, 26 deletions
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 })); } |
