Skip to content

rustdoc: where-clauses on tuple & unit structs and on assoc tys are weirdly styled #112901

Description

@fmease

The styling of where-clauses on tuple & unit structs and on assoc tys weirdly differs from those on other items (structs, enums, unions, functions, impl blocks etc.) in that they don't have a smaller fonts size and are indented by 9 instead of 4 spaces (more precisely: for associated types it's 3 instead of 4 inside the .item-decl of the trait but 9 instead of 4 everywhere else).

Tuple Structs

pub struct A<T>(T)
where
    T: Copy;

is rendered as

Screenshot 2023-06-21 at 18-54-30 A in tup - Rust

Compare that to

pub struct B<T>
where
    T: Copy,
{
    x: T,
}

Screenshot 2023-06-21 at 18-55-31 B in tup - Rust

Unit Structs

#![feature(trivial_bounds)]

pub struct S
where
    String: Clone;

Screenshot 2023-06-21 at 19-07-44 S in tup - Rust

Associated Types

pub struct S;

pub trait Tr {
    type F<T>
    where
        T: Clone;
}

impl Tr for S {
    type F<T> = T where T: Clone;
}

Inside the .item-decl of the trait (3 spaces, big):

Screenshot 2023-06-21 at 20-14-21 Tr in nx - Rust

In section Required Associated Types on the page of the trait (9 spaces):

Screenshot 2023-06-21 at 20-12-24 Tr in nx - Rust

On the implementer's page (9 spaces, big):

Screenshot 2023-06-21 at 20-15-58 S in nx - Rust

@rustbot label C-bug T-rustdoc A-rustdoc-ui

Activity

  1. added
    A-rustdoc-uiArea: Rustdoc UI (generated HTML)
    C-bugCategory: This is a bug.
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    on Jun 21, 2023
  2. self-assigned this
    on Jun 24, 2023
  3. added 2 commits that reference this issue on Jun 26, 2023
    c6948b5
    35b3577
  4. GuillaumeGomez commented on Jul 11, 2023

    @GuillaumeGomez
    Member

    #112927 fixed all of them as far as I can see:

    Screenshot from 2023-07-11 15-11-52
    Screenshot from 2023-07-11 15-12-43
    Screenshot from 2023-07-11 15-12-54
    Screenshot from 2023-07-11 15-11-31

    The remaining debate is about the 3 spaces rule which makes the reading easier but differs from rustfmt. You can see the debate in #113043.

  5. fmease commented on Jul 11, 2023

    @fmease
    MemberAuthor

    #112927 did indeed mostly fix it. The one thing remaining though is the font size of the where-clause which #113043 fixes: Outside of .item-decl I expect them to be smaller compared to the corresponding item.

    The where-clause being indented by 3 spaces inside of .item-decls has been FCP'ed as notriddle reminded me, so that's set in stone until someone raises a serious concern.

  6. removed their assignment
    on May 12, 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

    A-rustdoc-uiArea: Rustdoc UI (generated HTML)C-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