Skip to content

clippy::neg_multiply results in inconsistent code #15139

@pacak

Description

@pacak

Summary

I'm not sure if it's false positive or false negative. I'm okay with having it either way as long as it is uniform

Lint Name

clippy::neg_multiply

Reproducer

I tried this code:

pub const KNOTS: [f64; NUM_KNOTS] = [
    -3.0 * SCALE,
    -1.0 * SCALE,
    1.0 * SCALE,
    3.0 * SCALE,
];

I saw this happen:

clippy suggested to replace second constant with -SCALE but left everything as is.

I expected to see this happen:

Either leave things as is OR fix the third constant as well.

This is from pre-release testing version of 1.88

Version

rustc 1.88.0 (6b00bc388 2025-06-23)
binary: rustc
commit-hash: 6b00bc3880198600130e1cf62b8f8a93494488cc
commit-date: 2025-06-23
host: x86_64-unknown-linux-gnu
release: 1.88.0
LLVM version: 20.1.5

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions