Skip to content

suboptimal_flops missing mul_add opportunities in AddAssign and SubAssign expressions #16573

@OverwrittenCode

Description

@OverwrittenCode

Summary

Clippy is able to flag these:

  • a = a + (b * c)
  • a = a - (b * c)

but not their shortform equivalent using the AddAssign/SubAssign operators += and -=, respectively.

Lint Name

suboptimal_flops

Reproducer

I tried this code:

fn main() {
    let mut a = 3.0_f32;
    let b = 4.0_f32;
    let c = 7.0_f32;

    a += b * c;

    println!("{}", a);
}

I expected to see this happen:
Clippy flags with "multiply and add expressions can be calculated more efficiently and accurately"

Instead, this happened:
Nothing happens.

Version

rustc 1.95.0-nightly (d222ddc4d 2026-01-23)
binary: rustc
commit-hash: d222ddc4d90743dfc1e53b610be8fc9d95893d2c
commit-date: 2026-01-23
host: x86_64-pc-windows-msvc
release: 1.95.0-nightly
LLVM version: 21.1.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions