Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fmease opened this issue Jun 21, 2023 · 2 comments
Assignees
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Jun 21, 2023

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

@rustbot rustbot added A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jun 21, 2023
@camelid camelid self-assigned this Jun 24, 2023
camelid added a commit to camelid/rust that referenced this issue Jun 26, 2023
This commit (or one of the prior ones) mostly fixes rust-lang#112901, though it
causes one case (item-decl for trait assoc ty) to regress in that issue.
camelid added a commit to camelid/rust that referenced this issue Jun 26, 2023
It's a lot of snapshots, but it's quite hard to test this sort of
formatting with other ways.
@GuillaumeGomez
Copy link
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.

@fmease
Copy link
Member Author

fmease commented Jul 11, 2023

#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants