rust-lang / rust-lang/rust-clippy
Consequences of ptr_arg
Open
Nobody has claimed this yet.
C-enhancement
E-medium
T-AST
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Currently, following ptr_arg can lead to errors, if
- the function is used as a
Fnreference (fn foo(&Vec<u8>) { .. }; let foo : Fn(&Vec<u8>) = foo) - the function calls another function that expects a
&Vecreference.
We could extend the lint to
- check the whole crate if the function is referenced anywhere (we obviously cannot check across crate boundaries, but I guess, that'll be OK.
- look into the function and check the signatures of the contained calls; if those are only functions within the crate, note if those are eligible for
ptr_arg, otherwise don't lint. We should also bail on out-of-crate functions.
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 by locating the ptr_arg lint and its existing tests. Review how function references and calls are analyzed, then assess crate-wide references and in-crate call signatures while preserving the stated bailout for out-of-crate functions. Done means the lint avoids these false positives and has coverage for both listed cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100