-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #108495, postfix decrement and prefix decrement has no warning
- Loading branch information
Showing
4 changed files
with
214 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
fn test1() { | ||
let mut i = 0; | ||
let _ = i + --i; //~ ERROR Rust has no prefix decrement operator | ||
} | ||
|
||
fn test2() { | ||
let mut i = 0; | ||
let _ = --i + i; //~ ERROR Rust has no prefix decrement operator | ||
} | ||
|
||
fn test3() { | ||
let mut i = 0; | ||
let _ = --i + --i; //~ ERROR Rust has no prefix decrement operator | ||
} | ||
|
||
fn test4() { | ||
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() { | ||
let mut i = 0; | ||
let _ = i-- + i; //~ ERROR Rust has no postfix decrement operator | ||
} | ||
|
||
fn test6() { | ||
let mut i = 0; | ||
let _ = i-- + i--; //~ ERROR Rust has no postfix decrement operator | ||
} | ||
|
||
fn test7() { | ||
let mut i = 0; | ||
let _ = --i + i--; //~ ERROR Rust has no prefix decrement operator | ||
} | ||
|
||
fn test8() { | ||
let mut i = 0; | ||
let _ = i-- + --i; //~ ERROR Rust has no postfix decrement operator | ||
} | ||
|
||
fn test9() { | ||
let mut i = 0; | ||
let _ = (1 + 2 + i)--; //~ ERROR Rust has no postfix decrement operator | ||
} | ||
|
||
fn test10() { | ||
let mut i = 0; | ||
let _ = (i-- + 1) + 2; //~ ERROR Rust has no postfix decrement operator | ||
} | ||
|
||
fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
error: Rust has no prefix decrement operator | ||
--> $DIR/issue-dec.rs:3:17 | ||
| | ||
LL | let _ = i + --i; | ||
| ^^ not a valid prefix operator | ||
| | ||
help: use `-= 1` instead | ||
| | ||
LL | let _ = i + { i -= 1; i }; | ||
| ~ +++++++++ | ||
|
||
error: Rust has no prefix decrement operator | ||
--> $DIR/issue-dec.rs:8:13 | ||
| | ||
LL | let _ = --i + i; | ||
| ^^ not a valid prefix operator | ||
| | ||
help: use `-= 1` instead | ||
| | ||
LL | let _ = { i -= 1; i } + i; | ||
| ~ +++++++++ | ||
|
||
error: Rust has no prefix decrement operator | ||
--> $DIR/issue-dec.rs:13:13 | ||
| | ||
LL | let _ = --i + --i; | ||
| ^^ not a valid prefix operator | ||
| | ||
help: use `-= 1` instead | ||
| | ||
LL | let _ = { i -= 1; i } + --i; | ||
| ~ +++++++++ | ||
|
||
error: Rust has no postfix decrement operator | ||
--> $DIR/issue-dec.rs:18:18 | ||
| | ||
LL | let _ = i + i--; | ||
| ^^ not a valid postfix operator | ||
|
||
error: Rust has no postfix decrement operator | ||
--> $DIR/issue-dec.rs:24:14 | ||
| | ||
LL | let _ = i-- + i; | ||
| ^^ not a valid postfix operator | ||
| | ||
help: use `-= 1` instead | ||
| | ||
LL | let _ = { let tmp = i; i -= 1; tmp } + i; | ||
| +++++++++++ ~~~~~~~~~~~~~~~ | ||
|
||
error: Rust has no postfix decrement operator | ||
--> $DIR/issue-dec.rs:29:14 | ||
| | ||
LL | let _ = i-- + i--; | ||
| ^^ not a valid postfix operator | ||
| | ||
help: use `-= 1` instead | ||
| | ||
LL | let _ = { let tmp = i; i -= 1; tmp } + i--; | ||
| +++++++++++ ~~~~~~~~~~~~~~~ | ||
|
||
error: Rust has no prefix decrement operator | ||
--> $DIR/issue-dec.rs:34:13 | ||
| | ||
LL | let _ = --i + i--; | ||
| ^^ not a valid prefix operator | ||
| | ||
help: use `-= 1` instead | ||
| | ||
LL | let _ = { i -= 1; i } + i--; | ||
| ~ +++++++++ | ||
|
||
error: Rust has no postfix decrement operator | ||
--> $DIR/issue-dec.rs:39:14 | ||
| | ||
LL | let _ = i-- + --i; | ||
| ^^ not a valid postfix operator | ||
| | ||
help: use `-= 1` instead | ||
| | ||
LL | let _ = { let tmp = i; i -= 1; tmp } + --i; | ||
| +++++++++++ ~~~~~~~~~~~~~~~ | ||
|
||
error: Rust has no postfix decrement operator | ||
--> $DIR/issue-dec.rs:44:24 | ||
| | ||
LL | let _ = (1 + 2 + i)--; | ||
| ^^ not a valid postfix operator | ||
| | ||
help: use `-= 1` instead | ||
| | ||
LL | let _ = { let tmp = (1 + 2 + i); (1 + 2 + i) -= 1; tmp }; | ||
| +++++++++++ ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: Rust has no postfix decrement operator | ||
--> $DIR/issue-dec.rs:49:15 | ||
| | ||
LL | let _ = (i-- + 1) + 2; | ||
| ^^ not a valid postfix operator | ||
| | ||
help: use `-= 1` instead | ||
| | ||
LL | let _ = ({ let tmp = i; i -= 1; tmp } + 1) + 2; | ||
| +++++++++++ ~~~~~~~~~~~~~~~ | ||
|
||
error: aborting due to 10 previous errors | ||
|