Skip to content

manual_mul_add suggests broken code #4726

Closed
@matthiaskrgr

Description

@matthiaskrgr
let x = f64::from(32) + 2.0 * 4.0;

clippy suggests

warning: consider using mul_add() for better numerical precision
 --> src/main.rs:3:10
  |
3 |     let x = f64::from(32) + 2.0 * 4.0;
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `2.0.mul_add(4.0, f64::from(32))`
  |

but

	 let x = 2.0.mul_add(4.0, f64::from(32));

does not compile:

error[E0599]: no method named `mul_add` found for type `{float}` in the current scope
 --> src/main.rs:4:15
  |
4 |      let x = 2.0.mul_add(4.0, f64::from(32));
  |                  ^^^^^^^ method not found in `{float}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions