Closed
Description
Summary
I like using as_conversions as a catch-all guard to stop myself from reaching for it in my own code when better solutions are available. However, it triggers on the generated derive code too, e.g. when using serde-repr.
Worse, it can't even be disabled by putting #[allow(clippy::as_conversions)]
on the offending type, as it doesn't propagate to the derive-generated code, so the only option is to opt-out at the module level.
Lint Name
as_conversions
Reproducer
I tried this code:
#![warn(clippy::as_conversions)]
use serde_repr::{Deserialize_repr, Serialize_repr};
#[derive(Serialize_repr, Deserialize_repr)]
#[repr(i32)]
pub enum State {
Error = -1,
Idle = 0,
Waiting = 1,
Done = 2,
}
I saw this happen:
using a potentially dangerous silent `as` conversion
consider using a safe wrapper for this conversion
for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#as_conversions
I expected to see this happen:
(no warning, as the as
conversion is used internally by an external crate)
Version
rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: x86_64-pc-windows-msvc
release: 1.64.0
LLVM version: 14.0.6
Additional Labels
@rustbot label +T-macros