about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/floating_point_mul_add.fixed2
-rw-r--r--tests/ui/floating_point_mul_add.rs2
-rw-r--r--tests/ui/floating_point_mul_add.stderr30
-rw-r--r--tests/ui/floating_point_powi.fixed2
-rw-r--r--tests/ui/floating_point_powi.rs2
-rw-r--r--tests/ui/floating_point_powi.stderr20
6 files changed, 45 insertions, 13 deletions
diff --git a/tests/ui/floating_point_mul_add.fixed b/tests/ui/floating_point_mul_add.fixed
index 169ec02f82b..d3e536ba350 100644
--- a/tests/ui/floating_point_mul_add.fixed
+++ b/tests/ui/floating_point_mul_add.fixed
@@ -19,7 +19,9 @@ fn main() {
     let d: f64 = 0.0001;
 
     let _ = a.mul_add(b, c);
+    let _ = a.mul_add(b, -c);
     let _ = a.mul_add(b, c);
+    let _ = a.mul_add(-b, c);
     let _ = 2.0f64.mul_add(4.0, a);
     let _ = 2.0f64.mul_add(4., a);
 
diff --git a/tests/ui/floating_point_mul_add.rs b/tests/ui/floating_point_mul_add.rs
index 5338d4fc2b7..5d4a9e35cfc 100644
--- a/tests/ui/floating_point_mul_add.rs
+++ b/tests/ui/floating_point_mul_add.rs
@@ -19,7 +19,9 @@ fn main() {
     let d: f64 = 0.0001;
 
     let _ = a * b + c;
+    let _ = a * b - c;
     let _ = c + a * b;
+    let _ = c - a * b;
     let _ = a + 2.0 * 4.0;
     let _ = a + 2. * 4.;
 
diff --git a/tests/ui/floating_point_mul_add.stderr b/tests/ui/floating_point_mul_add.stderr
index e637bbf90ca..a79ae94e8d4 100644
--- a/tests/ui/floating_point_mul_add.stderr
+++ b/tests/ui/floating_point_mul_add.stderr
@@ -9,56 +9,68 @@ LL |     let _ = a * b + c;
 error: multiply and add expressions can be calculated more efficiently and accurately
   --> $DIR/floating_point_mul_add.rs:22:13
    |
+LL |     let _ = a * b - c;
+   |             ^^^^^^^^^ help: consider using: `a.mul_add(b, -c)`
+
+error: multiply and add expressions can be calculated more efficiently and accurately
+  --> $DIR/floating_point_mul_add.rs:23:13
+   |
 LL |     let _ = c + a * b;
    |             ^^^^^^^^^ help: consider using: `a.mul_add(b, c)`
 
 error: multiply and add expressions can be calculated more efficiently and accurately
-  --> $DIR/floating_point_mul_add.rs:23:13
+  --> $DIR/floating_point_mul_add.rs:24:13
+   |
+LL |     let _ = c - a * b;
+   |             ^^^^^^^^^ help: consider using: `a.mul_add(-b, c)`
+
+error: multiply and add expressions can be calculated more efficiently and accurately
+  --> $DIR/floating_point_mul_add.rs:25:13
    |
 LL |     let _ = a + 2.0 * 4.0;
    |             ^^^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4.0, a)`
 
 error: multiply and add expressions can be calculated more efficiently and accurately
-  --> $DIR/floating_point_mul_add.rs:24:13
+  --> $DIR/floating_point_mul_add.rs:26:13
    |
 LL |     let _ = a + 2. * 4.;
    |             ^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4., a)`
 
 error: multiply and add expressions can be calculated more efficiently and accurately
-  --> $DIR/floating_point_mul_add.rs:26:13
+  --> $DIR/floating_point_mul_add.rs:28:13
    |
 LL |     let _ = (a * b) + c;
    |             ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)`
 
 error: multiply and add expressions can be calculated more efficiently and accurately
-  --> $DIR/floating_point_mul_add.rs:27:13
+  --> $DIR/floating_point_mul_add.rs:29:13
    |
 LL |     let _ = c + (a * b);
    |             ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)`
 
 error: multiply and add expressions can be calculated more efficiently and accurately
-  --> $DIR/floating_point_mul_add.rs:28:13
+  --> $DIR/floating_point_mul_add.rs:30:13
    |
 LL |     let _ = a * b * c + d;
    |             ^^^^^^^^^^^^^ help: consider using: `(a * b).mul_add(c, d)`
 
 error: multiply and add expressions can be calculated more efficiently and accurately
-  --> $DIR/floating_point_mul_add.rs:30:13
+  --> $DIR/floating_point_mul_add.rs:32:13
    |
 LL |     let _ = a.mul_add(b, c) * a.mul_add(b, c) + a.mul_add(b, c) + c;
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `a.mul_add(b, c).mul_add(a.mul_add(b, c), a.mul_add(b, c))`
 
 error: multiply and add expressions can be calculated more efficiently and accurately
-  --> $DIR/floating_point_mul_add.rs:31:13
+  --> $DIR/floating_point_mul_add.rs:33:13
    |
 LL |     let _ = 1234.567_f64 * 45.67834_f64 + 0.0004_f64;
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1234.567_f64.mul_add(45.67834_f64, 0.0004_f64)`
 
 error: multiply and add expressions can be calculated more efficiently and accurately
-  --> $DIR/floating_point_mul_add.rs:33:13
+  --> $DIR/floating_point_mul_add.rs:35:13
    |
 LL |     let _ = (a * a + b).sqrt();
    |             ^^^^^^^^^^^ help: consider using: `a.mul_add(a, b)`
 
-error: aborting due to 10 previous errors
+error: aborting due to 12 previous errors
 
diff --git a/tests/ui/floating_point_powi.fixed b/tests/ui/floating_point_powi.fixed
index 5758db7c6c8..cc337038888 100644
--- a/tests/ui/floating_point_powi.fixed
+++ b/tests/ui/floating_point_powi.fixed
@@ -7,7 +7,9 @@ fn main() {
 
     let y = 4f32;
     let _ = x.mul_add(x, y);
+    let _ = x.mul_add(x, -y);
     let _ = y.mul_add(y, x);
+    let _ = y.mul_add(-y, x);
     let _ = (y as f32).mul_add(y as f32, x);
     let _ = x.mul_add(x, y).sqrt();
     let _ = y.mul_add(y, x).sqrt();
diff --git a/tests/ui/floating_point_powi.rs b/tests/ui/floating_point_powi.rs
index 5926bf1b000..5950902178c 100644
--- a/tests/ui/floating_point_powi.rs
+++ b/tests/ui/floating_point_powi.rs
@@ -7,7 +7,9 @@ fn main() {
 
     let y = 4f32;
     let _ = x.powi(2) + y;
+    let _ = x.powi(2) - y;
     let _ = x + y.powi(2);
+    let _ = x - y.powi(2);
     let _ = x + (y as f32).powi(2);
     let _ = (x.powi(2) + y).sqrt();
     let _ = (x + y.powi(2)).sqrt();
diff --git a/tests/ui/floating_point_powi.stderr b/tests/ui/floating_point_powi.stderr
index a3c74544212..643b70739cd 100644
--- a/tests/ui/floating_point_powi.stderr
+++ b/tests/ui/floating_point_powi.stderr
@@ -9,26 +9,38 @@ LL |     let _ = x.powi(2) + y;
 error: multiply and add expressions can be calculated more efficiently and accurately
   --> $DIR/floating_point_powi.rs:10:13
    |
+LL |     let _ = x.powi(2) - y;
+   |             ^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, -y)`
+
+error: multiply and add expressions can be calculated more efficiently and accurately
+  --> $DIR/floating_point_powi.rs:11:13
+   |
 LL |     let _ = x + y.powi(2);
    |             ^^^^^^^^^^^^^ help: consider using: `y.mul_add(y, x)`
 
 error: multiply and add expressions can be calculated more efficiently and accurately
-  --> $DIR/floating_point_powi.rs:11:13
+  --> $DIR/floating_point_powi.rs:12:13
+   |
+LL |     let _ = x - y.powi(2);
+   |             ^^^^^^^^^^^^^ help: consider using: `y.mul_add(-y, x)`
+
+error: multiply and add expressions can be calculated more efficiently and accurately
+  --> $DIR/floating_point_powi.rs:13:13
    |
 LL |     let _ = x + (y as f32).powi(2);
    |             ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y as f32).mul_add(y as f32, x)`
 
 error: multiply and add expressions can be calculated more efficiently and accurately
-  --> $DIR/floating_point_powi.rs:12:13
+  --> $DIR/floating_point_powi.rs:14:13
    |
 LL |     let _ = (x.powi(2) + y).sqrt();
    |             ^^^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, y)`
 
 error: multiply and add expressions can be calculated more efficiently and accurately
-  --> $DIR/floating_point_powi.rs:13:13
+  --> $DIR/floating_point_powi.rs:15:13
    |
 LL |     let _ = (x + y.powi(2)).sqrt();
    |             ^^^^^^^^^^^^^^^ help: consider using: `y.mul_add(y, x)`
 
-error: aborting due to 5 previous errors
+error: aborting due to 7 previous errors