Skip to content

Docs & rustdoc: Mark traits that have indirect and synthetic impls #133573

Open
@cher-nov

Description

@cher-nov

There's a lot of implicit stuff going on behind the scenes in Rust that's dictated by the very nature of the trait-based type systems. However, that doesn't change the fact that hidden complexity makes it difficult to understand other people's code and write your own, let alone learn the language for newbies.

One example of such complexity is side effects of importing traits from other modules, when seemingly familiar types can suddenly acquire new methods and even operational semantics. But since we can declare the use of elements without naming each of them individually, with asterisk wildcard syntax, these methods begin to look like as though they came out of nowhere. And sometimes this approach is even preferable and officially recommended - see e.g. std::io::prelude.

This problem could be greatly mitigated if such traits were distinctly marked out on overview pages. This includes:

  • Traits that have blanket implementations. The most prominent example here is Any.
  • Traits that have implementations on foreign types, along with generic (i.e. covered) ones. A good illustration of it is zerocopy::Unaligned.
  • Auto traits: as of 1.82.0, this is Send, Sync, Unpin, UnwindSafe, RefUnwindSafe, Freeze (unstable) and Sized.
    They don't quite fit the stated criterion, but are close to it in spirit, so I think it would be nice to also highlight them from the general mass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-uiArea: Rustdoc UI (generated HTML)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.T-rustdoc-frontendRelevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions