Repository navigation
rustdoc: add disambiguators for identically named method in sidebar - #162778
Conversation
|
rustbot has assigned @GuillaumeGomez. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| Cow::Borrowed(s) => *s = &s[..len], | ||
| Cow::Owned(s) => s.truncate(len), | ||
| }; | ||
| fn get_shortname<'a>(itm: Option<&'a Link<'a>>) -> Option<&'a str> { |
There was a problem hiding this comment.
Just a nit:
| 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> { |
| }) | ||
| } | ||
|
|
||
| fn postprocess_method_list(ml: &mut [Link<'_>]) { |
There was a problem hiding this comment.
| fn postprocess_method_list(ml: &mut [Link<'_>]) { | |
| fn postprocess_method_list(methods: &mut [Link<'_>]) { |
| 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); |
There was a problem hiding this comment.
Bigger suggestion then:
| 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); |
2dd6d30 to
bf8114c
Compare
|
the |
|
I like it a lot and the implementation looks good. Now just remains to add tests. :) |
| impl C<A> { | ||
| //@ has - "//a[@href='#method.dupe']" "dupe (C<A>)" | ||
| pub fn dupe(self) {} | ||
| //@ has - "//a[@href='#method.uniq1']" "uniq1" |
There was a problem hiding this comment.
Use matches with $ and ^ to ensure it's the full string instead of !has below.
8080cd8 to
d8272dc
Compare
| pub struct C<T>(T); | ||
|
|
||
| impl C<A> { | ||
| //@ has - "//a[@href='#method.dupe']" "^dupe (C<A>)$" |
There was a problem hiding this comment.
Shouldn't it be matches here as well?
This comment has been minimized.
This comment has been minimized.
d8272dc to
976084c
Compare
This comment has been minimized.
This comment has been minimized.
976084c to
9bab947
Compare
This comment has been minimized.
This comment has been minimized.
9bab947 to
46fca93
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Nice, thanks! @bors r+ rollup |
…big-142147, r=GuillaumeGomez rustdoc: add disambiguators for identically named method in sidebar fixes rust-lang#142147 also affects associated fns. main improvments are to pointer and box docs. before: <img width="264" height="439" alt="image" src="https://github.com/user-attachments/assets/8347c2b8-88cb-470f-beb3-6cb377ca37f0" /> after: <img width="693" height="576" alt="image" src="https://github.com/user-attachments/assets/478d1ef5-7a1e-4024-a796-d2b0fd0f5a49" />
…big-142147, r=GuillaumeGomez rustdoc: add disambiguators for identically named method in sidebar fixes rust-lang#142147 also affects associated fns. main improvments are to pointer and box docs. before: <img width="264" height="439" alt="image" src="https://github.com/user-attachments/assets/8347c2b8-88cb-470f-beb3-6cb377ca37f0" /> after: <img width="693" height="576" alt="image" src="https://github.com/user-attachments/assets/478d1ef5-7a1e-4024-a796-d2b0fd0f5a49" />
…big-142147, r=GuillaumeGomez rustdoc: add disambiguators for identically named method in sidebar fixes rust-lang#142147 also affects associated fns. main improvments are to pointer and box docs. before: <img width="264" height="439" alt="image" src="https://github.com/user-attachments/assets/8347c2b8-88cb-470f-beb3-6cb377ca37f0" /> after: <img width="693" height="576" alt="image" src="https://github.com/user-attachments/assets/478d1ef5-7a1e-4024-a796-d2b0fd0f5a49" />
…uwer Rollup of 8 pull requests Successful merges: - #164271 (Add release notes for 1.99.1) - #164361 (delegation: map return even if there is no target expression) - #162778 (rustdoc: add disambiguators for identically named method in sidebar) - #163224 ([rustdoc] Add tabs to settings popover) - #164220 (Test the interaction between `--remap-path-prefix` and doctests) - #164279 (Make the `documentation` scope a sub-scope of the `object` scope) - #164318 (Fix check with `is_impl_trait_in_trait()` before expecting local id) - #164360 (Fix(lib/sys): Restore Win7 compilation)
…uwer Rollup of 7 pull requests Successful merges: - #164175 (Drop WC_ERR_INVALID_CHARS from Windows stdio) - #164361 (delegation: map return even if there is no target expression) - #162778 (rustdoc: add disambiguators for identically named method in sidebar) - #163224 ([rustdoc] Add tabs to settings popover) - #164220 (Test the interaction between `--remap-path-prefix` and doctests) - #164318 (Fix check with `is_impl_trait_in_trait()` before expecting local id) - #164360 (Fix(lib/sys): Restore Win7 compilation)
Rollup merge of #162778 - lolbinarycat:rustdoc-sidebar-disambig-142147, r=GuillaumeGomez rustdoc: add disambiguators for identically named method in sidebar fixes #142147 also affects associated fns. main improvments are to pointer and box docs. before: <img width="264" height="439" alt="image" src="https://github.com/user-attachments/assets/8347c2b8-88cb-470f-beb3-6cb377ca37f0" /> after: <img width="693" height="576" alt="image" src="https://github.com/user-attachments/assets/478d1ef5-7a1e-4024-a796-d2b0fd0f5a49" />
|
Note This PR was benchmarked as part of triage of its containing rollup: triage URL. Finished benchmarking commit (7278160): comparison URL. Overall result: ❌ regressions - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Artifact size: 406.81 MiB -> 406.97 MiB (0.04%) |
|
Regression is real and persists, but limited to just one doc scenario and seems likely expected from disambiguating methods in the sidebar (more work to do, probably slightly more output). |
View all comments
fixes #142147
also affects associated fns. main improvments are to pointer and box docs.
before:

after:
