Skip to content

Commit 802779f

Browse files
committed
Move parse_or_use_outer_attributes out of parse_expr_prefix.
This eliminates one `Option<AttrWrapper>` argument.
1 parent ead0a45 commit 802779f

File tree

1 file changed

+8
-5
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+8
-5
lines changed

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ impl<'a> Parser<'a> {
155155
if self.token.is_range_separator() {
156156
return self.parse_expr_prefix_range(attrs);
157157
} else {
158+
let attrs = self.parse_or_use_outer_attributes(attrs)?;
158159
self.parse_expr_prefix(attrs)?
159160
}
160161
}
@@ -541,8 +542,7 @@ impl<'a> Parser<'a> {
541542
}
542543

543544
/// Parses a prefix-unary-operator expr.
544-
fn parse_expr_prefix(&mut self, attrs: Option<AttrWrapper>) -> PResult<'a, P<Expr>> {
545-
let attrs = self.parse_or_use_outer_attributes(attrs)?;
545+
fn parse_expr_prefix(&mut self, attrs: AttrWrapper) -> PResult<'a, P<Expr>> {
546546
let lo = self.token.span;
547547

548548
macro_rules! make_it {
@@ -591,7 +591,8 @@ impl<'a> Parser<'a> {
591591
this.dcx().emit_err(err);
592592

593593
this.bump();
594-
this.parse_expr_prefix(None)
594+
let attrs = this.parse_outer_attributes()?;
595+
this.parse_expr_prefix(attrs)
595596
}
596597
// Recover from `++x`:
597598
token::BinOp(token::Plus)
@@ -619,7 +620,8 @@ impl<'a> Parser<'a> {
619620

620621
fn parse_expr_prefix_common(&mut self, lo: Span) -> PResult<'a, (Span, P<Expr>)> {
621622
self.bump();
622-
let expr = self.parse_expr_prefix(None)?;
623+
let attrs = self.parse_outer_attributes()?;
624+
let expr = self.parse_expr_prefix(attrs)?;
623625
let span = self.interpolated_or_expr_span(&expr);
624626
Ok((lo.to(span), expr))
625627
}
@@ -872,7 +874,8 @@ impl<'a> Parser<'a> {
872874
let expr = if self.token.is_range_separator() {
873875
self.parse_expr_prefix_range(None)
874876
} else {
875-
self.parse_expr_prefix(None)
877+
let attrs = self.parse_outer_attributes()?;
878+
self.parse_expr_prefix(attrs)
876879
}?;
877880
let hi = self.interpolated_or_expr_span(&expr);
878881
let span = lo.to(hi);

0 commit comments

Comments
 (0)