Skip to content

Add missing_*_implementations for common traits. #145618

@kevincox

Description

@kevincox

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions