-
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.
- Loading branch information
Showing
8 changed files
with
150 additions
and
6 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
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,9 @@ | ||
//@ check-pass | ||
fn main() { | ||
let x = 1; | ||
-x; | ||
-(-x); | ||
--x; //~ WARN use of a double negation | ||
---x; //~ WARN use of a double negation | ||
let _y = --(-x); //~ WARN use of a double negation | ||
} |
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,42 @@ | ||
warning: use of a double negation | ||
--> $DIR/lint-double-negations.rs:6:5 | ||
| | ||
LL | --x; | ||
| ^^^ | ||
| | ||
= note: the prefix `--` could be misinterpreted as a decrement operator which exists in other languages | ||
= note: use `-= 1` if you meant to decrement the value | ||
= note: `#[warn(double_negations)]` on by default | ||
help: add parentheses for clarity | ||
| | ||
LL | -(-x); | ||
| + + | ||
|
||
warning: use of a double negation | ||
--> $DIR/lint-double-negations.rs:7:6 | ||
| | ||
LL | ---x; | ||
| ^^^ | ||
| | ||
= note: the prefix `--` could be misinterpreted as a decrement operator which exists in other languages | ||
= note: use `-= 1` if you meant to decrement the value | ||
help: add parentheses for clarity | ||
| | ||
LL | --(-x); | ||
| + + | ||
|
||
warning: use of a double negation | ||
--> $DIR/lint-double-negations.rs:8:14 | ||
| | ||
LL | let _y = --(-x); | ||
| ^^^^^^ | ||
| | ||
= note: the prefix `--` could be misinterpreted as a decrement operator which exists in other languages | ||
= note: use `-= 1` if you meant to decrement the value | ||
help: add parentheses for clarity | ||
| | ||
LL | let _y = -(-(-x)); | ||
| + + | ||
|
||
warning: 3 warnings emitted | ||
|
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