rust-lang / rust-lang/rust

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

Open
#146,570 1 comment 0 reactions 1 assignee View on GitHub

@fmease is already working on this.

Since Sep 15, 2025.

A-auto-traits A-synthetic-impls C-bug T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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 https://github.com/rust-lang/rust/issues/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).

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.