-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #4532 - rust-lang:integer-const, r=oli-obk
New `is_integer_const` to check more const ints This mostly affects loop checks and the modulo_one lint. Tests were also updated where applicable. changelog: none
- Loading branch information
Showing
11 changed files
with
98 additions
and
20 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
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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
#![warn(clippy::modulo_one)] | ||
#![allow(clippy::no_effect, clippy::unnecessary_operation)] | ||
|
||
static STATIC_ONE: usize = 2 - 1; | ||
|
||
fn main() { | ||
10 % 1; | ||
10 % 2; | ||
|
||
const ONE: u32 = 1 * 1; | ||
|
||
2 % ONE; | ||
5 % STATIC_ONE; | ||
} |
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 |
---|---|---|
@@ -1,10 +1,30 @@ | ||
error: any number modulo 1 will be 0 | ||
--> $DIR/modulo_one.rs:5:5 | ||
--> $DIR/modulo_one.rs:7:5 | ||
| | ||
LL | 10 % 1; | ||
| ^^^^^^ | ||
| | ||
= note: `-D clippy::modulo-one` implied by `-D warnings` | ||
|
||
error: aborting due to previous error | ||
error: the operation is ineffective. Consider reducing it to `1` | ||
--> $DIR/modulo_one.rs:10:22 | ||
| | ||
LL | const ONE: u32 = 1 * 1; | ||
| ^^^^^ | ||
| | ||
= note: `-D clippy::identity-op` implied by `-D warnings` | ||
|
||
error: the operation is ineffective. Consider reducing it to `1` | ||
--> $DIR/modulo_one.rs:10:22 | ||
| | ||
LL | const ONE: u32 = 1 * 1; | ||
| ^^^^^ | ||
|
||
error: any number modulo 1 will be 0 | ||
--> $DIR/modulo_one.rs:12:5 | ||
| | ||
LL | 2 % ONE; | ||
| ^^^^^^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|
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