-
Notifications
You must be signed in to change notification settings - Fork 14k
[rustdoc] Remove UrlFragment::render method to unify clean::types::links and anchor
#149028
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
base: main
Are you sure you want to change the base?
Conversation
|
I think we should block this on #149026 just to be safe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, just a few nits.
I am somewhat tempted to say in the future we should also unify the impl block section naming into the same function so that this same logic can be used for sidebar generation, but I'm not sure if that would be better than the status quo or not.
src/librustdoc/formats/item_type.rs
Outdated
| DefKind::AssocFn if tcx.associated_item(def_id).defaultness(tcx).has_value() => { | ||
| Self::Method | ||
| } | ||
| DefKind::AssocFn => Self::TyMethod, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I would personally use an if/else here instead of a match guard, but it's subjective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't prefer either so I'll update to your preference. :)
src/librustdoc/html/format.rs
Outdated
| let item_type = | ||
| ItemType::from_def_kind(def_kind, Some(tcx.def_kind(parent_def_id))); | ||
| format!("#{}.{}", item_type.as_str(), tcx.item_name(did)) | ||
| pub(crate) fn anchor(did: DefId, tcx: TyCtxt<'_>) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this fragment, since "anchor" can also refer to the whole <a> element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
I actually tested with this one but I don't mind waiting. 😉 |
3ad2a47 to
772c662
Compare
|
Applied suggestions. |
772c662 to
a5f972e
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. |
|
Rebased on #149026. |
| let item_type = | ||
| ItemType::from_def_kind(def_kind, Some(tcx.def_kind(parent_def_id))); | ||
| format!("#{}.{}", item_type.as_str(), tcx.item_name(did)) | ||
| pub(crate) fn fragment(did: DefId, tcx: TyCtxt<'_>) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason you moved from returning impl Display to returning String?
Fixes #148648.
First part of #148547.
The last part will be about handle
AssocItemLinkdifferently (either remove it or change how we do it).r? @lolbinarycat