Skip to content

rustdoc: Provide information on Send/Sync/Sized, variance, pointer indirection, ... #41537

Closed
@RalfJung

Description

@RalfJung

There are some properties of types that are part of the "publicly visible interface" in the sense that they can be observed by other crates using these types, but they are not shown by rustdoc and usually can only be figured out by hunting through the implementation source code (potentially through many layers).

This is includes the information of when the type satisfies Send or Sync ("when" in the sense of "which bounds are needed on T to make Foo<T> be Send), when it is sized, what is the variance of lifetime and/or type parameters, and whether type parameters are occurring exclusively below a pointer indirection. (The latter is relevant to know whether struct Foo { f: T<Foo> } is legal.)

I recently hit this when I wanted to figure out when exactly MutexGuard, RwLockReadGuard and RwLockWriteGuard are Send or Sync -- I started chasing the source code, but actually it turns out to be much easier to "probe" these types by writing little programs that test whether the bounds are satisfied. Needless to say, that's not great. Ideally, rustdoc should present this information somewhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions