1
Fork 0

Rollup merge of #108496 - nx2k3:issue-108495-dec, r=WaffleLapkin

fix #108495, postfix decrement and prefix decrement has no warning

Fixes #108495
This commit is contained in:
Matthias Krüger 2023-03-01 01:21:56 +01:00 committed by GitHub
commit 1c3cc8bba5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 134 additions and 2 deletions

View file

@ -165,8 +165,6 @@ enum IsStandalone {
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
enum IncOrDec {
Inc,
// FIXME: `i--` recovery isn't implemented yet
#[allow(dead_code)]
Dec,
}
@ -1357,6 +1355,20 @@ impl<'a> Parser<'a> {
self.recover_from_inc_dec(operand_expr, kind, op_span)
}
pub(super) fn recover_from_postfix_decrement(
&mut self,
operand_expr: P<Expr>,
op_span: Span,
start_stmt: bool,
) -> PResult<'a, P<Expr>> {
let kind = IncDecRecovery {
standalone: if start_stmt { IsStandalone::Standalone } else { IsStandalone::Subexpr },
op: IncOrDec::Dec,
fixity: UnaryFixity::Post,
};
self.recover_from_inc_dec(operand_expr, kind, op_span)
}
fn recover_from_inc_dec(
&mut self,
base: P<Expr>,