Open
Description
Summary
Under certain circumstances, clippy does not detect unnecessary casts when rust-src
is installed, whereas it does accurately detect them when that component is removed.
Lint Name
unnecessary_cast
Reproducer
I tried this code:
pub struct Foo(i32);
pub fn clippy_failure() {
let a: Foo = std::convert::identity(Foo(0));
let _ = a.0 as i32;
}
I expected to see this happen:
warning: casting to the same type is unnecessary (`i32` -> `i32`)
--> src/lib.rs:5:13
|
5 | let _ = a.0 as i32;
| ^^^^^^^^^^ help: try: `a.0`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
= note: `#[warn(clippy::unnecessary_cast)]` on by default
Instead, this happened:
There is no such output when component rust-src
is installed, but when not installed the output matches above.
Version
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-pc-windows-msvc
release: 1.86.0
LLVM version: 19.1.7