Skip to content

rustdoc shouldn't render deduced "unimpls" of auto traits as synthetic negative impls but simply not at all #146571

@fmease

Description

@fmease

Currently, when a given type doesn't impl an auto trait AutoTrait due to its constituents not impl'ing the auto trait, then rustdoc displays a synthetic negative impl of AutoTrait for said type. However, strictly speaking that's not correct as negative impls affect coherence and SemVer differently.

E.g., for:

pub struct Type(*const ());

rustdoc currently synthesizes

impl !Send for Type

to denote "Type doesn't impl Send" (due to <T: ?Sized> *const T: !Send). However that syntax is clashing with actual negative impls (presently unstably gated under negative_impls) which come with different SemVer guarantees (namely, "the type will never impl Send") and behave differently under coherence (for an example. see #146427).

Since synthetic auto trait impls are meant to be copy/paste-able into the source code w/o it affecting semantics (this principle is violated already, cc #111101), the simplest solution would be to stop synthesizing auto trait "unimpls".

I was worried that this isn't quite compatible with conditional negative impls (I might elaborate on that later) but they seem to get rejected anyway (time to update (parts of) #79098) with E0367. In any case, we might someday also have impl ?Trait for Type (Negative impls draft RFC § ? and auto-traits, #68318 (comment) et seqq.) which we could fall back to in case we ever need to express more complex bounds.


Originally reported in #146427 (comment) by @RReverser.

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