rustdoc: add disambiguators for identically named method in sidebar - #162778
lolbinarycat wants to merge 2 commits into
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
|
☔ The latest upstream changes (presumably #163244) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
fixes #142147
also affects associated fns. main improvments are to pointer and box docs.
before:

after:
