rust-lang / rust-lang/rust-clippy
`unnecessary_cast`: `core::ffi::c_*` cases
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
unnecessary_cast's does not cover some cases around core::ffi::c_* types that it could.
Lint Name
unnecessary_cast
Reproducer
I tried this code:
let x = 42;
let _ = x as core::ffi::c_int as core::ffi::c_int;
I expected to see this happen: lint triggers (e.g. "warning: casting to the same type is unnecessary (core::ffi::c_int -> core::ffi::c_int)").
Instead, this happened: lint does not trigger.
Version
rustc 1.83.0-nightly (18b1161ec 2024-10-02)
binary: rustc
commit-hash: 18b1161ec9eeab8927f91405bca0ddf59a4a26c9
commit-date: 2024-10-02
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Clippy's unnecessary_cast lint and the reproducer in this issue, then locate the lint implementation and its regression tests. The work is done when the shown core::ffi::c_int cast chain triggers the expected warning and the behavior is covered by a test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100