-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow statement-generating braced macro invocations at the end of blocks #34436
Changes from 1 commit
b7da35a
a48a4f5
94479ad
060a84d
8cad251
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,12 +98,9 @@ pub trait AstBuilder { | |
fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> ast::Stmt; | ||
|
||
// blocks | ||
fn block(&self, span: Span, stmts: Vec<ast::Stmt>, | ||
expr: Option<P<ast::Expr>>) -> P<ast::Block>; | ||
fn block(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Block>; | ||
fn block_expr(&self, expr: P<ast::Expr>) -> P<ast::Block>; | ||
fn block_all(&self, span: Span, | ||
stmts: Vec<ast::Stmt>, | ||
expr: Option<P<ast::Expr>>) -> P<ast::Block>; | ||
fn block_all(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Block>; | ||
|
||
// expressions | ||
fn expr(&self, span: Span, node: ast::ExprKind) -> P<ast::Expr>; | ||
|
@@ -508,7 +505,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { | |
} | ||
|
||
fn stmt_expr(&self, expr: P<ast::Expr>) -> ast::Stmt { | ||
respan(expr.span, ast::StmtKind::Semi(expr, ast::DUMMY_NODE_ID)) | ||
respan(expr.span, ast::StmtKind::Expr(expr, ast::DUMMY_NODE_ID)) | ||
} | ||
|
||
fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, | ||
|
@@ -556,9 +553,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { | |
P(respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))) | ||
} | ||
|
||
fn block(&self, span: Span, stmts: Vec<ast::Stmt>, | ||
expr: Option<P<Expr>>) -> P<ast::Block> { | ||
self.block_all(span, stmts, expr) | ||
fn block(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Block> { | ||
self.block_all(span, stmts) | ||
} | ||
|
||
fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> ast::Stmt { | ||
|
@@ -567,19 +563,18 @@ impl<'a> AstBuilder for ExtCtxt<'a> { | |
} | ||
|
||
fn block_expr(&self, expr: P<ast::Expr>) -> P<ast::Block> { | ||
self.block_all(expr.span, Vec::new(), Some(expr)) | ||
} | ||
fn block_all(&self, | ||
span: Span, | ||
stmts: Vec<ast::Stmt>, | ||
expr: Option<P<ast::Expr>>) -> P<ast::Block> { | ||
P(ast::Block { | ||
stmts: stmts, | ||
expr: expr, | ||
id: ast::DUMMY_NODE_ID, | ||
rules: BlockCheckMode::Default, | ||
span: span, | ||
}) | ||
self.block_all(expr.span, vec![Spanned { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't land directly -- once it's approved I'll rebase over #34316 in the breaking batch, so this will become |
||
span: expr.span, | ||
node: ast::StmtKind::Expr(expr, ast::DUMMY_NODE_ID), | ||
}]) | ||
} | ||
fn block_all(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Block> { | ||
P(ast::Block { | ||
stmts: stmts, | ||
id: ast::DUMMY_NODE_ID, | ||
rules: BlockCheckMode::Default, | ||
span: span, | ||
}) | ||
} | ||
|
||
fn expr(&self, span: Span, node: ast::ExprKind) -> P<ast::Expr> { | ||
|
@@ -948,14 +943,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { | |
ids: Vec<ast::Ident>, | ||
stmts: Vec<ast::Stmt>) | ||
-> P<ast::Expr> { | ||
self.lambda(span, ids, self.block(span, stmts, None)) | ||
self.lambda(span, ids, self.block(span, stmts)) | ||
} | ||
fn lambda_stmts_0(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Expr> { | ||
self.lambda0(span, self.block(span, stmts, None)) | ||
self.lambda0(span, self.block(span, stmts)) | ||
} | ||
fn lambda_stmts_1(&self, span: Span, stmts: Vec<ast::Stmt>, | ||
ident: ast::Ident) -> P<ast::Expr> { | ||
self.lambda1(span, self.block(span, stmts, None), ident) | ||
self.lambda1(span, self.block(span, stmts), ident) | ||
} | ||
|
||
fn arg(&self, span: Span, ident: ast::Ident, ty: P<ast::Ty>) -> ast::Arg { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these two functions both exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason -- removed
block_all
.