forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#108496 - nx2k3:issue-108495-dec, r=WaffleLa…
…pkin fix rust-lang#108495, postfix decrement and prefix decrement has no warning Fixes rust-lang#108495
- Loading branch information
Showing
4 changed files
with
134 additions
and
2 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,39 @@ | ||
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 test1() { | ||
let mut i = 0; | ||
let _ = i-- + i--; //~ ERROR Rust has no postfix decrement operator | ||
} | ||
|
||
fn test2() { | ||
let mut i = 0; | ||
let _ = --i + i--; //~ ERROR Rust has no postfix decrement operator | ||
} | ||
|
||
fn test3() { | ||
let mut i = 0; | ||
let _ = i-- + --i; //~ ERROR Rust has no postfix decrement operator | ||
} | ||
|
||
fn test4() { | ||
let mut i = 0; | ||
let _ = (1 + 2 + i)--; //~ ERROR Rust has no postfix decrement operator | ||
} | ||
|
||
fn test5() { | ||
let mut i = 0; | ||
let _ = (i-- + 1) + 2; //~ ERROR Rust has no postfix decrement operator | ||
} | ||
|
||
fn test6(){ | ||
let i=10; | ||
while i != 0 { | ||
i--; //~ 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,69 @@ | ||
error: Rust has no postfix decrement operator | ||
--> $DIR/issue-108495-dec.rs:3:18 | ||
| | ||
LL | let _ = i + i--; | ||
| ^^ not a valid postfix operator | ||
|
||
error: Rust has no postfix decrement operator | ||
--> $DIR/issue-108495-dec.rs:9: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-108495-dec.rs:14:20 | ||
| | ||
LL | let _ = --i + i--; | ||
| ^^ not a valid postfix operator | ||
|
||
error: Rust has no postfix decrement operator | ||
--> $DIR/issue-108495-dec.rs:19: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-108495-dec.rs:24: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-108495-dec.rs:29: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: Rust has no postfix decrement operator | ||
--> $DIR/issue-108495-dec.rs:35:10 | ||
| | ||
LL | i--; | ||
| ^^ not a valid postfix operator | ||
| | ||
help: use `-= 1` instead | ||
| | ||
LL | i -= 1; | ||
| ~~~~ | ||
|
||
error: aborting due to 7 previous errors | ||
|