diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /src/tools/clippy/tests/ui/float_arithmetic.rs | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/float_arithmetic.rs')
-rw-r--r-- | src/tools/clippy/tests/ui/float_arithmetic.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/float_arithmetic.rs b/src/tools/clippy/tests/ui/float_arithmetic.rs index a928c35e8..1647273c4 100644 --- a/src/tools/clippy/tests/ui/float_arithmetic.rs +++ b/src/tools/clippy/tests/ui/float_arithmetic.rs @@ -13,40 +13,58 @@ fn main() { let mut f = 1.0f32; f * 2.0; + //~^ ERROR: floating-point arithmetic detected + //~| NOTE: `-D clippy::float-arithmetic` implied by `-D warnings` 1.0 + f; + //~^ ERROR: floating-point arithmetic detected f * 2.0; + //~^ ERROR: floating-point arithmetic detected f / 2.0; + //~^ ERROR: floating-point arithmetic detected f - 2.0 * 4.2; + //~^ ERROR: floating-point arithmetic detected -f; + //~^ ERROR: floating-point arithmetic detected f += 1.0; + //~^ ERROR: floating-point arithmetic detected f -= 1.0; + //~^ ERROR: floating-point arithmetic detected f *= 2.0; + //~^ ERROR: floating-point arithmetic detected f /= 2.0; + //~^ ERROR: floating-point arithmetic detected } // also warn about floating point arith with references involved pub fn float_arith_ref() { 3.1_f32 + &1.2_f32; + //~^ ERROR: floating-point arithmetic detected &3.4_f32 + 1.5_f32; + //~^ ERROR: floating-point arithmetic detected &3.5_f32 + &1.3_f32; + //~^ ERROR: floating-point arithmetic detected } pub fn float_foo(f: &f32) -> f32 { let a = 5.1; a + f + //~^ ERROR: floating-point arithmetic detected } pub fn float_bar(f1: &f32, f2: &f32) -> f32 { f1 + f2 + //~^ ERROR: floating-point arithmetic detected } pub fn float_baz(f1: f32, f2: &f32) -> f32 { f1 + f2 + //~^ ERROR: floating-point arithmetic detected } pub fn float_qux(f1: f32, f2: f32) -> f32 { (&f1 + &f2) + //~^ ERROR: floating-point arithmetic detected } |