diff options
| author | bors <bors@rust-lang.org> | 2025-09-05 02:01:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-09-05 02:01:50 +0000 |
| commit | 91edc3ebccc4daa46c20a93f4709862376da1fdd (patch) | |
| tree | 63e75231cb63d011d54d9cd3e771fb4b91eb81da /src/tools/clippy/tests/ui/assign_ops.fixed | |
| parent | b3cfb8faf84c5f3b7909479a9f9b6a3290d5f4d7 (diff) | |
| parent | 75b9ee5f085f695cba061fd9ed7fa3b912dd1bbf (diff) | |
| download | rust-91edc3ebccc4daa46c20a93f4709862376da1fdd.tar.gz rust-91edc3ebccc4daa46c20a93f4709862376da1fdd.zip | |
Auto merge of #146218 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update r? `@Manishearth`
Diffstat (limited to 'src/tools/clippy/tests/ui/assign_ops.fixed')
| -rw-r--r-- | src/tools/clippy/tests/ui/assign_ops.fixed | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/tools/clippy/tests/ui/assign_ops.fixed b/src/tools/clippy/tests/ui/assign_ops.fixed index 3754b9dfe74..2046d089d6a 100644 --- a/src/tools/clippy/tests/ui/assign_ops.fixed +++ b/src/tools/clippy/tests/ui/assign_ops.fixed @@ -1,8 +1,9 @@ #![allow(clippy::useless_vec)] #![warn(clippy::assign_op_pattern)] -#![feature(const_trait_impl, const_ops)] +#![feature(const_ops)] +#![feature(const_trait_impl)] -use core::num::Wrapping; +use std::num::Wrapping; use std::ops::{Mul, MulAssign}; fn main() { @@ -82,6 +83,18 @@ mod issue14871 { pub trait Number: Copy + Add<Self, Output = Self> + AddAssign { const ZERO: Self; const ONE: Self; + + fn non_constant(value: usize) -> Self { + let mut res = Self::ZERO; + let mut count = 0; + while count < value { + res += Self::ONE; + //~^ assign_op_pattern + count += 1; + //~^ assign_op_pattern + } + res + } } #[rustfmt::skip] // rustfmt doesn't understand the order of pub const on traits (yet) @@ -91,7 +104,7 @@ mod issue14871 { impl<T> const NumberConstants for T where - T: Number + [const] core::ops::Add, + T: Number + [const] std::ops::Add, { fn constant(value: usize) -> Self { let mut res = Self::ZERO; @@ -99,8 +112,28 @@ mod issue14871 { while count < value { res = res + Self::ONE; count += 1; + //~^ assign_op_pattern } res } } + + pub struct S; + + impl const std::ops::Add for S { + type Output = S; + fn add(self, _rhs: S) -> S { + S + } + } + + impl const std::ops::AddAssign for S { + fn add_assign(&mut self, rhs: S) {} + } + + const fn do_add() { + let mut s = S; + s += S; + //~^ assign_op_pattern + } } |
