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

@ -282,6 +282,18 @@ impl<'a> Parser<'a> {
continue;
}
if self.prev_token == token::BinOp(token::Minus)
&& self.token == token::BinOp(token::Minus)
&& self.prev_token.span.between(self.token.span).is_empty()
&& !self.look_ahead(1, |tok| tok.can_begin_expr())
{
let op_span = self.prev_token.span.to(self.token.span);
// Eat the second `-`
self.bump();
lhs = self.recover_from_postfix_decrement(lhs, op_span, starts_stmt)?;
continue;
}
let op = op.node;
// Special cases:
if op == AssocOp::As {