Skip to content

Commit d247489

Browse files
committed
Reorder Parser::parse_expr_dot_or_call_with arguments.
Put `attrs` before `e0` because that matches the order in the source code, where outer attributes appear before expressions.
1 parent 48cdfc3 commit d247489

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,15 +885,15 @@ impl<'a> Parser<'a> {
885885
self.collect_tokens_for_expr(attrs, |this, attrs| {
886886
let base = this.parse_expr_bottom()?;
887887
let span = this.interpolated_or_expr_span(&base);
888-
this.parse_expr_dot_or_call_with(base, span, attrs)
888+
this.parse_expr_dot_or_call_with(attrs, base, span)
889889
})
890890
}
891891

892892
pub(super) fn parse_expr_dot_or_call_with(
893893
&mut self,
894+
mut attrs: ast::AttrVec,
894895
e0: P<Expr>,
895896
lo: Span,
896-
mut attrs: ast::AttrVec,
897897
) -> PResult<'a, P<Expr>> {
898898
// Stitch the list of outer attributes onto the return value.
899899
// A little bit ugly, but the best way given the current code

compiler/rustc_parse/src/parser/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ impl<'a> Parser<'a> {
388388
// Parse `?`, `.f`, `(arg0, arg1, ...)` or `[expr]` until they've all been eaten.
389389
if let Ok(expr) = snapshot
390390
.parse_expr_dot_or_call_with(
391+
AttrVec::new(),
391392
self.mk_expr(pat_span, ExprKind::Dummy), // equivalent to transforming the parsed pattern into an `Expr`
392393
pat_span,
393-
AttrVec::new(),
394394
)
395395
.map_err(|err| err.cancel())
396396
{

compiler/rustc_parse/src/parser/stmt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl<'a> Parser<'a> {
164164
};
165165

166166
let expr = this.with_res(Restrictions::STMT_EXPR, |this| {
167-
this.parse_expr_dot_or_call_with(expr, lo, attrs)
167+
this.parse_expr_dot_or_call_with(attrs, expr, lo)
168168
})?;
169169
// `DUMMY_SP` will get overwritten later in this function
170170
Ok((this.mk_stmt(rustc_span::DUMMY_SP, StmtKind::Expr(expr)), TrailingToken::None))
@@ -206,7 +206,7 @@ impl<'a> Parser<'a> {
206206
// Since none of the above applied, this is an expression statement macro.
207207
let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac));
208208
let e = self.maybe_recover_from_bad_qpath(e)?;
209-
let e = self.parse_expr_dot_or_call_with(e, lo, attrs)?;
209+
let e = self.parse_expr_dot_or_call_with(attrs, e, lo)?;
210210
let e = self
211211
.parse_expr_assoc_with(0, LhsExpr::Parsed { expr: e, starts_statement: false })?;
212212
StmtKind::Expr(e)

0 commit comments

Comments
 (0)