Skip to content

suboptimal_flops in const functions #8004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
leonardo-m opened this issue Nov 20, 2021 · 1 comment · Fixed by #8009
Closed

suboptimal_flops in const functions #8004

leonardo-m opened this issue Nov 20, 2021 · 1 comment · Fixed by #8009
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@leonardo-m
Copy link

leonardo-m commented Nov 20, 2021

On this code:

#![feature(const_fn_floating_point_arithmetic)]
#![allow(dead_code)]

#![warn(clippy::nursery)]

const fn mul_add(a: f32, b: f32, c: f32) -> f32 { a * b + c }

fn main() {}

Clippy gives me:

Checking foo1 v0.1.0 (...\foo1)
warning: multiply and add expressions can be calculated more efficiently and accurately
 --> src\main.rs:6:51
  |
6 | const fn mul_add(a: f32, b: f32, c: f32) -> f32 { a * b + c }
  |                                                   ^^^^^^^^^ help: consider using: `a.mul_add(b, c)`
  |
note: the lint level is defined here
 --> src\main.rs:4:9
  |
4 | #![warn(clippy::nursery)]
  |         ^^^^^^^^^^^^^^^
  = note: `#[warn(clippy::suboptimal_flops)]` implied by `#[warn(clippy::nursery)]`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suboptimal_flops

But currently mul_add doesn't work in const functions.

@leonardo-m leonardo-m added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Nov 20, 2021
@xFrednet
Copy link
Member

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants