Skip to content

rustdoc: Incorrect synthetic auto trait impl if constituents have applicable non-identity impl of auto trait #146570

@fmease

Description

@fmease

Given

pub struct Outer<T>(Inner<T>);
struct Inner<T>(T);

// non-identity impl:
impl Unpin for Inner<()> {} // or any other auto trait

rustdoc currently synthesizes:

impl<T> !Unpin for Outer<T>

However, ideally it would be:

impl Unpin for Outer<()>

Counterexample:

pub struct Outer<T>(Inner<T, i32>, Inner<T, u32>);
struct Inner<T, D>(T, D);
impl Unpin for Inner<(), i32> {}
impl Unpin for Inner<bool, u32> {}

Here, the synthesized impl<T> !Unpin for Outer<T> is obviously correct (modulo #146571).


Side note: This only affects non-identity impls (i.e., args differ from impl'er's def) and not conditional impls (i.e., bounds diff from impl'er's def) because the latter is forbidden (E0367).

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