Skip to content

Commit a0e8257

Browse files
committed
Auto merge of rust-lang#11147 - y21:issue11145, r=Alexendoo
[`arithmetic_side_effect`]: allow different types on the right hand side for `Wrapping<T>` Fixes rust-lang#11145 This lint has a list of allowed types, one of which is `Wrapping<T>`, but it was only actually allowed if the type on the right hand side was also `Wrapping<T>`, which meant that, for example, `Wrapping<u32> += u32` would still lint. It now allows binary ops involving `Wrapping<T>` regardless of the type on the rhs. These impls have only existed since Rust 1.60.0, so that is probably why the lint was previously not handling this correctly changelog: [`arithmetic_side_effect`]: allow different types on the right hand side for `Wrapping<T>` (e.g. `Wrapping<T> += T`)
2 parents 631faa1 + c5fc61c commit a0e8257

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

clippy_lints/src/operators/arithmetic_side_effects.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use rustc_span::{
1919
const HARD_CODED_ALLOWED_BINARY: &[[&str; 2]] = &[
2020
["f32", "f32"],
2121
["f64", "f64"],
22-
["std::num::Saturating", "std::num::Saturating"],
23-
["std::num::Wrapping", "std::num::Wrapping"],
22+
["std::num::Saturating", "*"],
23+
["std::num::Wrapping", "*"],
2424
["std::string::String", "str"],
2525
];
2626
const HARD_CODED_ALLOWED_UNARY: &[&str] = &["f32", "f64", "std::num::Saturating", "std::num::Wrapping"];

tests/ui/arithmetic_side_effects.rs

+5
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,9 @@ pub fn issue_10792() {
481481
let _ = 10 / TWO.c;
482482
}
483483

484+
pub fn issue_11145() {
485+
let mut x: Wrapping<u32> = Wrapping(0_u32);
486+
x += 1;
487+
}
488+
484489
fn main() {}

0 commit comments

Comments
 (0)