Uh oh!
There was an error while loading. Please reload this page.
[rustdoc] Remove UrlFragment::render method to unify clean::types::links and anchor - #149028
Conversation
lolbinarycat
commented
Nov 17, 2025
I think we should block this on #149026 just to be safe. |
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
GuillaumeGomez
commented
Nov 17, 2025
I actually tested with this one but I don't mind waiting. 😉 |
3ad2a47 to
772c662CompareGuillaumeGomez
commented
Nov 17, 2025
Applied suggestions. |
772c662 to
a5f972eComparerustbot
commented
Nov 18, 2025
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. |
GuillaumeGomez
commented
Nov 18, 2025
Rebased on #149026. |
Uh oh!
There was an error while loading. Please reload this page.
GuillaumeGomez
commented
Nov 20, 2025
Replaced the returned value of |
| }; | ||
| let s; | ||
| let kind = if tcx.def_kind(parent_def_id) == DefKind::Variant { | ||
| s = format!("variant.{}.field", tcx.item_name(parent_def_id).as_str()); |
There was a problem hiding this comment.
now that we're using from_fn, we shouldn't need this intermediate allocation either, it should be possible to rewrite this branch just as a series of calls to write!.
f506f39 to
a5e8edaCompareGuillaumeGomez
commented
Nov 20, 2025
Applied suggestion. |
This comment has been minimized.
This comment has been minimized.
a5e8eda to
ae8dc3bCompareGuillaumeGomez
commented
Nov 21, 2025
Added back the |
| /// becoming a `TyMethod`). | ||
| pub(crate) fn from_def_kind(kind: DefKind, parent_kind: Option<DefKind>) -> Self { | ||
| match kind { | ||
| pub(crate) fn from_def_id(def_id: DefId, tcx: TyCtxt<'_>) -> Self { |
There was a problem hiding this comment.
now that i think about it, wouldn't of_def_id be a more descriptive name?
There was a problem hiding this comment.
Not exactly seems it involves a type conversion, not a direct translation.
| } else { | ||
| String::new() | ||
| }; | ||
| f.write_char('#').unwrap(); |
There was a problem hiding this comment.
why are we using unwrap here instead of ?, the from_fn closure returns a Result containing fmt::Error.
in fact, the last write! of each branch does cascade it's error, so we should do the same with the others.
the unwrap in the other function is fine because there we have a concrete type of String.
There was a problem hiding this comment.
Arf indeed. Got so used to the unwrap everywhere that I simply used it here without second thought. Gonna check on a separate PRs to do the same change in the other from_fn calls.
ae8dc3b to
8f76773CompareGuillaumeGomez
commented
Nov 21, 2025
Updated! |
lolbinarycat
commented
Nov 21, 2025
just realized if you don't give a top-level comment along with your review, rustbot doesn't have anywhere to put the "view changes since this review" link. |
GuillaumeGomez
commented
Nov 21, 2025
You can click on the |
lolbinarycat
commented
Nov 21, 2025
@bors r+ |
bors
commented
Nov 21, 2025
Rollup of 7 pull requests Successful merges: - #146978 (Emit error when using path-segment keyword as cfg pred) - #148719 (Allow unnormalized types in drop elaboration) - #148795 (add `rust.rustflags` and per target `rustflags` options to `bootstrap.toml`) - #149028 ([rustdoc] Remove `UrlFragment::render` method to unify `clean::types::links` and `anchor`) - #149043 ( rustdoc-json: add rlib path to ExternalCrate to enable robust crate resolution) - #149098 (Fix error message for calling a non-tuple struct) - #149151 (Add test for importing path-segment keyword) r? `@ghost` `@rustbot` modify labels: rollup
Uh oh!
There was an error while loading. Please reload this page.
Rollup merge of #149028 - GuillaumeGomez:unify-anchor, r=lolbinarycat [rustdoc] Remove `UrlFragment::render` method to unify `clean::types::links` and `anchor` Fixes#148648. First part of #148547. The last part will be about handle `AssocItemLink` differently (either remove it or change how we do it). r? `@lolbinarycat`
…amofek,lolbinarycat [rustdoc] Make more functions return `fmt::Result` and reduce number of `.unwrap()` calls Following our discussion in rust-lang#149028 (comment), this PR makes more function return `fmt::Result`, allowing to use `?` a lot more, and also reducing number of `.unwrap()` calls. r? `@lolbinarycat`
Rollup merge of #149208 - GuillaumeGomez:less-unwraps, r=yotamofek,lolbinarycat [rustdoc] Make more functions return `fmt::Result` and reduce number of `.unwrap()` calls Following our discussion in #149028 (comment), this PR makes more function return `fmt::Result`, allowing to use `?` a lot more, and also reducing number of `.unwrap()` calls. r? `@lolbinarycat`
…lbinarycat [rustdoc] Make more functions return `fmt::Result` and reduce number of `.unwrap()` calls Following our discussion in rust-lang/rust#149028 (comment), this PR makes more function return `fmt::Result`, allowing to use `?` a lot more, and also reducing number of `.unwrap()` calls. r? `@lolbinarycat`
Rollup of 7 pull requests Successful merges: - rust-lang/rust#146978 (Emit error when using path-segment keyword as cfg pred) - rust-lang/rust#148719 (Allow unnormalized types in drop elaboration) - rust-lang/rust#148795 (add `rust.rustflags` and per target `rustflags` options to `bootstrap.toml`) - rust-lang/rust#149028 ([rustdoc] Remove `UrlFragment::render` method to unify `clean::types::links` and `anchor`) - rust-lang/rust#149043 ( rustdoc-json: add rlib path to ExternalCrate to enable robust crate resolution) - rust-lang/rust#149098 (Fix error message for calling a non-tuple struct) - rust-lang/rust#149151 (Add test for importing path-segment keyword) r? `@ghost` `@rustbot` modify labels: rollup
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