-
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.
| 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.
| 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.
I actually tested with this one but I don't mind waiting. 😉 |
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