rust-lang / rust-lang/reference

Document when items can be omitted from trait impls

Open
#1,932 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

The Reference says:

A trait implementation must define all non-default associated items declared by the implemented trait, may redefine default associated items defined by the implemented trait, and cannot define any other items.

However, the compiler accepts:

trait Tr {
    type Ty where Self: Sized;
    fn f() where Self: Sized;
}

trait A {}
impl Tr for dyn A {}

cc @ehuss https://github.com/rust-lang/rust/pull/135480 https://github.com/rust-lang/reference/issues/1933 https://github.com/rust-lang/rust/issues/127251

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 with the linked Reference section on trait implementation item requirements and compare its wording with the Rust example in the issue. Determine how the accepted omission of Self: Sized associated items should be documented, then update that section so the documented rule matches the compiler behavior shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.