rust-lang / rust-lang/rust-clippy
`transmutes_expressible_as_ptr_casts` does not detect reference-to-usize transmutes
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
Clippy by default lints against transmuting raw pointers to usize. However, it does not lint against transmuting references to usize. Both of these transmutes are highly questionable so it'd be good to lint them all.
Lint Name
transmutes_expressible_as_ptr_casts
Reproducer
I tried this code:
fn main() { unsafe {
let _x: usize = std::mem::transmute(&0);
}}
I expected to see this happen: clippy should complain about the transmute.
Instead, this happened: clippy remains silent.
Version
Current playground
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 at the transmutes_expressible_as_ptr_casts lint and reproduce the reference-to-usize example from the issue. Done means the lint reports this transmute, while continuing to handle the raw-pointer case already described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100