Skip to content
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

clippy suggests40..to_radians() which is a compile error #7651

Closed
Volker-Weissmann opened this issue Sep 9, 2021 · 2 comments · Fixed by #8187
Closed

clippy suggests40..to_radians() which is a compile error #7651

Volker-Weissmann opened this issue Sep 9, 2021 · 2 comments · Fixed by #8187
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@Volker-Weissmann
Copy link

Volker-Weissmann commented Sep 9, 2021

use std::f64::consts::PI;
fn main() {
    40. * PI / 180.;
}

cargo clippy -- -W clippy::nursery

warning: conversion to radians can be done more accurately
 --> src/main.rs:3:5
  |
3 |     40. * PI / 180.;
  |     ^^^^^^^^^^^^^^^ help: consider using: `40..to_radians()`
  |
  = note: `-W clippy::suboptimal-flops` implied by `-W clippy::nursery`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suboptimal_flops

Clippy suggests 40..to_radians(), which is a compile-error. 40_f64.to_radians() would be correct.

Slightly OT: This bug seems to be catchable by a fuzzer that verifies that clippy never suggest introducing compiler errors into code that compiles.

Meta

Rust version (rustc -Vv):

rustc 1.55.0-nightly (ce1d5611a 2021-06-18)
binary: rustc
commit-hash: ce1d5611a28468663e275078649e7ca6eef735a8
commit-date: 2021-06-18
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1

@rustbot label +suggestion-causes-error

@Volker-Weissmann Volker-Weissmann added the C-bug Category: Clippy is not doing the correct thing label Sep 9, 2021
@rustbot

This comment has been minimized.

@giraffate giraffate added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Sep 10, 2021
@giraffate giraffate added the good-first-issue These issues are a good way to get started with Clippy label Oct 15, 2021
@Dmitry-Borodin
Copy link
Contributor

Reproduced it in current latest stable toolchain (rustc 1.55.0)
I will try to solve it in a next few days.
@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 good-first-issue These issues are a good way to get started with Clippy I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants