rust-lang / rust-lang/rust-clippy
not_unsafe_ptr_arg_deref does not trigger on type aliases and trait methods
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
If the raw pointer is used behind a type alias or the function is part of a trait, not_unsafe_ptr_arg_deref is not triggered.
Lint Name
not_unsafe_ptr_arg_deref
Reproducer
I tried this code:
trait Bad {
fn f(x: *const u8) -> u8 {
unsafe { *x }
}
}
type Alias = *const u8;
pub fn bad(x: Alias) -> u8 {
unsafe { *x }
}
pub fn main() {
bad(0 as _);
}
I expected to see this happen: Lint for not_unsafe_ptr_arg_deref is triggered
Instead, this happened: Lint is not triggered
Version
No response
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
Run the linked Playground reproducer and inspect the not_unsafe_ptr_arg_deref lint entry point. Compare the raw-pointer cases involving the type alias and trait method with the existing behavior; done means the lint triggers for both cases without regressing the current lint behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100