Skip to content

rustdoc: add disambiguators for identically named method in sidebar - #162778

Open
lolbinarycat wants to merge 1 commit into
rust-lang:mainfrom
lolbinarycat:rustdoc-sidebar-disambig-142147
Open

lolbinarycat wants to merge 1 commit into
rust-lang:mainfrom
lolbinarycat:rustdoc-sidebar-disambig-142147

Conversation

@lolbinarycat

@lolbinarycat lolbinarycat commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

fixes #142147

also affects associated fns. main improvments are to pointer and box docs.

before:
image

after:
image

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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. labels Sep 14, 2026
@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

r? @GuillaumeGomez

rustbot has assigned @GuillaumeGomez.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 8 candidates
  • Random selection from GuillaumeGomez, notriddle

Cow::Borrowed(s) => *s = &s[..len],
Cow::Owned(s) => s.truncate(len),
};
fn get_shortname<'a>(itm: Option<&'a Link<'a>>) -> Option<&'a str> {

@GuillaumeGomez GuillaumeGomez Sep 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit:

Suggested change
fn get_shortname<'a>(itm: Option<&'a Link<'a>>) -> Option<&'a str> {
fn get_short_name<'a>(item: Option<&'a Link<'a>>) -> Option<&'a str> {

View changes since the review

})
}

fn postprocess_method_list(ml: &mut [Link<'_>]) {

@GuillaumeGomez GuillaumeGomez Sep 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn postprocess_method_list(ml: &mut [Link<'_>]) {
fn postprocess_method_list(methods: &mut [Link<'_>]) {

View changes since the review

Comment thread src/librustdoc/html/render/sidebar.rs
Comment thread src/librustdoc/html/render/sidebar.rs
Comment thread src/librustdoc/html/render/sidebar.rs
Comment on lines +809 to +814
let cur_sn = get_shortname(ml.get(i));
if get_shortname(ml.get(i.wrapping_sub(1))) != cur_sn
&& cur_sn != get_shortname(ml.get(i + 1))
{
let csnl = cur_sn.unwrap().len();
trunc_to(&mut ml[i].name, csnl);

@GuillaumeGomez GuillaumeGomez Sep 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bigger suggestion then:

Suggested change
let cur_sn = get_shortname(ml.get(i));
if get_shortname(ml.get(i.wrapping_sub(1))) != cur_sn
&& cur_sn != get_shortname(ml.get(i + 1))
{
let csnl = cur_sn.unwrap().len();
trunc_to(&mut ml[i].name, csnl);
let Some(short_name) = get_short_name(methods.get(i)) else { continue };
if i > 0
&& get_short_name(methods.get(i - 1)) != Some(short_name)
&& Some(short_name) != get_short_name(methods.get(i + 1))
{
let current_len = short_name.len();
trunc_to(&mut methods[i].name, current_len);

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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 this pull request may close these issues.

Duplicate entries in side bar in std docs for pointer

3 participants