From 031206bc1d16edcc963a1d0987ad37448a4cc019 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Tue, 28 Feb 2023 19:28:14 +0400 Subject: [PATCH] micro fmt changes --- .../rustc_parse/src/parser/diagnostics.rs | 1 + compiler/rustc_parse/src/parser/expr.rs | 2 +- tests/ui/parser/issue-108495-dec.rs | 20 +++++++++---------- tests/ui/parser/issue-108495-dec.stderr | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 779fd90627b..78e4f3581b9 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1368,6 +1368,7 @@ impl<'a> Parser<'a> { }; self.recover_from_inc_dec(operand_expr, kind, op_span) } + fn recover_from_inc_dec( &mut self, base: P, diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index ec50388cb46..828c268b588 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -281,6 +281,7 @@ impl<'a> Parser<'a> { lhs = self.recover_from_postfix_increment(lhs, op_span, starts_stmt)?; 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() @@ -606,7 +607,6 @@ impl<'a> Parser<'a> { let operand_expr = this.parse_dot_or_call_expr(Default::default())?; this.recover_from_prefix_increment(operand_expr, pre_span, starts_stmt) } - token::Ident(..) if this.token.is_keyword(kw::Box) => { make_it!(this, attrs, |this, _| this.parse_box_expr(lo)) } diff --git a/tests/ui/parser/issue-108495-dec.rs b/tests/ui/parser/issue-108495-dec.rs index db45577ec01..e0816f84e5c 100644 --- a/tests/ui/parser/issue-108495-dec.rs +++ b/tests/ui/parser/issue-108495-dec.rs @@ -1,41 +1,39 @@ -fn test4() { +fn test0() { let mut i = 0; let _ = i + i--; //~ ERROR Rust has no postfix decrement operator // won't suggest since we can not handle the precedences } -fn test5() { +fn test1() { let mut i = 0; let _ = i-- + i--; //~ ERROR Rust has no postfix decrement operator } -fn test6() { +fn test2() { let mut i = 0; let _ = --i + i--; //~ ERROR Rust has no postfix decrement operator } -fn test7() { +fn test3() { let mut i = 0; let _ = i-- + --i; //~ ERROR Rust has no postfix decrement operator } -fn test8() { +fn test4() { let mut i = 0; let _ = (1 + 2 + i)--; //~ ERROR Rust has no postfix decrement operator } -fn test9() { +fn test5() { let mut i = 0; let _ = (i-- + 1) + 2; //~ ERROR Rust has no postfix decrement operator } - - -fn test14(){ +fn test6(){ let i=10; - while i!=0{ + while i != 0 { i--; //~ ERROR Rust has no postfix decrement operator } } -fn main() { } +fn main() {} diff --git a/tests/ui/parser/issue-108495-dec.stderr b/tests/ui/parser/issue-108495-dec.stderr index 90019e68f44..85b29038f7c 100644 --- a/tests/ui/parser/issue-108495-dec.stderr +++ b/tests/ui/parser/issue-108495-dec.stderr @@ -55,7 +55,7 @@ LL | let _ = ({ let tmp = i; i -= 1; tmp } + 1) + 2; | +++++++++++ ~~~~~~~~~~~~~~~ error: Rust has no postfix decrement operator - --> $DIR/issue-108495-dec.rs:37:10 + --> $DIR/issue-108495-dec.rs:35:10 | LL | i--; | ^^ not a valid postfix operator