Skip to content

Commit 432b361

Browse files
committed
Experiment: lint all .is_multiple_of() candidates
This is not meant to be merged as-is. Also, tests have been spared to avoid modifying the 8 tests that use lintable expressions; they still use 4 as a value.
1 parent 19d8ca6 commit 432b361

File tree

5 files changed

+5
-3
lines changed

5 files changed

+5
-3
lines changed

book/src/lint_configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ The maximum number of bounds a trait can have to be linted
706706
## `min-divisor`
707707
The smallest divisor to propose `.is_multiple_of()` for.
708708

709-
**Default Value:** `4`
709+
**Default Value:** `0`
710710

711711
---
712712
**Affected lints:**

clippy_config/src/conf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ define_Conf! {
585585
max_trait_bounds: u64 = 3,
586586
/// The smallest divisor to propose `.is_multiple_of()` for.
587587
#[lints(manual_is_multiple_of)]
588-
min_divisor: u64 = 4,
588+
min_divisor: u64 = 0,
589589
/// Minimum chars an ident can have, anything below or equal to this will be linted.
590590
#[lints(min_ident_chars)]
591591
min_ident_chars_threshold: u64 = 1,

clippy_lints/src/casts/cast_sign_loss.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn pow_call_result_sign(cx: &LateContext<'_>, base: &Expr<'_>, exponent: &Expr<'
167167

168168
// Rust's integer pow() functions take an unsigned exponent.
169169
let exponent_val = get_const_unsigned_int_eval(cx, exponent, None);
170-
let exponent_is_even = exponent_val.map(|val| val % 2 == 0);
170+
let exponent_is_even = exponent_val.map(|val| val.is_multiple_of(2));
171171

172172
match (base_sign, exponent_is_even) {
173173
// Non-negative bases always return non-negative results, ignoring overflow.

clippy_lints/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![feature(round_char_boundary)]
1313
#![feature(rustc_private)]
1414
#![feature(stmt_expr_attributes)]
15+
#![feature(unsigned_is_multiple_of)]
1516
#![feature(unwrap_infallible)]
1617
#![recursion_limit = "512"]
1718
#![allow(

tests/clippy.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# default config for tests, overrides clippy.toml at the project root
2+
min-divisor = 4

0 commit comments

Comments
 (0)