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: awkward vertical spacing on trait bounds #85566

Closed
jsha opened this issue May 21, 2021 · 1 comment · Fixed by #102842
Closed

rustdoc: awkward vertical spacing on trait bounds #85566

jsha opened this issue May 21, 2021 · 1 comment · Fixed by #102842
Assignees
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jsha
Copy link
Contributor

jsha commented May 21, 2021

When a method does not have trait bounds, it is displayed all on one line. When a method has just one trait bound, it takes four lines:

fn by_ref(&mut self) -> &mut Self
where
    Self: Sized,
{ ... }

There are some conflicting priorities here: On the one hand, it's nice for the layout to match what rustfmt does. On the other hand, it's good to use spacing to emphasize the parts of the documentation that are important. For instance, the { ... } has a whole line to itself to convey one bit of information: this is a provided method, not a required one. Spacing is also useful to show that parts of the display are related to each other. In the above, it's not visually clear whether { ... } is part of by_ref or some independent item.

I propose we change to this for methods with one trait bound:

fn by_ref(&mut self) -> &mut Self
   where Self: Sized { ... }

And this for methods with multiple trait bounds:

fn by_ref(&mut self, other: T) -> &mut Self
   where Self: Sized,
         T: Read { ... }

Screen shot of nightly: https://doc.rust-lang.org/nightly/std/io/trait.Read.html

@jsha jsha added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) labels May 21, 2021
@rol1510
Copy link
Contributor

rol1510 commented Oct 9, 2022

@rustbot claim

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

2 participants