Skip to content

fix: [suboptimal_flops] false negative with ambiguous float literals#16980

Merged
rustbot merged 1 commit into
rust-lang:masterfrom
Kokoro2336:fix/suboptimal-flops
Jul 12, 2026
Merged

fix: [suboptimal_flops] false negative with ambiguous float literals#16980
rustbot merged 1 commit into
rust-lang:masterfrom
Kokoro2336:fix/suboptimal-flops

Conversation

@Kokoro2336

@Kokoro2336 Kokoro2336 commented May 9, 2026

Copy link
Copy Markdown
Contributor

changelog: [suboptimal_flops] false negative with ambiguous float literals

Fixes #16954

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 9, 2026
@rustbot

rustbot commented May 9, 2026

Copy link
Copy Markdown
Collaborator

r? @llogiq

rustbot has assigned @llogiq.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, llogiq, samueltardieu

@Kokoro2336

Copy link
Copy Markdown
Contributor Author

I've noticed that the former version of suboptimal_flops doesn't lint any pattern with ambiguous float literal. After the fixing, all of them could be fixed automatically. For non-literal recv with ambiguous type, I call mul_add through the inferred type instead of emitting a method call, since adding type annotation to the source def could be complex.

@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown

Lintcheck changes for ee0e5a5

Lint Added Removed Changed
clippy::suboptimal_flops 4 0 2

This comment will be updated if you push new changes

@Kokoro2336

Copy link
Copy Markdown
Contributor Author

I don't know whether f64::mul_add() could be received as readable and obvious. If not, we can downgrade the Applicability as an alternative too when this case occur.

@Kokoro2336

Copy link
Copy Markdown
Contributor Author

r? @Jarcho

@rustbot rustbot assigned Jarcho and unassigned llogiq May 13, 2026
@rustbot

This comment has been minimized.

@Jarcho Jarcho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not, in general, select a specific reviewer unless they've indicated otherwise.

View changes since this review

Comment thread clippy_lints/src/floating_point_arithmetic/mul_add.rs Outdated
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jun 17, 2026
@rustbot

rustbot commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@Kokoro2336
Kokoro2336 force-pushed the fix/suboptimal-flops branch from a7972b0 to f554233 Compare June 17, 2026 14:26
@rustbot

This comment has been minimized.

@Kokoro2336

Copy link
Copy Markdown
Contributor Author

@Jarcho Sorry about that, I would follow the rules in the future. Now the suggestion has been applied. @rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Jun 17, 2026
@Kokoro2336
Kokoro2336 force-pushed the fix/suboptimal-flops branch from f554233 to 1891a45 Compare June 17, 2026 14:37
@rustbot

rustbot commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Kokoro2336
Kokoro2336 force-pushed the fix/suboptimal-flops branch from 1891a45 to 895f55c Compare June 18, 2026 03:57
@Kokoro2336
Kokoro2336 requested a review from Jarcho June 18, 2026 04:08
Comment thread clippy_lints/src/floating_point_arithmetic/mul_add.rs Outdated
Comment thread clippy_utils/src/hir_utils.rs Outdated
Comment thread clippy_lints/src/floating_point_arithmetic/mul_add.rs Outdated
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jun 19, 2026
test: supply test for issue 16954.

fix: suggest MethodCall for expr with type anchor.

fix: remove redudant is_lit check.

fix: missing parenthesis for a * b.

fix: remove redundant lit check.
@Kokoro2336
Kokoro2336 force-pushed the fix/suboptimal-flops branch from 895f55c to ee0e5a5 Compare June 19, 2026 14:56
@Kokoro2336

Copy link
Copy Markdown
Contributor Author

@Jarcho Done @rustbot ready

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) label Jun 19, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 19, 2026
@Kokoro2336
Kokoro2336 requested a review from Jarcho June 25, 2026 15:01

@Jarcho Jarcho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rustbot
rustbot added this pull request to the merge queue Jul 12, 2026
Merged via the queue into rust-lang:master with commit 2f32ccf Jul 12, 2026
11 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 12, 2026
@Kokoro2336
Kokoro2336 deleted the fix/suboptimal-flops branch July 12, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

suboptimal_flops false negative: type inference/literals break expression tracking across let bindings

4 participants