rust-lang / rust-lang/rust-clippy
restriction lint: `indirect_derive`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
when enabled, this would produce a warning and suggestion whenever referring to a derive macro through a reexport instead of via the original package.
(optionally this would only trigger if the reexport is behind a feature flag, but i'm not sure how feasible that is)
Advantage
Enabling a derive feature flag has a slight overhead on compile times as it linearizes the dependency tree.
For example, building serde with the derive feature enabled means that serde and serde_derive can't be built in parallel.
This is something that often is done internally in the rust project, see https://github.com/rust-lang/rust/pull/141989.
There is currently no automated way to refactor this, as it requires a level of namespace awareness that most (all?) IDEs lack.
Drawbacks
Some library crates may not want their _derive crates to be part of the public API for semver reasons.
May require adding a new entry to Cargo.toml
Example
use serde::Deserialize;
#[derive(Deserialize)]
struct Foo;
...
Could be written as:
use serde::Deserialize;
#[derive(serde_derive::Deserialize)]
struct Foo;
...
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
No files, tests, or entry points are named. Start by examining how rust-clippy implements existing restriction lints and how Rust resolves derive-macro reexports, then determine whether the proposed warning and suggestion are feasible. Done means the lint reliably distinguishes direct and reexported derives, with tests covering the serde example and any feature-flag behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100