rust-lang / rust-lang/rust-clippy

Consequences of ptr_arg

Open
#846 2 comments 0 reactions 0 assignees View on GitHub

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 Fn reference (fn foo(&Vec<u8>) { .. }; let foo : Fn(&Vec<u8>) = foo)
  • the function calls another function that expects a &Vec reference.

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.