-
Notifications
You must be signed in to change notification settings - Fork 2k
"square can be computed more efficiently" is wrong #7058
Copy link
Copy link
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Type
Fields
Give feedbackNo fields configured for issues without a type.
Lint name:
suboptimal_flopsI tried this code:
I expected to see this happen: it should pass.
Instead, this happened: it says "square can be computed more efficiently" and suggests to use
x * xinstead.This is incorrect, because, unlike
powf,powiproduces exactly same native code asx * x, and is more natural to read (IMO). If anything, due to usage of intrinsic, it might be optimised even more than bare expression, although they're unlikely to be different on practice.Meta
cargo clippy -V: clippy 0.1.53 (2e495d2 2021-04-08)rustc -Vv: