[Feature Request]: Derive entry per crate
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Feature Request
Derive entry per crate
Summary
Introduce separate derive macro entries grouped by their originating crate. Instead of combining all derives into a single attribute, derives would be organized into multiple #[derive(...)] blocks based on the crate they come from.
Motivation
Grouping derives by crate improves both readability and maintainability of the code. When derives from different ecosystems (e.g., serialization, archiving, standard traits) are separated, it becomes immediately clear which functionality is provided by which dependency.
This structure also makes it easier to:
- Navigate and audit dependencies: Developers can quickly identify which crate is responsible for specific derives.
- Modify or remove functionality: Adjusting or removing derives tied to a specific crate becomes straightforward without affecting unrelated ones.
- Reduce cognitive load: Large, mixed derive lists can be difficult to scan; grouping them provides a more structured and predictable layout.
- Improve consistency in larger codebases: Enforcing crate-based grouping encourages a standardized style across teams and projects.
Overall, this change promotes clearer intent, better organization, and easier long-term maintenance, especially in projects that rely on multiple derive-heavy libraries.
Related configuration options
merge_derives
Examples
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] // Rkyv derives
#[derive(serde::Serialize, serde::Deserialize)] // Serde derives
#[derive(Debug, Clone)] // Built-in derives
pub struct Donation {
verification_token: Uuid,
message_id: Uuid,
}
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 tracing the merge_derives configuration and the derive-formatting entry points in rustfmt. Use the Donation example as the expected shape: derives should be emitted in separate #[derive(...)] blocks grouped by originating crate, while built-in derives remain distinct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100