Skip to content

rustdoc: Legend for important language specifics of items in the sidebar #164813

Open

Description

@cher-nov

Currently, the sidebar looks pretty monotonous and dull, difficult to navigate. For example: Primitive Type slice (1.99.1).
However, #154644 is definitely a step in the right direction. So I would suggest taking this initiative even further.

1. Split "Methods" into more distinct groups based on how self is passed.

  • Immutable Methods (&self)
  • Mutable Methods (&mut self)
  • Consuming Methods (self)

Or simpler (to preserve grouping of items like get() / get_mut()):

  • Borrowing Methods (&self and &mut self)
  • Exclusive Methods (self)

2. Highlight the following characteristics by category:

  • Safety

    • safe
    • safe but having raw pointers in any position, thus involving unsafe code
    • explicitly unsafe
  • Concreteness (excluding lifetimes!)

    • common (e.g. impl Foo for Bar) or generic only over parameters of the parent item, if any (e.g. impl<T> Foo for Bar<T>)
    • generic over additional type parameters introduced (e.g. impl<T, U> Foo<U> for Bar<T>)
    • non-generic over some parameter of the parent item, or specialized over all of them
      Like impl AsRef<[u8]> for str, as opposed to e.g. impl<T> AsRef<[T]> for [T].
    • having any const generic parameters

Given that only two categories are proposed, only the basic formatting properties can be used for them: color and font style.
Or it might also be worth employing subscript/superscript somehow here, idk.

member generic special w/ const
safe $\color{#00AA00}\text{foobar}$ $\color{#00AA00}\text{𝘧𝘰𝘰𝘣𝘢𝘳}$ $\color{#00AA00}\text{𝗳𝗼𝗼𝗯𝗮𝗿}$ $\color{#00AA00}\text{𝙛𝙤𝙤𝙗𝙖𝙧}$
w/ raw $\color{#FFAC00}\text{foobar}$ $\color{#FFAC00}\text{𝘧𝘰𝘰𝘣𝘢𝘳}$ $\color{#FFAC00}\text{𝗳𝗼𝗼𝗯𝗮𝗿}$ $\color{#FFAC00}\text{𝙛𝙤𝙤𝙗𝙖𝙧}$
unsafe $\color{#EE0000}\text{foobar}$ $\color{#EE0000}\text{𝘧𝘰𝘰𝘣𝘢𝘳}$ $\color{#EE0000}\text{𝗳𝗼𝗼𝗯𝗮𝗿}$ $\color{#EE0000}\text{𝙛𝙤𝙤𝙗𝙖𝙧}$

Instead of hard-coding the color, it can just tint the primary theme color used for sidebar captions.

Activity

  1. added
    needs-triage
    on Oct 23, 2026
  2. added
    T-rustdoc
    C-enhancement
    C-feature-request
    and removed
    needs-triage
    on Oct 23, 2026
  3. GuillaumeGomez commented on Oct 25, 2026

    @GuillaumeGomez
    Member

    I don't think introducing differentiation through colors or font style is a good idea. It adds a lot more things to be wary about for themes handling and for visually impaired people, it's just not something they will receive information about.

  4. cher-nov commented on Oct 26, 2026

    @cher-nov
    Author

    @GuillaumeGomez Thanks for the feedback! Could you please also take a look at #133573, which is kinda similar?

    I don't think introducing differentiation through colors or font style is a good idea.

    That's not the only option. The other ones are icons, badges or additional characters - e.g. writing the generic function foobar as foobar<>.
    The issue is about distinction - I might know roughly what kind of routine I'm looking for, but the sidebar doesn't currently help me with that.

    It adds a lot more things to be wary about for themes handling and for visually impaired people, it's just not something they will receive information about.

    Sure, but I'd like to point out something:

    1. The best solution for people with disabilities, IMO, is an accessibility theme specifically tailored to their needs such as screen readers.

    2. Color is already being used at least to highlight the type name in the page header ("Primitive Type slice").
      Previously, it was also a link, but not anymore. So, when all color is removed from the page, that emphasis is lost as well.

    3. It would be anyway useful to have a page setting like "Mark subroutine specifics: none / by style / with syntax".

    4. The number of colors could be reduced (color-blind people would appreciate this?), as well as categories. Like this, for example:

      common generic special
      safe $\text{foobar}$ $\text{𝘧𝘰𝘰𝘣𝘢𝘳}$ $\text{𝗳𝗼𝗼𝗯𝗮𝗿}$
      unsafe $\color{#EE0000}\text{foobar}$ $\color{#EE0000}\text{𝘧𝘰𝘰𝘣𝘢𝘳}$ $\color{#EE0000}\text{𝗳𝗼𝗼𝗯𝗮𝗿}$

      * non-highlighted text means the default theme color

  5. changed the title [-]`rustdoc`: Legend for notable language specifics of items in the sidebar[/-] [+]`rustdoc`: Legend for important language specifics of items in the sidebar[/+] on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementC-feature-requestT-rustdoc

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions