rust-lang / rust-lang/rust

Add `missing_*_implementations` for common traits.

Open
#145,618 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lints C-feature-request T-lang
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
pub struct MyType;
Current output

Nothing.

Desired output

Some warnings.

Rationale and extra context

According to Rust API Guidelines - Types eagerly implement common traits (C-COMMON-TRAITS) public types should eagerly implement common traits from std such as Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Display, Default.

However it is very easy to forget at least some of these traits. Then the users are frustrated because they can't derive Eq for their struct because one field isn't Eq when it could be. We have missing-debug-implementations for Debug and missing-copy-implementations for Copy (kind of, this one only triggers if the type can implement Copy, but that is likely a good enough heuristic). When implementing a library it can be useful to have a reminder.

If all of the above mentioned traits had a missing_*_implementations lint library authors couldn't forget. You would need to either add the impl or explicitly allow it in cases where it doesn't make sense. This serves as a checked-in and reviewed checklist.

These lints would be allow by default. Binary crates would likely never enable them. However libraries can enable as many of them as makes sense.

Rust Version
rustc 1.88.0 (6b00bc388 2025-06-23) (built from a source tarball)
binary: rustc
commit-hash: 6b00bc3880198600130e1cf62b8f8a93494488cc
commit-date: 2025-06-23
host: x86_64-unknown-linux-gnu
release: 1.88.0
LLVM version: 20.1.6
Anything else?

No response

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 reading the existing missing-debug-implementations and missing-copy-implementations lints and the Rust API Guidelines section on common traits. Determine how the proposed lints should identify public types and which traits they should cover. Done means the requested allow-by-default lints exist with behavior and coverage matching the stated common-trait checklist.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.