Fix relative extern URL depth on source pages#153160
Open
arferreira wants to merge 2 commits intorust-lang:mainfrom
Open
Fix relative extern URL depth on source pages#153160arferreira wants to merge 2 commits intorust-lang:mainfrom
arferreira wants to merge 2 commits intorust-lang:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
372a8c7 to
d71f355
Compare
notriddle
requested changes
Feb 27, 2026
Collaborator
|
Reminder, once the PR becomes ready for a review, use |
d71f355 to
bfeb902
Compare
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
0f28723 to
6017689
Compare
notriddle
approved these changes
Feb 27, 2026
Contributor
|
@bors r+ |
Contributor
This comment has been minimized.
This comment has been minimized.
6017689 to
59b37bb
Compare
Collaborator
|
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. |
Contributor
|
@bors r+ |
Contributor
This comment has been minimized.
This comment has been minimized.
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 12, 2026
… 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
Contributor
|
💔 Test for e95d0cd failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
Member
|
@bors retry |
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Mar 12, 2026
…-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
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Mar 12, 2026
…-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
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 12, 2026
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)
Contributor
|
⌛ Testing commit 59b37bb with merge c66e4b8... Workflow: https://github.com/rust-lang/rust/actions/runs/22995536645 |
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 12, 2026
… 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
Member
|
Failed in rollup: #153761 (comment) @bors r- |
Contributor
|
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: |
Member
|
@bors try jobs=dist-x86_64-linux-alt |
This comment has been minimized.
This comment has been minimized.
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 12, 2026
… r=<try> Fix relative extern URL depth on source pages try-job: dist-x86_64-linux-alt
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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