Uh oh!
There was an error while loading. Please reload this page.
Fix relative extern URL depth on source pages - #153160
Conversation
This comment has been minimized.
This comment has been minimized.
372a8c7 to
d71f355CompareUh oh!
There was an error while loading. Please reload this page.
rustbot
commented
Feb 27, 2026
Reminder, once the PR becomes ready for a review, use |
d71f355 to
bfeb902Compare
This comment has been minimized.
This comment has been minimized.
arferreira
commented
Feb 27, 2026
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
0f28723 to
6017689Comparenotriddle
commented
Feb 27, 2026
@bors r+ |
This comment has been minimized.
This comment has been minimized.
6017689 to
59b37bbComparerustbot
commented
Mar 12, 2026
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. |
notriddle
commented
Mar 12, 2026
@bors r+ |
This comment has been minimized.
This comment has been minimized.
… r=notriddle Fix relative extern URL depth on source pages Source pages with `--extern-html-root-url` pointing to a relative URL like `../` were generating links with one extra `../`. So instead of `../../core/iter/index.html` you'd get `../../../core/iter/index.html`. Took a while to notice because `htmldocck.py` uses substring matching — `../../core/` is a substring of `../../../core/` so the test passed anyway. Two root causes. `remote_url_prefix` was using `cx.current.len()` for depth, but during source rendering `cx.current` is empty — `SourceCollector` doesn't do module descent. Source pages live under `src/<crate_name>/` so the real depth is 2, not 0. On top of that, `make_href` was trying to compensate by prepending `root_path` to relative remote URLs (there was a FIXME about this), which just made it worse — `../../` + `../core/iter/` = `../../../core/iter/`. Fix: added `remote_item_depth(root_path, doc_depth)` that counts `../` segments in `root_path` when present, falls back to `doc_depth` otherwise. With the right depth in `remote_url_prefix`, `make_href` no longer needs to touch remote URLs at all — so `url_parts` now returns `is_remote = true` for all `Remote` locations. Also renamed `is_absolute` → `is_remote` since the semantics were always about "don't modify this URL", not about whether it has a scheme. Added `!has` assertions to the test so the wrong URL gets caught explicitly next time. Follow-up to #152977. r? @notriddle
💔 Test for e95d0cd failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
Zalathar
commented
Mar 12, 2026
@bors retry |
…-root-path, r=notriddle Fix relative extern URL depth on source pages Source pages with `--extern-html-root-url` pointing to a relative URL like `../` were generating links with one extra `../`. So instead of `../../core/iter/index.html` you'd get `../../../core/iter/index.html`. Took a while to notice because `htmldocck.py` uses substring matching — `../../core/` is a substring of `../../../core/` so the test passed anyway. Two root causes. `remote_url_prefix` was using `cx.current.len()` for depth, but during source rendering `cx.current` is empty — `SourceCollector` doesn't do module descent. Source pages live under `src/<crate_name>/` so the real depth is 2, not 0. On top of that, `make_href` was trying to compensate by prepending `root_path` to relative remote URLs (there was a FIXME about this), which just made it worse — `../../` + `../core/iter/` = `../../../core/iter/`. Fix: added `remote_item_depth(root_path, doc_depth)` that counts `../` segments in `root_path` when present, falls back to `doc_depth` otherwise. With the right depth in `remote_url_prefix`, `make_href` no longer needs to touch remote URLs at all — so `url_parts` now returns `is_remote = true` for all `Remote` locations. Also renamed `is_absolute` → `is_remote` since the semantics were always about "don't modify this URL", not about whether it has a scheme. Added `!has` assertions to the test so the wrong URL gets caught explicitly next time. Follow-up to rust-lang#152977. r? @notriddle
…-root-path, r=notriddle Fix relative extern URL depth on source pages Source pages with `--extern-html-root-url` pointing to a relative URL like `../` were generating links with one extra `../`. So instead of `../../core/iter/index.html` you'd get `../../../core/iter/index.html`. Took a while to notice because `htmldocck.py` uses substring matching — `../../core/` is a substring of `../../../core/` so the test passed anyway. Two root causes. `remote_url_prefix` was using `cx.current.len()` for depth, but during source rendering `cx.current` is empty — `SourceCollector` doesn't do module descent. Source pages live under `src/<crate_name>/` so the real depth is 2, not 0. On top of that, `make_href` was trying to compensate by prepending `root_path` to relative remote URLs (there was a FIXME about this), which just made it worse — `../../` + `../core/iter/` = `../../../core/iter/`. Fix: added `remote_item_depth(root_path, doc_depth)` that counts `../` segments in `root_path` when present, falls back to `doc_depth` otherwise. With the right depth in `remote_url_prefix`, `make_href` no longer needs to touch remote URLs at all — so `url_parts` now returns `is_remote = true` for all `Remote` locations. Also renamed `is_absolute` → `is_remote` since the semantics were always about "don't modify this URL", not about whether it has a scheme. Added `!has` assertions to the test so the wrong URL gets caught explicitly next time. Follow-up to rust-lang#152977. r? @notriddle
Rollup of 7 pull requests Successful merges: - #153736 (add test that an incomplete feature emits a warning) - #153160 (Fix relative extern URL depth on source pages) - #153432 (Fix some comments about dataflow analysis.) - #153694 (fix(query): Pass Query Key to `value_from_cycle_error`) - #153717 (unused_macro_rules switched used and unused comments) - #153748 (editorconfig: css uses tabs) - #153750 (rustc-dev-guide subtree update)
⌛ Testing commit 59b37bb with merge c66e4b8... Workflow: https://github.com/rust-lang/rust/actions/runs/22995536645 |
… r=notriddle Fix relative extern URL depth on source pages Source pages with `--extern-html-root-url` pointing to a relative URL like `../` were generating links with one extra `../`. So instead of `../../core/iter/index.html` you'd get `../../../core/iter/index.html`. Took a while to notice because `htmldocck.py` uses substring matching — `../../core/` is a substring of `../../../core/` so the test passed anyway. Two root causes. `remote_url_prefix` was using `cx.current.len()` for depth, but during source rendering `cx.current` is empty — `SourceCollector` doesn't do module descent. Source pages live under `src/<crate_name>/` so the real depth is 2, not 0. On top of that, `make_href` was trying to compensate by prepending `root_path` to relative remote URLs (there was a FIXME about this), which just made it worse — `../../` + `../core/iter/` = `../../../core/iter/`. Fix: added `remote_item_depth(root_path, doc_depth)` that counts `../` segments in `root_path` when present, falls back to `doc_depth` otherwise. With the right depth in `remote_url_prefix`, `make_href` no longer needs to touch remote URLs at all — so `url_parts` now returns `is_remote = true` for all `Remote` locations. Also renamed `is_absolute` → `is_remote` since the semantics were always about "don't modify this URL", not about whether it has a scheme. Added `!has` assertions to the test so the wrong URL gets caught explicitly next time. Follow-up to #152977. r? @notriddle
Zalathar
commented
Mar 12, 2026
Failed in rollup: #153761 (comment) @bors r- |
This pull request was unapproved. This PR was contained in a rollup (#153761), which was unapproved. Auto build was cancelled due to unapproval. Cancelled workflows: |
Zalathar
commented
Mar 12, 2026
@bors try jobs=dist-x86_64-linux-alt |
This comment has been minimized.
This comment has been minimized.
… r=<try> Fix relative extern URL depth on source pages try-job: dist-x86_64-linux-alt
☔ The latest upstream changes (presumably #161990) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
View all comments
Source pages with
--extern-html-root-urlpointing to a relative URL like../were generating links with one extra../. So instead of../../core/iter/index.htmlyou'd get../../../core/iter/index.html. Took a while to notice becausehtmldocck.pyuses substring matching —../../core/is a substring of../../../core/so the test passed anyway.Two root causes.
remote_url_prefixwas usingcx.current.len()for depth, but during source renderingcx.currentis empty —SourceCollectordoesn't do module descent. Source pages live undersrc/<crate_name>/so the real depth is 2, not 0. On top of that,make_hrefwas trying to compensate by prependingroot_pathto relative remote URLs (there was a FIXME about this), which just made it worse —../../+../core/iter/=../../../core/iter/.Fix: added
remote_item_depth(root_path, doc_depth)that counts../segments inroot_pathwhen present, falls back todoc_depthotherwise. With the right depth inremote_url_prefix,make_hrefno longer needs to touch remote URLs at all — sourl_partsnow returnsis_remote = truefor allRemotelocations. Also renamedis_absolute→is_remotesince the semantics were always about "don't modify this URL", not about whether it has a scheme.Added
!hasassertions to the test so the wrong URL gets caught explicitly next time.Follow-up to #152977.
r? @notriddle