Simplify attribute handling in parse_bottom_expr
.
`Parser::parse_bottom_expr` currently constructs an empty `attrs` and then passes it to a large number of other functions. This makes the code harder to read than it should be, because it's not clear that many `attrs` arguments are always empty. This commit removes `attrs` and the passing, simplifying a lot of functions. The commit also renames `Parser::mk_expr` (which takes an `attrs` argument) as `mk_expr_with_attrs`, and introduces a new `mk_expr` which creates an expression with no attributes, which is the more common case.
This commit is contained in:
parent
1e8497351d
commit
2ef0479568
6 changed files with 159 additions and 208 deletions
|
@ -1116,10 +1116,14 @@ impl<'a> Parser<'a> {
|
|||
let (attrs, blk) = self.parse_inner_attrs_and_block()?;
|
||||
let anon_const = AnonConst {
|
||||
id: DUMMY_NODE_ID,
|
||||
value: self.mk_expr(blk.span, ExprKind::Block(blk, None), AttrVec::new()),
|
||||
value: self.mk_expr(blk.span, ExprKind::Block(blk, None)),
|
||||
};
|
||||
let blk_span = anon_const.value.span;
|
||||
Ok(self.mk_expr(span.to(blk_span), ExprKind::ConstBlock(anon_const), AttrVec::from(attrs)))
|
||||
Ok(self.mk_expr_with_attrs(
|
||||
span.to(blk_span),
|
||||
ExprKind::ConstBlock(anon_const),
|
||||
AttrVec::from(attrs),
|
||||
))
|
||||
}
|
||||
|
||||
/// Parses mutability (`mut` or nothing).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue