diff --git a/tests/ui-toml/float_cmp_change_detection/clippy.toml b/tests/ui-toml/float_cmp/change_detect/clippy.toml similarity index 100% rename from tests/ui-toml/float_cmp_change_detection/clippy.toml rename to tests/ui-toml/float_cmp/change_detect/clippy.toml diff --git a/tests/ui-toml/float_cmp_constant_comparisons/clippy.toml b/tests/ui-toml/float_cmp/const_cmp/clippy.toml similarity index 100% rename from tests/ui-toml/float_cmp_constant_comparisons/clippy.toml rename to tests/ui-toml/float_cmp/const_cmp/clippy.toml diff --git a/tests/ui-toml/float_cmp_named_constants/clippy.toml b/tests/ui-toml/float_cmp/named_const/clippy.toml similarity index 100% rename from tests/ui-toml/float_cmp_named_constants/clippy.toml rename to tests/ui-toml/float_cmp/named_const/clippy.toml diff --git a/tests/ui-toml/float_cmp/test.change_detect.stderr b/tests/ui-toml/float_cmp/test.change_detect.stderr new file mode 100644 index 000000000000..e212739c7afe --- /dev/null +++ b/tests/ui-toml/float_cmp/test.change_detect.stderr @@ -0,0 +1,296 @@ +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:15:21 + | +LL | let _ = x == y; + | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() < error_margin` + | +note: the lint level is defined here + --> tests/ui-toml/float_cmp/test.rs:9:9 + | +LL | #![deny(clippy::float_cmp)] + | ^^^^^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:16:21 + | +LL | let _ = x != y; + | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() > error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:17:21 + | +LL | let _ = x == 5.5; + | ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 5.5).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:18:21 + | +LL | let _ = 5.5 == x; + | ^^^^^^^^ help: consider comparing them within some margin of error: `(5.5 - x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:41:21 + | +LL | let _ = x == y; + | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:42:21 + | +LL | let _ = x != y; + | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() > error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:43:21 + | +LL | let _ = x == 5.5; + | ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 5.5).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:44:21 + | +LL | let _ = 5.5 == x; + | ^^^^^^^^ help: consider comparing them within some margin of error: `(5.5 - x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:67:21 + | +LL | let _ = x == y; + | ^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:68:21 + | +LL | let _ = x == [5.5; 4]; + | ^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:69:21 + | +LL | let _ = [5.5; 4] == x; + | ^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:70:21 + | +LL | let _ = [0.0, 0.0, 0.0, 5.5] == x; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:71:21 + | +LL | let _ = x == [0.0, 0.0, 0.0, 5.5]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:87:21 + | +LL | let _ = x == y; + | ^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:88:21 + | +LL | let _ = x == [5.5; 4]; + | ^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:89:21 + | +LL | let _ = [5.5; 4] == x; + | ^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:90:21 + | +LL | let _ = [0.0, 0.0, 0.0, 5.5] == x; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:91:21 + | +LL | let _ = x == [0.0, 0.0, 0.0, 5.5]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:109:21 + | +LL | let _ = x == y; + | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() < error_margin` + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:115:21 + | +LL | let _ = x == y; + | ^^^^^^ + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:131:21 + | +LL | let _ = C * x == x * x; + | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(C * x - x * x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:132:21 + | +LL | let _ = x * x == C * x; + | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x * x - C * x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:158:17 + | +LL | let _ = f(1.0) == f(5.0); + | ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) - f(5.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:159:17 + | +LL | let _ = 1.0 == f(5.0); + | ^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(1.0 - f(5.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:160:17 + | +LL | let _ = f(1.0) + 1.0 != 5.0; + | ^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) + 1.0 - 5.0).abs() > error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:202:21 + | +LL | let _ = x == C[1]; + | ^^^^^^^^^ help: consider comparing them within some margin of error: `(x - C[1]).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:203:21 + | +LL | let _ = C[1] == x; + | ^^^^^^^^^ help: consider comparing them within some margin of error: `(C[1] - x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:262:21 + | +LL | let _ = x == x + 1.0; + | ^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x - (x + 1.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:263:21 + | +LL | let _ = x + 1.0 == x; + | ^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x + 1.0 - x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:264:21 + | +LL | let _ = -x == -x + 1.0; + | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(-x - (-x + 1.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:265:21 + | +LL | let _ = -x + 1.0 == -x; + | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(-x + 1.0 - -x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:266:21 + | +LL | let _ = x == f1(x); + | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(x - f1(x)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:267:21 + | +LL | let _ = f1(x) == x; + | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(f1(x) - x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:268:21 + | +LL | let _ = x == f2(x, y); + | ^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x - f2(x, y)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:269:21 + | +LL | let _ = f2(x, y) == x; + | ^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f2(x, y) - x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:270:21 + | +LL | let _ = f1(f1(x)) == f1(x); + | ^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f1(f1(x)) - f1(x)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:271:21 + | +LL | let _ = f1(x) == f1(f1(x)); + | ^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f1(x) - f1(f1(x))).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:274:21 + | +LL | let _ = z.0 == z.0 + 1.0; + | ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(z.0 - (z.0 + 1.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:275:21 + | +LL | let _ = z.0 + 1.0 == z.0; + | ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(z.0 + 1.0 - z.0).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:279:21 + | +LL | let _ = *x + 1.0 == *x; + | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(*x + 1.0 - *x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:280:21 + | +LL | let _ = *x == *x + 1.0; + | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(*x - (*x + 1.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:281:21 + | +LL | let _ = *x == f1(*x); + | ^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(*x - f1(*x)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:282:21 + | +LL | let _ = f1(*x) == *x; + | ^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f1(*x) - *x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:287:21 + | +LL | let _ = x.next().unwrap() == x.next().unwrap() + 1.0; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x.next().unwrap() - (x.next().unwrap() + 1.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:303:21 + | +LL | let _ = x.f() + 1.0 == x.f(); + | ^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x.f() + 1.0 - x.f()).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:304:21 + | +LL | let _ = x.f() == x.f() + 1.0; + | ^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x.f() - (x.f() + 1.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:309:17 + | +LL | let _ = f(1.0) == f(1.0) + 1.0; + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) - (f(1.0) + 1.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:313:17 + | +LL | let _ = f(1.0) == f(1.0) + 1.0; + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) - (f(1.0) + 1.0)).abs() < error_margin` + +error: aborting due to 48 previous errors + diff --git a/tests/ui/float_cmp.stderr b/tests/ui-toml/float_cmp/test.const_cmp.stderr similarity index 71% rename from tests/ui/float_cmp.stderr rename to tests/ui-toml/float_cmp/test.const_cmp.stderr index f5b7376c4a47..584b68caaae6 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui-toml/float_cmp/test.const_cmp.stderr @@ -1,191 +1,212 @@ error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:11:21 + --> tests/ui-toml/float_cmp/test.rs:15:21 | LL | let _ = x == y; | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() < error_margin` | - = note: `-D clippy::float-cmp` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::float_cmp)]` +note: the lint level is defined here + --> tests/ui-toml/float_cmp/test.rs:9:9 + | +LL | #![deny(clippy::float_cmp)] + | ^^^^^^^^^^^^^^^^^ error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:13:21 + --> tests/ui-toml/float_cmp/test.rs:16:21 | LL | let _ = x != y; | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() > error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:15:21 + --> tests/ui-toml/float_cmp/test.rs:17:21 | LL | let _ = x == 5.5; | ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 5.5).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:17:21 + --> tests/ui-toml/float_cmp/test.rs:18:21 | LL | let _ = 5.5 == x; | ^^^^^^^^ help: consider comparing them within some margin of error: `(5.5 - x).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:41:21 + --> tests/ui-toml/float_cmp/test.rs:41:21 | LL | let _ = x == y; | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:43:21 + --> tests/ui-toml/float_cmp/test.rs:42:21 | LL | let _ = x != y; | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() > error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:45:21 + --> tests/ui-toml/float_cmp/test.rs:43:21 | LL | let _ = x == 5.5; | ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 5.5).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:47:21 + --> tests/ui-toml/float_cmp/test.rs:44:21 | LL | let _ = 5.5 == x; | ^^^^^^^^ help: consider comparing them within some margin of error: `(5.5 - x).abs() < error_margin` error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:71:21 + --> tests/ui-toml/float_cmp/test.rs:67:21 | LL | let _ = x == y; | ^^^^^^ error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:73:21 + --> tests/ui-toml/float_cmp/test.rs:68:21 | LL | let _ = x == [5.5; 4]; | ^^^^^^^^^^^^^ error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:75:21 + --> tests/ui-toml/float_cmp/test.rs:69:21 | LL | let _ = [5.5; 4] == x; | ^^^^^^^^^^^^^ error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:77:21 + --> tests/ui-toml/float_cmp/test.rs:70:21 | LL | let _ = [0.0, 0.0, 0.0, 5.5] == x; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:79:21 + --> tests/ui-toml/float_cmp/test.rs:71:21 | LL | let _ = x == [0.0, 0.0, 0.0, 5.5]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:96:21 + --> tests/ui-toml/float_cmp/test.rs:87:21 | LL | let _ = x == y; | ^^^^^^ error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:98:21 + --> tests/ui-toml/float_cmp/test.rs:88:21 | LL | let _ = x == [5.5; 4]; | ^^^^^^^^^^^^^ error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:100:21 + --> tests/ui-toml/float_cmp/test.rs:89:21 | LL | let _ = [5.5; 4] == x; | ^^^^^^^^^^^^^ error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:102:21 + --> tests/ui-toml/float_cmp/test.rs:90:21 | LL | let _ = [0.0, 0.0, 0.0, 5.5] == x; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:104:21 + --> tests/ui-toml/float_cmp/test.rs:91:21 | LL | let _ = x == [0.0, 0.0, 0.0, 5.5]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:123:21 + --> tests/ui-toml/float_cmp/test.rs:109:21 | LL | let _ = x == y; | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() < error_margin` error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:131:21 + --> tests/ui-toml/float_cmp/test.rs:115:21 | LL | let _ = x == y; | ^^^^^^ error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:149:21 + --> tests/ui-toml/float_cmp/test.rs:131:21 | LL | let _ = C * x == x * x; | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(C * x - x * x).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:151:21 + --> tests/ui-toml/float_cmp/test.rs:132:21 | LL | let _ = x * x == C * x; | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x * x - C * x).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:178:17 + --> tests/ui-toml/float_cmp/test.rs:150:17 + | +LL | let _ = f(1.0) == f(5.0); + | ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) - f(5.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:151:17 + | +LL | let _ = 1.0 == f(5.0); + | ^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(1.0 - f(5.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:152:17 + | +LL | let _ = f(1.0) + 1.0 != 5.0; + | ^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) + 1.0 - 5.0).abs() > error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:158:17 | LL | let _ = f(1.0) == f(5.0); | ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) - f(5.0)).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:180:17 + --> tests/ui-toml/float_cmp/test.rs:159:17 | LL | let _ = 1.0 == f(5.0); | ^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(1.0 - f(5.0)).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:182:17 + --> tests/ui-toml/float_cmp/test.rs:160:17 | LL | let _ = f(1.0) + 1.0 != 5.0; | ^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) + 1.0 - 5.0).abs() > error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:225:21 + --> tests/ui-toml/float_cmp/test.rs:202:21 | LL | let _ = x == C[1]; | ^^^^^^^^^ help: consider comparing them within some margin of error: `(x - C[1]).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:227:21 + --> tests/ui-toml/float_cmp/test.rs:203:21 | LL | let _ = C[1] == x; | ^^^^^^^^^ help: consider comparing them within some margin of error: `(C[1] - x).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:312:21 + --> tests/ui-toml/float_cmp/test.rs:287:21 | LL | let _ = x.next().unwrap() == x.next().unwrap() + 1.0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x.next().unwrap() - (x.next().unwrap() + 1.0)).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:329:21 + --> tests/ui-toml/float_cmp/test.rs:303:21 | LL | let _ = x.f() + 1.0 == x.f(); | ^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x.f() + 1.0 - x.f()).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:331:21 + --> tests/ui-toml/float_cmp/test.rs:304:21 | LL | let _ = x.f() == x.f() + 1.0; | ^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x.f() - (x.f() + 1.0)).abs() < error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:341:17 + --> tests/ui-toml/float_cmp/test.rs:313:17 | LL | let _ = f(1.0) == f(1.0) + 1.0; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) - (f(1.0) + 1.0)).abs() < error_margin` -error: aborting due to 31 previous errors +error: aborting due to 34 previous errors diff --git a/tests/ui-toml/float_cmp/test.named_const.stderr b/tests/ui-toml/float_cmp/test.named_const.stderr new file mode 100644 index 000000000000..eb49aff7b280 --- /dev/null +++ b/tests/ui-toml/float_cmp/test.named_const.stderr @@ -0,0 +1,254 @@ +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:15:21 + | +LL | let _ = x == y; + | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() < error_margin` + | +note: the lint level is defined here + --> tests/ui-toml/float_cmp/test.rs:9:9 + | +LL | #![deny(clippy::float_cmp)] + | ^^^^^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:16:21 + | +LL | let _ = x != y; + | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() > error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:17:21 + | +LL | let _ = x == 5.5; + | ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 5.5).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:18:21 + | +LL | let _ = 5.5 == x; + | ^^^^^^^^ help: consider comparing them within some margin of error: `(5.5 - x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:41:21 + | +LL | let _ = x == y; + | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:42:21 + | +LL | let _ = x != y; + | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() > error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:43:21 + | +LL | let _ = x == 5.5; + | ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 5.5).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:44:21 + | +LL | let _ = 5.5 == x; + | ^^^^^^^^ help: consider comparing them within some margin of error: `(5.5 - x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:67:21 + | +LL | let _ = x == y; + | ^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:68:21 + | +LL | let _ = x == [5.5; 4]; + | ^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:69:21 + | +LL | let _ = [5.5; 4] == x; + | ^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:70:21 + | +LL | let _ = [0.0, 0.0, 0.0, 5.5] == x; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:71:21 + | +LL | let _ = x == [0.0, 0.0, 0.0, 5.5]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:87:21 + | +LL | let _ = x == y; + | ^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:88:21 + | +LL | let _ = x == [5.5; 4]; + | ^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:89:21 + | +LL | let _ = [5.5; 4] == x; + | ^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:90:21 + | +LL | let _ = [0.0, 0.0, 0.0, 5.5] == x; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:91:21 + | +LL | let _ = x == [0.0, 0.0, 0.0, 5.5]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:109:21 + | +LL | let _ = x == y; + | ^^^^^^ help: consider comparing them within some margin of error: `(x - y).abs() < error_margin` + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:115:21 + | +LL | let _ = x == y; + | ^^^^^^ + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:124:21 + | +LL | let _ = x == C; + | ^^^^^^ help: consider comparing them within some margin of error: `(x - C).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:125:21 + | +LL | let _ = C == x; + | ^^^^^^ help: consider comparing them within some margin of error: `(C - x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:126:21 + | +LL | let _ = &&x == &&C; + | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(&&x - &&C).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:127:21 + | +LL | let _ = &&C == &&x; + | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(&&C - &&x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:128:21 + | +LL | let _ = y == C as f64; + | ^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(y - C as f64).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:129:21 + | +LL | let _ = C as f64 == y; + | ^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(C as f64 - y).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:131:21 + | +LL | let _ = C * x == x * x; + | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(C * x - x * x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:132:21 + | +LL | let _ = x * x == C * x; + | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x * x - C * x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:138:21 + | +LL | let _ = x == C; + | ^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:139:21 + | +LL | let _ = C == x; + | ^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:140:21 + | +LL | let _ = &&x == &&C; + | ^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` arrays + --> tests/ui-toml/float_cmp/test.rs:141:21 + | +LL | let _ = &&C == &&x; + | ^^^^^^^^^^ + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:158:17 + | +LL | let _ = f(1.0) == f(5.0); + | ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) - f(5.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:159:17 + | +LL | let _ = 1.0 == f(5.0); + | ^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(1.0 - f(5.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:160:17 + | +LL | let _ = f(1.0) + 1.0 != 5.0; + | ^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) + 1.0 - 5.0).abs() > error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:202:21 + | +LL | let _ = x == C[1]; + | ^^^^^^^^^ help: consider comparing them within some margin of error: `(x - C[1]).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:203:21 + | +LL | let _ = C[1] == x; + | ^^^^^^^^^ help: consider comparing them within some margin of error: `(C[1] - x).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:287:21 + | +LL | let _ = x.next().unwrap() == x.next().unwrap() + 1.0; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x.next().unwrap() - (x.next().unwrap() + 1.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:303:21 + | +LL | let _ = x.f() + 1.0 == x.f(); + | ^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x.f() + 1.0 - x.f()).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:304:21 + | +LL | let _ = x.f() == x.f() + 1.0; + | ^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x.f() - (x.f() + 1.0)).abs() < error_margin` + +error: strict comparison of `f32` or `f64` + --> tests/ui-toml/float_cmp/test.rs:313:17 + | +LL | let _ = f(1.0) == f(1.0) + 1.0; + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) - (f(1.0) + 1.0)).abs() < error_margin` + +error: aborting due to 41 previous errors + diff --git a/tests/ui/float_cmp.rs b/tests/ui-toml/float_cmp/test.rs similarity index 61% rename from tests/ui/float_cmp.rs rename to tests/ui-toml/float_cmp/test.rs index 25ed439753a6..443064b45733 100644 --- a/tests/ui/float_cmp.rs +++ b/tests/ui-toml/float_cmp/test.rs @@ -1,21 +1,21 @@ //@no-rustfix +//@revisions: change_detect const_cmp named_const +//@[change_detect] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/float_cmp/change_detect +//@[const_cmp] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/float_cmp/const_cmp +//@[named_const] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/float_cmp/named_const // FIXME(f16_f128): const casting is not yet supported for these types. Add when available. -#![warn(clippy::float_cmp)] +#![deny(clippy::float_cmp)] #![allow(clippy::op_ref, clippy::eq_op)] fn main() { { fn _f(x: f32, y: f32) { - let _ = x == y; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = x != y; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = x == 5.5; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = 5.5 == x; - //~^ ERROR: strict comparison of `f32` or `f64` + let _ = x == y; //~ float_cmp + let _ = x != y; //~ float_cmp + let _ = x == 5.5; //~ float_cmp + let _ = 5.5 == x; //~ float_cmp let _ = x < 5.5; let _ = x <= 5.5; @@ -38,14 +38,10 @@ fn main() { } { fn _f(x: f64, y: f64) { - let _ = x == y; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = x != y; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = x == 5.5; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = 5.5 == x; - //~^ ERROR: strict comparison of `f32` or `f64` + let _ = x == y; //~ float_cmp + let _ = x != y; //~ float_cmp + let _ = x == 5.5; //~ float_cmp + let _ = 5.5 == x; //~ float_cmp let _ = x < 5.5; let _ = x <= 5.5; @@ -68,16 +64,11 @@ fn main() { } { fn _f(x: [f32; 4], y: [f32; 4]) { - let _ = x == y; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = x == [5.5; 4]; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = [5.5; 4] == x; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = [0.0, 0.0, 0.0, 5.5] == x; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = x == [0.0, 0.0, 0.0, 5.5]; - //~^ ERROR: strict comparison of `f32` or `f64` + let _ = x == y; //~ float_cmp + let _ = x == [5.5; 4]; //~ float_cmp + let _ = [5.5; 4] == x; //~ float_cmp + let _ = [0.0, 0.0, 0.0, 5.5] == x; //~ float_cmp + let _ = x == [0.0, 0.0, 0.0, 5.5]; //~ float_cmp let _ = [0.0; 4] == x; let _ = [-0.0; 4] == x; @@ -93,16 +84,11 @@ fn main() { } { fn _f(x: [f64; 4], y: [f64; 4]) { - let _ = x == y; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = x == [5.5; 4]; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = [5.5; 4] == x; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = [0.0, 0.0, 0.0, 5.5] == x; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = x == [0.0, 0.0, 0.0, 5.5]; - //~^ ERROR: strict comparison of `f32` or `f64` + let _ = x == y; //~ float_cmp + let _ = x == [5.5; 4]; //~ float_cmp + let _ = [5.5; 4] == x; //~ float_cmp + let _ = [0.0, 0.0, 0.0, 5.5] == x; //~ float_cmp + let _ = x == [0.0, 0.0, 0.0, 5.5]; //~ float_cmp let _ = [0.0; 4] == x; let _ = [-0.0; 4] == x; @@ -120,17 +106,13 @@ fn main() { // Reference comparisons { fn _f(x: &&&f32, y: &&&f32) { - let _ = x == y; - //~^ ERROR: strict comparison of `f32` or `f64` - + let _ = x == y; //~ float_cmp let _ = x == &&&0.0; } } { fn _f(x: &&&[f32; 2], y: &&&[f32; 2]) { - let _ = x == y; - //~^ ERROR: strict comparison of `f32` or `f64` - + let _ = x == y; //~ float_cmp let _ = x == &&&[0.0, -0.0]; } } @@ -139,26 +121,24 @@ fn main() { { const C: f32 = 5.5; fn _f(x: f32, y: f64) { - let _ = x == C; - let _ = C == x; - let _ = &&x == &&C; - let _ = &&C == &&x; - let _ = y == C as f64; - let _ = C as f64 == y; - - let _ = C * x == x * x; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = x * x == C * x; - //~^ ERROR: strict comparison of `f32` or `f64` + let _ = x == C; //~[named_const] float_cmp + let _ = C == x; //~[named_const] float_cmp + let _ = &&x == &&C; //~[named_const] float_cmp + let _ = &&C == &&x; //~[named_const] float_cmp + let _ = y == C as f64; //~[named_const] float_cmp + let _ = C as f64 == y; //~[named_const] float_cmp + + let _ = C * x == x * x; //~ float_cmp + let _ = x * x == C * x; //~ float_cmp } } { const C: [f32; 2] = [5.5, 5.5]; fn _f(x: [f32; 2]) { - let _ = x == C; - let _ = C == x; - let _ = &&x == &&C; - let _ = &&C == &&x; + let _ = x == C; //~[named_const] float_cmp + let _ = C == x; //~[named_const] float_cmp + let _ = &&x == &&C; //~[named_const] float_cmp + let _ = &&C == &&x; //~[named_const] float_cmp } } @@ -167,20 +147,17 @@ fn main() { const fn f(x: f32) -> f32 { todo!() } - let _ = f(1.0) == f(5.0); - let _ = 1.0 == f(5.0); - let _ = f(1.0) + 1.0 != 5.0; + let _ = f(1.0) == f(5.0); //~[const_cmp] float_cmp + let _ = 1.0 == f(5.0); //~[const_cmp] float_cmp + let _ = f(1.0) + 1.0 != 5.0; //~[const_cmp] float_cmp } { fn f(x: f32) -> f32 { todo!() } - let _ = f(1.0) == f(5.0); - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = 1.0 == f(5.0); - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = f(1.0) + 1.0 != 5.0; - //~^ ERROR: strict comparison of `f32` or `f64` + let _ = f(1.0) == f(5.0); //~ float_cmp + let _ = 1.0 == f(5.0); //~ float_cmp + let _ = f(1.0) + 1.0 != 5.0; //~ float_cmp } // Pointer equality @@ -222,10 +199,8 @@ fn main() { let _ = C[0] == x; let _ = C[2] == x; - let _ = x == C[1]; - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = C[1] == x; - //~^ ERROR: strict comparison of `f32` or `f64` + let _ = x == C[1]; //~ float_cmp + let _ = C[1] == x; //~ float_cmp } } @@ -284,33 +259,32 @@ fn main() { } fn _f(x: f32, y: f32) { - let _ = x == x + 1.0; - let _ = x + 1.0 == x; - let _ = -x == -x + 1.0; - let _ = -x + 1.0 == -x; - let _ = x == f1(x); - let _ = f1(x) == x; - let _ = x == f2(x, y); - let _ = f2(x, y) == x; - let _ = f1(f1(x)) == f1(x); - let _ = f1(x) == f1(f1(x)); + let _ = x == x + 1.0; //~[change_detect] float_cmp + let _ = x + 1.0 == x; //~[change_detect] float_cmp + let _ = -x == -x + 1.0; //~[change_detect] float_cmp + let _ = -x + 1.0 == -x; //~[change_detect] float_cmp + let _ = x == f1(x); //~[change_detect] float_cmp + let _ = f1(x) == x; //~[change_detect] float_cmp + let _ = x == f2(x, y); //~[change_detect] float_cmp + let _ = f2(x, y) == x; //~[change_detect] float_cmp + let _ = f1(f1(x)) == f1(x); //~[change_detect] float_cmp + let _ = f1(x) == f1(f1(x)); //~[change_detect] float_cmp let z = (x, y); - let _ = z.0 == z.0 + 1.0; - let _ = z.0 + 1.0 == z.0; + let _ = z.0 == z.0 + 1.0; //~[change_detect] float_cmp + let _ = z.0 + 1.0 == z.0; //~[change_detect] float_cmp } fn _f2(x: &f32) { - let _ = *x + 1.0 == *x; - let _ = *x == *x + 1.0; - let _ = *x == f1(*x); - let _ = f1(*x) == *x; + let _ = *x + 1.0 == *x; //~[change_detect] float_cmp + let _ = *x == *x + 1.0; //~[change_detect] float_cmp + let _ = *x == f1(*x); //~[change_detect] float_cmp + let _ = f1(*x) == *x; //~[change_detect] float_cmp } } { fn _f(mut x: impl Iterator) { - let _ = x.next().unwrap() == x.next().unwrap() + 1.0; - //~^ ERROR: strict comparison of `f32` or `f64` + let _ = x.next().unwrap() == x.next().unwrap() + 1.0; //~ float_cmp } } { @@ -326,10 +300,8 @@ fn main() { } fn _f(x: S) { - let _ = x.f() + 1.0 == x.f(); - //~^ ERROR: strict comparison of `f32` or `f64` - let _ = x.f() == x.f() + 1.0; - //~^ ERROR: strict comparison of `f32` or `f64` + let _ = x.f() + 1.0 == x.f(); //~ float_cmp + let _ = x.f() == x.f() + 1.0; //~ float_cmp } } { diff --git a/tests/ui-toml/float_cmp_change_detection/test.rs b/tests/ui-toml/float_cmp_change_detection/test.rs deleted file mode 100644 index c16776e104e3..000000000000 --- a/tests/ui-toml/float_cmp_change_detection/test.rs +++ /dev/null @@ -1,40 +0,0 @@ -//@no-rustfix - -#![deny(clippy::float_cmp)] -#![allow(clippy::op_ref, clippy::eq_op)] - -fn main() { - { - const C: f64 = 1.0; - fn f(x: f64) { - let _ = x == C; - } - } - { - const fn f(x: f64) -> f64 { - todo!() - } - let _ = f(1.0) == f(2.0); - } - { - let _ = 1.0f32 == 2.0f32; - let _ = -1.0f32 == -2.0f32; - let _ = 1.0f64 == 2.0f64; - } - { - fn f(x: f32) { - let _ = x + 1.0 == x; - let _ = x == x + 1.0; - } - } - { - fn _f(x: f32) { - let _ = x == x; - let _ = x != x; - let _ = x == -x; - let _ = -x == x; - let _ = x as f64 == x as f64; - let _ = &&x == &&x; - } - } -} diff --git a/tests/ui-toml/float_cmp_change_detection/test.stderr b/tests/ui-toml/float_cmp_change_detection/test.stderr deleted file mode 100644 index 7bbe9713f56a..000000000000 --- a/tests/ui-toml/float_cmp_change_detection/test.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: strict comparison of `f32` or `f64` - --> tests/ui-toml/float_cmp_change_detection/test.rs:26:21 - | -LL | let _ = x + 1.0 == x; - | ^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x + 1.0 - x).abs() < error_margin` - | -note: the lint level is defined here - --> tests/ui-toml/float_cmp_change_detection/test.rs:3:9 - | -LL | #![deny(clippy::float_cmp)] - | ^^^^^^^^^^^^^^^^^ - -error: strict comparison of `f32` or `f64` - --> tests/ui-toml/float_cmp_change_detection/test.rs:27:21 - | -LL | let _ = x == x + 1.0; - | ^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x - (x + 1.0)).abs() < error_margin` - -error: aborting due to 2 previous errors - diff --git a/tests/ui-toml/float_cmp_constant_comparisons/test.rs b/tests/ui-toml/float_cmp_constant_comparisons/test.rs deleted file mode 100644 index c16776e104e3..000000000000 --- a/tests/ui-toml/float_cmp_constant_comparisons/test.rs +++ /dev/null @@ -1,40 +0,0 @@ -//@no-rustfix - -#![deny(clippy::float_cmp)] -#![allow(clippy::op_ref, clippy::eq_op)] - -fn main() { - { - const C: f64 = 1.0; - fn f(x: f64) { - let _ = x == C; - } - } - { - const fn f(x: f64) -> f64 { - todo!() - } - let _ = f(1.0) == f(2.0); - } - { - let _ = 1.0f32 == 2.0f32; - let _ = -1.0f32 == -2.0f32; - let _ = 1.0f64 == 2.0f64; - } - { - fn f(x: f32) { - let _ = x + 1.0 == x; - let _ = x == x + 1.0; - } - } - { - fn _f(x: f32) { - let _ = x == x; - let _ = x != x; - let _ = x == -x; - let _ = -x == x; - let _ = x as f64 == x as f64; - let _ = &&x == &&x; - } - } -} diff --git a/tests/ui-toml/float_cmp_constant_comparisons/test.stderr b/tests/ui-toml/float_cmp_constant_comparisons/test.stderr deleted file mode 100644 index 7f6db02b485d..000000000000 --- a/tests/ui-toml/float_cmp_constant_comparisons/test.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: strict comparison of `f32` or `f64` - --> tests/ui-toml/float_cmp_constant_comparisons/test.rs:17:17 - | -LL | let _ = f(1.0) == f(2.0); - | ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(f(1.0) - f(2.0)).abs() < error_margin` - | -note: the lint level is defined here - --> tests/ui-toml/float_cmp_constant_comparisons/test.rs:3:9 - | -LL | #![deny(clippy::float_cmp)] - | ^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui-toml/float_cmp_named_constants/test.rs b/tests/ui-toml/float_cmp_named_constants/test.rs deleted file mode 100644 index c16776e104e3..000000000000 --- a/tests/ui-toml/float_cmp_named_constants/test.rs +++ /dev/null @@ -1,40 +0,0 @@ -//@no-rustfix - -#![deny(clippy::float_cmp)] -#![allow(clippy::op_ref, clippy::eq_op)] - -fn main() { - { - const C: f64 = 1.0; - fn f(x: f64) { - let _ = x == C; - } - } - { - const fn f(x: f64) -> f64 { - todo!() - } - let _ = f(1.0) == f(2.0); - } - { - let _ = 1.0f32 == 2.0f32; - let _ = -1.0f32 == -2.0f32; - let _ = 1.0f64 == 2.0f64; - } - { - fn f(x: f32) { - let _ = x + 1.0 == x; - let _ = x == x + 1.0; - } - } - { - fn _f(x: f32) { - let _ = x == x; - let _ = x != x; - let _ = x == -x; - let _ = -x == x; - let _ = x as f64 == x as f64; - let _ = &&x == &&x; - } - } -} diff --git a/tests/ui-toml/float_cmp_named_constants/test.stderr b/tests/ui-toml/float_cmp_named_constants/test.stderr deleted file mode 100644 index 74036b354cd6..000000000000 --- a/tests/ui-toml/float_cmp_named_constants/test.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: strict comparison of `f32` or `f64` - --> tests/ui-toml/float_cmp_named_constants/test.rs:10:21 - | -LL | let _ = x == C; - | ^^^^^^ help: consider comparing them within some margin of error: `(x - C).abs() < error_margin` - | -note: the lint level is defined here - --> tests/ui-toml/float_cmp_named_constants/test.rs:3:9 - | -LL | #![deny(clippy::float_cmp)] - | ^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error -