Fixes: rust-lang/rust-clippy#14897, rust-lang/rust-clippy#10015 This is not a perfect solution, but it fixes the issue. Happy to discuss further with the clippy team. This PR refines check_mul_add to avoid false positives on ambiguous float types (e.g., f32 vs f64). It improves type detection and ensures mul_add is only suggested when the type is clear. Changes: - Improved detection of ambiguous float types - Refined mul_add suggestion logic - Added tests for ambiguous cases ## Example Before this change, expressions like: ```rust let x = 1.0; // ambiguous type let _ = x * 2.0 + 0.5; // could incorrectly suggest mul_add ``` ---- changelog: [`suboptimal_flops`]: improve handling of ambiguous float types in mul_add suggestions |
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| README.md | ||
clippy-utils
Helpful tools for writing lints, provided as they are used in Clippy.
Usage
This crate is only guaranteed to build with this nightly toolchain:
nightly-2025-06-26
To use clippy-utils in your lint, add the following to your Cargo.toml:
clippy_utils = "0.1.XY"
XY is the version of the nightly toolchain above and can be determined with rustc +nightly-YYYY-MM-DD -V.
⚠️ Stability ⚠️
No stability guarantees are made for this crate! Use at your own risk.
Function signatures can change or be removed without replacement without any prior notice.
LICENSE
Copyright 2014-2025 The Rust Project Developers
Licensed under the Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> or the MIT license <https://opensource.org/licenses/MIT>, at your option. Files in the project may not be copied, modified, or distributed except according to those terms.