Skip to content

[rustdoc] Correctly link to (imported) enum variants with "jump to def" - #163682

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
GuillaumeGomez:jump-to-variant
Oct 4, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
GuillaumeGomez:jump-to-variant

Conversation

@GuillaumeGomez

Copy link
Copy Markdown
Member

New bug I found while working on #162808.

Explanations: this one was quite tricky as it took me a while to understand that variants could be imported and present in Cache::external_paths. So the path was entered while generating a link for "jump to def", generating a URL looking like this: module/enum_name/variant.variant_name.html, which is obviously very wrong as it should be module/enum.enum_name.html#variant.variant_name.

r? @Urgau

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Oct 2, 2026
return Err(HrefError::Private);
} else {
return generate_item_def_id_path(did, original_did, cx, root_path);
}

@Urgau Urgau Oct 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure I understood what's happening, with the test case we would end-up in this else branch, right?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

// performed there.
let def_id_to_get = if root_path.is_some() { original_did } else { did };
if let Some(&(ref fqp, shortty)) = cache.external_paths.get(&def_id_to_get) {
if (root_path.is_none() || original_did == did)

@Urgau Urgau Oct 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to add a little comment for why we are checking original_did == did, it's not obvious at first glace.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, adding it.

…s` when using the `--generate-link-to-definition` feature
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Extended doc comments to make it more clear what was expected.

@Urgau Urgau left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 56bb244 has been approved by Urgau

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 3, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 3, 2026
…Urgau

[rustdoc] Correctly link to (imported) enum variants with "jump to def"

New bug I found while working on rust-lang#162808.

Explanations: this one was quite tricky as it took me a while to understand that variants could be imported and present in `Cache::external_paths`. So the path was entered while generating a link for "jump to def", generating a URL looking like this: `module/enum_name/variant.variant_name.html`, which is obviously very wrong as it should be `module/enum.enum_name.html#variant.variant_name`.

r? @Urgau
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 3, 2026
…Urgau

[rustdoc] Correctly link to (imported) enum variants with "jump to def"

New bug I found while working on rust-lang#162808.

Explanations: this one was quite tricky as it took me a while to understand that variants could be imported and present in `Cache::external_paths`. So the path was entered while generating a link for "jump to def", generating a URL looking like this: `module/enum_name/variant.variant_name.html`, which is obviously very wrong as it should be `module/enum.enum_name.html#variant.variant_name`.

r? @Urgau
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
Rollup of 18 pull requests

Successful merges:

 - #158102 (When compiling without a specified `--edition`, emit a message)
 - #162027 (std: add `fs::rename_noreplace`)
 - #162761 (Lower attributes for functions without bodies)
 - #163161 (implement FCW for `rustc_allowed_through_unstable_modules` items)
 - #163613 (Tweak the rendering of "not general enough" errors on the old trait solver)
 - #162062 (core: fix the docs of PanicInfo::location)
 - #163140 (document safety requirements for atomic intrinsics)
 - #163342 (Don't imply incorrect things about `Global` in the docs of `System`)
 - #163445 (Add safety comments for alloc::str)
 - #163503 (Mark Rc strong/weak count methods must_use)
 - #163548 (fs::set_permissions_nofollow: Android support, test cleanup)
 - #163585 ([triagebot] Create `debugger_visualizer` assign group)
 - #163597 (Add `SplitPathsRef` implementation for motor to make std build)
 - #163602 (Move media & home dirs tests to fs tests.)
 - #163667 (Finalize changes on expect messages for library/core/src/fmt/mod.rs)
 - #163682 ([rustdoc] Correctly link to (imported) enum variants with "jump to def")
 - #163683 (Fix GCC codegen backend comment in bootstrap)
 - #163703 (Move more `rustdoc-html tests` in the right location)

Failed merges:

 - #161491 (Rip out old solver coherence)
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
Rollup of 18 pull requests

Successful merges:

 - #158102 (When compiling without a specified `--edition`, emit a message)
 - #162761 (Lower attributes for functions without bodies)
 - #163161 (implement FCW for `rustc_allowed_through_unstable_modules` items)
 - #163613 (Tweak the rendering of "not general enough" errors on the old trait solver)
 - #162062 (core: fix the docs of PanicInfo::location)
 - #163140 (document safety requirements for atomic intrinsics)
 - #163342 (Don't imply incorrect things about `Global` in the docs of `System`)
 - #163445 (Add safety comments for alloc::str)
 - #163503 (Mark Rc strong/weak count methods must_use)
 - #163548 (fs::set_permissions_nofollow: Android support, test cleanup)
 - #163585 ([triagebot] Create `debugger_visualizer` assign group)
 - #163597 (Add `SplitPathsRef` implementation for motor to make std build)
 - #163602 (Move media & home dirs tests to fs tests.)
 - #163667 (Finalize changes on expect messages for library/core/src/fmt/mod.rs)
 - #163682 ([rustdoc] Correctly link to (imported) enum variants with "jump to def")
 - #163683 (Fix GCC codegen backend comment in bootstrap)
 - #163703 (Move more `rustdoc-html tests` in the right location)
 - #163725 (some crashes fixed with next-solver)

Failed merges:

 - #161491 (Rip out old solver coherence)
@rust-bors
rust-bors Bot merged commit 969f99c into rust-lang:main Oct 4, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
Rollup merge of #163682 - GuillaumeGomez:jump-to-variant, r=Urgau

[rustdoc] Correctly link to (imported) enum variants with "jump to def"

New bug I found while working on #162808.

Explanations: this one was quite tricky as it took me a while to understand that variants could be imported and present in `Cache::external_paths`. So the path was entered while generating a link for "jump to def", generating a URL looking like this: `module/enum_name/variant.variant_name.html`, which is obviously very wrong as it should be `module/enum.enum_name.html#variant.variant_name`.

r? @Urgau
@GuillaumeGomez
GuillaumeGomez deleted the jump-to-variant branch October 4, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants