Skip to content

Impl documentation with sections is poorly indented #139771

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

Closed
zopsicle opened this issue Apr 13, 2025 · 2 comments · Fixed by #140248
Closed

Impl documentation with sections is poorly indented #139771

zopsicle opened this issue Apr 13, 2025 · 2 comments · Fixed by #140248
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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Comments

@zopsicle
Copy link
Contributor

I tried this code:

struct Context<'a>(&'a ());

/// Working with objects.
///
/// # Safety
///
/// Functions that take indices of locals do not check bounds on these indices;
/// the caller must ensure that the indices are less than the number of locals
/// in the current stack frame.
impl<'a> Context<'a> {}

I expected to see this happen:

Documentation for impl is indented consistently.

Instead, this happened:

The first paragraph is indented more than the safety section:

Image

Meta

rustc --version --verbose:

rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7
@zopsicle zopsicle added the C-bug Category: This is a bug. label Apr 13, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 13, 2025
@fmease fmease added A-rustdoc-ui Area: Rustdoc UI (generated HTML) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 13, 2025
@rustbot rustbot added the T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. label Apr 13, 2025
@fmease fmease added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 13, 2025
@GuillaumeGomez
Copy link
Member

Interesting. I tried your code as is and got:

Image

You'll notice that the note added by rustdoc is not at the very beginning of the doc. So that's actually 2 bugs, yeay. =D

Taking a look.

@GuillaumeGomez
Copy link
Member

Opened fix in #140248.

@bors bors closed this as completed in bc25dc2 Apr 25, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 25, 2025
Rollup merge of rust-lang#140248 - GuillaumeGomez:fix-impl-block-items-indent, r=notriddle

Fix impl block items indent

Fixes rust-lang#139771.

Now, all impl block "before impl block items" indent are the same (ie, item info and documentation).

With this fix, it looks like this:

![Screenshot From 2025-04-24 12-32-40](https://github.com/user-attachments/assets/907803a2-2949-4d01-afa5-fc3132d10ff2)

You can test it [here](https://rustdoc.crud.net/imperio/fix-impl-block-items-indent/foo/struct.Context.html).

r? `@notriddle`
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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants