rust-lang / rust-lang/reference
Document when items can be omitted from trait impls
Nobody has claimed this yet.
- 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
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 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