Skip to content

rustdoc: synthetic impls don't include bounds that originate from the implementing type #111101

Open
@fmease

Description

@fmease

For example, given

pub struct Ty<T: Clone>(T);

the impl of the auto trait Send synthesized for the generic type Ty looks like

impl<T> Send for Ty<T>
where
    T: Send

while ideally its where clause should be where T: Clone + Send since in its current form it isn't well-typed: the trait bound T: Clone is not satisfied (strictly speaking a manual Send impl would have to be additionally marked as unsafe to be well-formed but the omission is by design).

According to the following paragraph from the PR description of the initial implementation of synthetic impls (#47833):

All of this means that a user should be able to copy-paste a [synthetic impl] into their code, without any observable changes in behavior (assuming the rest of the program remains unchanged).

If we want to conform to this rule then the current behavior is incorrect (although it goes all the way back to said PR) since a copy-paste will lead to a type error.

Maybe all of this is intentional (less clutter, disk size reduction)? Opening for discussion (my bias: bug).

@rustbot label C-bug T-rustdoc A-auto-traits A-synthetic-impls

Metadata

Metadata

Assignees

Labels

A-auto-traitsArea: auto traits (e.g., `auto trait Send {}`)A-synthetic-implsArea: Synthetic impls, used by rustdoc to document auto traits and traits with blanket implsC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions