[breaking-change] don't glob export ast::MacStmtStyle
This commit is contained in:
parent
798974cae5
commit
e797e1961d
4 changed files with 13 additions and 14 deletions
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
// The Rust abstract syntax tree.
|
// The Rust abstract syntax tree.
|
||||||
|
|
||||||
pub use self::MacStmtStyle::*;
|
|
||||||
pub use self::MetaItem_::*;
|
pub use self::MetaItem_::*;
|
||||||
pub use self::Mutability::*;
|
pub use self::Mutability::*;
|
||||||
pub use self::Pat_::*;
|
pub use self::Pat_::*;
|
||||||
|
@ -782,13 +781,13 @@ impl StmtKind {
|
||||||
pub enum MacStmtStyle {
|
pub enum MacStmtStyle {
|
||||||
/// The macro statement had a trailing semicolon, e.g. `foo! { ... };`
|
/// The macro statement had a trailing semicolon, e.g. `foo! { ... };`
|
||||||
/// `foo!(...);`, `foo![...];`
|
/// `foo!(...);`, `foo![...];`
|
||||||
MacStmtWithSemicolon,
|
Semicolon,
|
||||||
/// The macro statement had braces; e.g. foo! { ... }
|
/// The macro statement had braces; e.g. foo! { ... }
|
||||||
MacStmtWithBraces,
|
Braces,
|
||||||
/// The macro statement had parentheses or brackets and no semicolon; e.g.
|
/// The macro statement had parentheses or brackets and no semicolon; e.g.
|
||||||
/// `foo!(...)`. All of these will end up being converted into macro
|
/// `foo!(...)`. All of these will end up being converted into macro
|
||||||
/// expressions.
|
/// expressions.
|
||||||
MacStmtWithoutBraces,
|
NoBraces,
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME (pending discussion of #1697, #2178...): local should really be
|
// FIXME (pending discussion of #1697, #2178...): local should really be
|
||||||
|
|
|
@ -533,7 +533,7 @@ fn expand_stmt(stmt: P<Stmt>, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> {
|
||||||
|
|
||||||
// If this is a macro invocation with a semicolon, then apply that
|
// If this is a macro invocation with a semicolon, then apply that
|
||||||
// semicolon to the final statement produced by expansion.
|
// semicolon to the final statement produced by expansion.
|
||||||
if style == MacStmtWithSemicolon {
|
if style == MacStmtStyle::Semicolon {
|
||||||
if let Some(stmt) = fully_expanded.pop() {
|
if let Some(stmt) = fully_expanded.pop() {
|
||||||
let new_stmt = stmt.map(|Spanned {node, span}| {
|
let new_stmt = stmt.map(|Spanned {node, span}| {
|
||||||
Spanned {
|
Spanned {
|
||||||
|
|
|
@ -26,7 +26,7 @@ use ast::{ForeignItem, ForeignItemKind, FunctionRetTy};
|
||||||
use ast::{Ident, Inherited, ImplItem, Item, ItemKind};
|
use ast::{Ident, Inherited, ImplItem, Item, ItemKind};
|
||||||
use ast::{Lit, LitKind, UintTy};
|
use ast::{Lit, LitKind, UintTy};
|
||||||
use ast::Local;
|
use ast::Local;
|
||||||
use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces};
|
use ast::MacStmtStyle;
|
||||||
use ast::{MutImmutable, MutMutable, Mac_};
|
use ast::{MutImmutable, MutMutable, Mac_};
|
||||||
use ast::{MutTy, Mutability};
|
use ast::{MutTy, Mutability};
|
||||||
use ast::NamedField;
|
use ast::NamedField;
|
||||||
|
@ -3721,9 +3721,9 @@ impl<'a> Parser<'a> {
|
||||||
let hi = self.last_span.hi;
|
let hi = self.last_span.hi;
|
||||||
|
|
||||||
let style = if delim == token::Brace {
|
let style = if delim == token::Brace {
|
||||||
MacStmtWithBraces
|
MacStmtStyle::Braces
|
||||||
} else {
|
} else {
|
||||||
MacStmtWithoutBraces
|
MacStmtStyle::NoBraces
|
||||||
};
|
};
|
||||||
|
|
||||||
if id.name == token::special_idents::invalid.name {
|
if id.name == token::special_idents::invalid.name {
|
||||||
|
@ -3734,7 +3734,7 @@ impl<'a> Parser<'a> {
|
||||||
// if it has a special ident, it's definitely an item
|
// if it has a special ident, it's definitely an item
|
||||||
//
|
//
|
||||||
// Require a semicolon or braces.
|
// Require a semicolon or braces.
|
||||||
if style != MacStmtWithBraces {
|
if style != MacStmtStyle::Braces {
|
||||||
if !self.eat(&token::Semi) {
|
if !self.eat(&token::Semi) {
|
||||||
let last_span = self.last_span;
|
let last_span = self.last_span;
|
||||||
self.span_err(last_span,
|
self.span_err(last_span,
|
||||||
|
@ -3841,13 +3841,13 @@ impl<'a> Parser<'a> {
|
||||||
StmtKind::Expr(e, _) => {
|
StmtKind::Expr(e, _) => {
|
||||||
try!(self.handle_expression_like_statement(e, span, &mut stmts, &mut expr));
|
try!(self.handle_expression_like_statement(e, span, &mut stmts, &mut expr));
|
||||||
}
|
}
|
||||||
StmtKind::Mac(mac, MacStmtWithoutBraces, attrs) => {
|
StmtKind::Mac(mac, MacStmtStyle::NoBraces, attrs) => {
|
||||||
// statement macro without braces; might be an
|
// statement macro without braces; might be an
|
||||||
// expr depending on whether a semicolon follows
|
// expr depending on whether a semicolon follows
|
||||||
match self.token {
|
match self.token {
|
||||||
token::Semi => {
|
token::Semi => {
|
||||||
stmts.push(P(Spanned {
|
stmts.push(P(Spanned {
|
||||||
node: StmtKind::Mac(mac, MacStmtWithSemicolon, attrs),
|
node: StmtKind::Mac(mac, MacStmtStyle::Semicolon, attrs),
|
||||||
span: mk_sp(span.lo, self.span.hi),
|
span: mk_sp(span.lo, self.span.hi),
|
||||||
}));
|
}));
|
||||||
self.bump();
|
self.bump();
|
||||||
|
@ -3872,7 +3872,7 @@ impl<'a> Parser<'a> {
|
||||||
match self.token {
|
match self.token {
|
||||||
token::Semi => {
|
token::Semi => {
|
||||||
stmts.push(P(Spanned {
|
stmts.push(P(Spanned {
|
||||||
node: StmtKind::Mac(m, MacStmtWithSemicolon, attrs),
|
node: StmtKind::Mac(m, MacStmtStyle::Semicolon, attrs),
|
||||||
span: mk_sp(span.lo, self.span.hi),
|
span: mk_sp(span.lo, self.span.hi),
|
||||||
}));
|
}));
|
||||||
self.bump();
|
self.bump();
|
||||||
|
|
|
@ -1629,12 +1629,12 @@ impl<'a> State<'a> {
|
||||||
try!(self.space_if_not_bol());
|
try!(self.space_if_not_bol());
|
||||||
try!(self.print_outer_attributes(attrs.as_attr_slice()));
|
try!(self.print_outer_attributes(attrs.as_attr_slice()));
|
||||||
let delim = match style {
|
let delim = match style {
|
||||||
ast::MacStmtWithBraces => token::Brace,
|
ast::MacStmtStyle::Braces => token::Brace,
|
||||||
_ => token::Paren
|
_ => token::Paren
|
||||||
};
|
};
|
||||||
try!(self.print_mac(&**mac, delim));
|
try!(self.print_mac(&**mac, delim));
|
||||||
match style {
|
match style {
|
||||||
ast::MacStmtWithBraces => {}
|
ast::MacStmtStyle::Braces => {}
|
||||||
_ => try!(word(&mut self.s, ";")),
|
_ => try!(word(&mut self.s, ";")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue