Skip to content

Commit a483026

Browse files
committed
handle only postfix decrement
1 parent 0883973 commit a483026

File tree

3 files changed

+4
-82
lines changed

3 files changed

+4
-82
lines changed

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,16 +1354,6 @@ impl<'a> Parser<'a> {
13541354
};
13551355
self.recover_from_inc_dec(operand_expr, kind, op_span)
13561356
}
1357-
pub(super) fn recover_from_prefix_decrement(
1358-
&mut self,
1359-
operand_expr: P<Expr>,
1360-
op_span: Span,
1361-
start_stmt: bool,
1362-
) -> PResult<'a, P<Expr>> {
1363-
let standalone = if start_stmt { IsStandalone::Standalone } else { IsStandalone::Subexpr };
1364-
let kind = IncDecRecovery { standalone, op: IncOrDec::Dec, fixity: UnaryFixity::Pre };
1365-
self.recover_from_inc_dec(operand_expr, kind, op_span)
1366-
}
13671357

13681358
pub(super) fn recover_from_postfix_decrement(
13691359
&mut self,

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,10 @@ impl<'a> Parser<'a> {
561561
token::Not => make_it!(this, attrs, |this, _| this.parse_unary_expr(lo, UnOp::Not)),
562562
// `~expr`
563563
token::Tilde => make_it!(this, attrs, |this, _| this.recover_tilde_expr(lo)),
564-
// // `-expr`
565-
// token::BinOp(token::Minus) => {
566-
// make_it!(this, attrs, |this, _| this.parse_unary_expr(lo, UnOp::Neg))
567-
// }
564+
// `-expr`
565+
token::BinOp(token::Minus) => {
566+
make_it!(this, attrs, |this, _| this.parse_unary_expr(lo, UnOp::Neg))
567+
}
568568
// `*expr`
569569
token::BinOp(token::Star) => {
570570
make_it!(this, attrs, |this, _| this.parse_unary_expr(lo, UnOp::Deref))
@@ -606,27 +606,7 @@ impl<'a> Parser<'a> {
606606
let operand_expr = this.parse_dot_or_call_expr(Default::default())?;
607607
this.recover_from_prefix_increment(operand_expr, pre_span, starts_stmt)
608608
}
609-
// Recover from `--x`:
610-
token::BinOp(token::Minus)
611-
if this.look_ahead(1, |t| *t == token::BinOp(token::Minus))
612-
&& !this.token.can_begin_expr() =>
613-
{
614-
let starts_stmt = this.prev_token == token::Semi
615-
|| this.prev_token == token::CloseDelim(Delimiter::Brace);
616-
let pre_span = this.token.span.to(this.look_ahead(1, |t| t.span));
617-
// if !this.token.can_begin_expr() {
618-
// Eat both `-`s.
619-
this.bump();
620-
this.bump();
621-
let operand_expr = this.parse_dot_or_call_expr(Default::default())?;
622-
this.recover_from_prefix_decrement(operand_expr, pre_span, starts_stmt)
623609

624-
// }
625-
}
626-
// `-expr`
627-
token::BinOp(token::Minus) => {
628-
make_it!(this, attrs, |this, _| this.parse_unary_expr(lo, UnOp::Neg))
629-
}
630610
token::Ident(..) if this.token.is_keyword(kw::Box) => {
631611
make_it!(this, attrs, |this, _| this.parse_box_expr(lo))
632612
}

tests/ui/parser/issue-108495-dec-pass.rs

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)