Simplifications to statement macro handling.

SmallVector::pop no longer worries about converting a Many repr downward
to One or Zero.

expand_stmt makes use of `if let` for style purposes.
This commit is contained in:
Christopher Chambers
2015-04-10 23:06:34 -05:00
parent fae29e497c
commit 22eb3193a6
2 changed files with 12 additions and 37 deletions

View File

@@ -772,20 +772,17 @@ fn expand_stmt(stmt: P<Stmt>, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> {
// If this is a macro invocation with a semicolon, then apply that
// semicolon to the final statement produced by expansion.
if style == MacStmtWithSemicolon {
match fully_expanded.pop() {
Some(stmt) => {
let new_stmt = stmt.map(|Spanned {node, span}| {
Spanned {
node: match node {
StmtExpr(e, stmt_id) => StmtSemi(e, stmt_id),
_ => node /* might already have a semi */
},
span: span
}
});
fully_expanded.push(new_stmt);
}
None => (),
if let Some(stmt) = fully_expanded.pop() {
let new_stmt = stmt.map(|Spanned {node, span}| {
Spanned {
node: match node {
StmtExpr(e, stmt_id) => StmtSemi(e, stmt_id),
_ => node /* might already have a semi */
},
span: span
}
});
fully_expanded.push(new_stmt);
}
}