diff options
| author | Catherine <114838443+Centri3@users.noreply.github.com> | 2023-06-30 11:31:08 -0500 |
|---|---|---|
| committer | Catherine <114838443+Centri3@users.noreply.github.com> | 2023-07-06 20:27:21 -0500 |
| commit | f12edfdb53b13008dcff9eba2a3fd9a19370d2ee (patch) | |
| tree | d021e96ce7d4b54a29acadb55bf07a549fc8e229 /tests/ui/manual_float_methods.fixed | |
| parent | dd8e44c5a22ab646821252604420c5bb82c36aa9 (diff) | |
`manual_float_methods`
Diffstat (limited to 'tests/ui/manual_float_methods.fixed')
| -rw-r--r-- | tests/ui/manual_float_methods.fixed | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/ui/manual_float_methods.fixed b/tests/ui/manual_float_methods.fixed new file mode 100644 index 00000000000..87a23b5a75b --- /dev/null +++ b/tests/ui/manual_float_methods.fixed @@ -0,0 +1,37 @@ +//@run-rustfix +//@aux-build:proc_macros.rs:proc-macro +#![allow(clippy::needless_if, unused)] +#![warn(clippy::manual_is_infinite, clippy::manual_is_finite)] + +#[macro_use] +extern crate proc_macros; + +const INFINITE: f32 = f32::INFINITY; +const NEG_INFINITE: f32 = f32::NEG_INFINITY; + +fn main() { + let x = 1.0f32; + if x.is_infinite() {} + if x.is_finite() {} + if x.is_infinite() {} + if x.is_finite() {} + let x = 1.0f64; + if x.is_infinite() {} + if x.is_finite() {} + // Don't lint + if x.is_infinite() {} + if x.is_finite() {} + // If they're doing it this way, they probably know what they're doing + if x.abs() < f64::INFINITY {} + external! { + let x = 1.0; + if x == f32::INFINITY || x == f32::NEG_INFINITY {} + if x != f32::INFINITY && x != f32::NEG_INFINITY {} + } + with_span! { + span + let x = 1.0; + if x == f32::INFINITY || x == f32::NEG_INFINITY {} + if x != f32::INFINITY && x != f32::NEG_INFINITY {} + } +} |
