Skip to content

Commit 1c28229

Browse files
committed
Simplify Parser::parse_expr_dot_or_call.
The call in `parse_expr_prefix` for the `++` case passes an empty `attrs`, but it doesn' need to. This commit changes it to pass the parsed `attrs`, which doesn't change any behaviour. As a result, `parse_expr_dot_or_call` no longer needs an `Option` argument, and no longer needs to call `parse_or_use_outer_attributes`.
1 parent 1fbb3ec commit 1c28229

File tree

1 file changed

+3
-4
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+3
-4
lines changed

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl<'a> Parser<'a> {
629629
this.bump();
630630
this.bump();
631631

632-
let operand_expr = this.parse_expr_dot_or_call(Default::default())?;
632+
let operand_expr = this.parse_expr_dot_or_call(attrs)?;
633633
this.recover_from_prefix_increment(operand_expr, pre_span, starts_stmt)
634634
}
635635
token::Ident(..) if this.token.is_keyword(kw::Box) => {
@@ -638,7 +638,7 @@ impl<'a> Parser<'a> {
638638
token::Ident(..) if this.may_recover() && this.is_mistaken_not_ident_negation() => {
639639
make_it!(this, attrs, |this, _| this.recover_not_expr(lo))
640640
}
641-
_ => return this.parse_expr_dot_or_call(Some(attrs)),
641+
_ => return this.parse_expr_dot_or_call(attrs),
642642
}
643643
}
644644

@@ -927,8 +927,7 @@ impl<'a> Parser<'a> {
927927
}
928928

929929
/// Parses `a.b` or `a(13)` or `a[4]` or just `a`.
930-
fn parse_expr_dot_or_call(&mut self, attrs: Option<AttrWrapper>) -> PResult<'a, P<Expr>> {
931-
let attrs = self.parse_or_use_outer_attributes(attrs)?;
930+
fn parse_expr_dot_or_call(&mut self, attrs: AttrWrapper) -> PResult<'a, P<Expr>> {
932931
self.collect_tokens_for_expr(attrs, |this, attrs| {
933932
let base = this.parse_expr_bottom()?;
934933
let span = this.interpolated_or_expr_span(&base);

0 commit comments

Comments
 (0)