Remove field expr
of ast::Block
This commit is contained in:
parent
4960f2f907
commit
b7da35a5aa
19 changed files with 87 additions and 119 deletions
|
@ -3217,9 +3217,11 @@ impl<'a> Parser<'a> {
|
|||
let body_expr = self.parse_expr()?;
|
||||
P(ast::Block {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
stmts: vec![],
|
||||
span: body_expr.span,
|
||||
expr: Some(body_expr),
|
||||
stmts: vec![Spanned {
|
||||
span: body_expr.span,
|
||||
node: StmtKind::Expr(body_expr, ast::DUMMY_NODE_ID),
|
||||
}],
|
||||
rules: BlockCheckMode::Default,
|
||||
})
|
||||
}
|
||||
|
@ -4082,7 +4084,6 @@ impl<'a> Parser<'a> {
|
|||
/// Precondition: already parsed the '{'.
|
||||
fn parse_block_tail(&mut self, lo: BytePos, s: BlockCheckMode) -> PResult<'a, P<Block>> {
|
||||
let mut stmts = vec![];
|
||||
let mut expr = None;
|
||||
|
||||
while !self.eat(&token::CloseDelim(token::Brace)) {
|
||||
let Spanned {node, span} = if let Some(s) = self.parse_stmt_() {
|
||||
|
@ -4095,11 +4096,10 @@ impl<'a> Parser<'a> {
|
|||
};
|
||||
match node {
|
||||
StmtKind::Expr(e, _) => {
|
||||
self.handle_expression_like_statement(e, span, &mut stmts, &mut expr)?;
|
||||
self.handle_expression_like_statement(e, span, &mut stmts)?;
|
||||
}
|
||||
StmtKind::Mac(mac, MacStmtStyle::NoBraces, attrs) => {
|
||||
// statement macro without braces; might be an
|
||||
// expr depending on whether a semicolon follows
|
||||
// statement macro without braces
|
||||
match self.token {
|
||||
token::Semi => {
|
||||
stmts.push(Spanned {
|
||||
|
@ -4115,11 +4115,7 @@ impl<'a> Parser<'a> {
|
|||
let lo = e.span.lo;
|
||||
let e = self.parse_dot_or_call_expr_with(e, lo, attrs)?;
|
||||
let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?;
|
||||
self.handle_expression_like_statement(
|
||||
e,
|
||||
span,
|
||||
&mut stmts,
|
||||
&mut expr)?;
|
||||
self.handle_expression_like_statement(e, span, &mut stmts)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4133,13 +4129,6 @@ impl<'a> Parser<'a> {
|
|||
});
|
||||
self.bump();
|
||||
}
|
||||
token::CloseDelim(token::Brace) => {
|
||||
// if a block ends in `m!(arg)` without
|
||||
// a `;`, it must be an expr
|
||||
expr = Some(self.mk_mac_expr(span.lo, span.hi,
|
||||
m.and_then(|x| x.node),
|
||||
attrs));
|
||||
}
|
||||
_ => {
|
||||
stmts.push(Spanned {
|
||||
node: StmtKind::Mac(m, style, attrs),
|
||||
|
@ -4165,7 +4154,6 @@ impl<'a> Parser<'a> {
|
|||
|
||||
Ok(P(ast::Block {
|
||||
stmts: stmts,
|
||||
expr: expr,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
rules: s,
|
||||
span: mk_sp(lo, self.last_span.hi),
|
||||
|
@ -4175,8 +4163,7 @@ impl<'a> Parser<'a> {
|
|||
fn handle_expression_like_statement(&mut self,
|
||||
e: P<Expr>,
|
||||
span: Span,
|
||||
stmts: &mut Vec<Stmt>,
|
||||
last_block_expr: &mut Option<P<Expr>>)
|
||||
stmts: &mut Vec<Stmt>)
|
||||
-> PResult<'a, ()> {
|
||||
// expression without semicolon
|
||||
if classify::expr_requires_semi_to_be_stmt(&e) {
|
||||
|
@ -4202,7 +4189,6 @@ impl<'a> Parser<'a> {
|
|||
span: span_with_semi,
|
||||
});
|
||||
}
|
||||
token::CloseDelim(token::Brace) => *last_block_expr = Some(e),
|
||||
_ => {
|
||||
stmts.push(Spanned {
|
||||
node: StmtKind::Expr(e, ast::DUMMY_NODE_ID),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue