]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/clippy/tests/ui/floating_point_exp.rs
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / floating_point_exp.rs
diff --git a/src/tools/clippy/tests/ui/floating_point_exp.rs b/src/tools/clippy/tests/ui/floating_point_exp.rs
new file mode 100644 (file)
index 0000000..27e0b9b
--- /dev/null
@@ -0,0 +1,18 @@
+// run-rustfix
+#![warn(clippy::imprecise_flops)]
+
+fn main() {
+    let x = 2f32;
+    let _ = x.exp() - 1.0;
+    let _ = x.exp() - 1.0 + 2.0;
+    // Cases where the lint shouldn't be applied
+    let _ = x.exp() - 2.0;
+    let _ = x.exp() - 1.0 * 2.0;
+
+    let x = 2f64;
+    let _ = x.exp() - 1.0;
+    let _ = x.exp() - 1.0 + 2.0;
+    // Cases where the lint shouldn't be applied
+    let _ = x.exp() - 2.0;
+    let _ = x.exp() - 1.0 * 2.0;
+}