Skip to content

Commit ac914d3

Browse files
committed
Auto merge of #12476 - GuillaumeGomez:add-manual_arithmetic_check, r=y21
Extend `implicit_saturating_sub` lint Fixes #10070. It can serve as base if we want to add equivalent checks for other arithmetic operations. Also one important note: when writing this lint, I realized that I could check for wrong conditions performed beforehand on subtraction and added another part in the lint. Considering they both rely on the same checks, I kept both in the same place. Not sure if it makes sense though... changelog: Extend `implicit_saturating_sub` lint
2 parents b86a202 + 2832faf commit ac914d3

12 files changed

+508
-70
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5500,6 +5500,7 @@ Released 2018-09-13
55005500
[`invalid_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
55015501
[`invalid_upcast_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_upcast_comparisons
55025502
[`invalid_utf8_in_unchecked`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_utf8_in_unchecked
5503+
[`inverted_saturating_sub`]: https://rust-lang.github.io/rust-clippy/master/index.html#inverted_saturating_sub
55035504
[`invisible_characters`]: https://rust-lang.github.io/rust-clippy/master/index.html#invisible_characters
55045505
[`is_digit_ascii_radix`]: https://rust-lang.github.io/rust-clippy/master/index.html#is_digit_ascii_radix
55055506
[`items_after_statements`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements

clippy_config/src/msrvs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ msrv_aliases! {
3636
1,52,0 { STR_SPLIT_ONCE, REM_EUCLID_CONST }
3737
1,51,0 { BORROW_AS_PTR, SEEK_FROM_CURRENT, UNSIGNED_ABS }
3838
1,50,0 { BOOL_THEN, CLAMP }
39-
1,47,0 { TAU, IS_ASCII_DIGIT_CONST, ARRAY_IMPL_ANY_LEN }
39+
1,47,0 { TAU, IS_ASCII_DIGIT_CONST, ARRAY_IMPL_ANY_LEN, SATURATING_SUB_CONST }
4040
1,46,0 { CONST_IF_MATCH }
4141
1,45,0 { STR_STRIP_PREFIX }
4242
1,43,0 { LOG2_10, LOG10_2, NUMERIC_ASSOCIATED_CONSTANTS }

clippy_lints/src/declared_lints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
217217
crate::implicit_return::IMPLICIT_RETURN_INFO,
218218
crate::implicit_saturating_add::IMPLICIT_SATURATING_ADD_INFO,
219219
crate::implicit_saturating_sub::IMPLICIT_SATURATING_SUB_INFO,
220+
crate::implicit_saturating_sub::INVERTED_SATURATING_SUB_INFO,
220221
crate::implied_bounds_in_impls::IMPLIED_BOUNDS_IN_IMPLS_INFO,
221222
crate::incompatible_msrv::INCOMPATIBLE_MSRV_INFO,
222223
crate::inconsistent_struct_constructor::INCONSISTENT_STRUCT_CONSTRUCTOR_INFO,

0 commit comments

Comments
 (0)