rustdoc: Incorrect synthetic auto trait impl if constituents have applicable non-identity impl of auto trait
Open
@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
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.
Assessment
This issue has not been assessed yet.