Skip to content

Fix jump-to-def links broken by turbofish syntax#156727

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
abdul2801:docs
May 20, 2026
Merged

Fix jump-to-def links broken by turbofish syntax#156727
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
abdul2801:docs

Conversation

@abdul2801
Copy link
Copy Markdown
Contributor

@abdul2801 abdul2801 commented May 18, 2026

Fixes #156706

@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 May 18, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 18, 2026

r? @GuillaumeGomez

rustbot has assigned @GuillaumeGomez.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 9 candidates
  • Random selection from GuillaumeGomez, fmease, lolbinarycat, notriddle

@rust-log-analyzer

This comment has been minimized.


pub fn foo() {
// `PhantomData::<usize>` — `PhantomData` must be linked despite the turbofish.
//@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'PhantomData'
Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez May 18, 2026

Choose a reason for hiding this comment

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

The type appears 3 times, so the test is not really checking much. Use a type alias instead for the specific one that you need to be tested. For example:

type TheOne = PhantomData;

let _: TheOne::<usize> = PhantomData;

The idea is to make TheOne appears only once. Then you can check like you did with //@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'TheOne'.

View changes since the review

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.

An alternative would be to use count but I think it'd be less robust (and readable).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Switched to checking the local reference link since a type alias links to its own
definition rather than to struct.PhantomData.html.

Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

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

Fix looks good, please just fix the test and squash your commits once done.

View changes since this review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 18, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 18, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@fmease
Copy link
Copy Markdown
Member

fmease commented May 18, 2026

You've linked to the wrong issue (#156707). I've updated the PR description to make it reference #156706 instead.

@rust-log-analyzer

This comment has been minimized.

Handle turbofish syntax correctly in rustdoc jump-to-def links
and add regression tests covering type aliases.
// `PhantomData::<usize>` — `PhantomData` must be linked despite the turbofish.
type TheOne = PhantomData<()>;

//@ has - '//a[@href="#13"]' 'TheOne'
Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez May 19, 2026

Choose a reason for hiding this comment

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

That doesn't fix anything. ^^'

View changes since the review

Copy link
Copy Markdown
Contributor Author

@abdul2801 abdul2801 May 19, 2026

Choose a reason for hiding this comment

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

Is using an import alias fine

use std::marker::PhantomData as TheOne;

pub fn foo() {
    //@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'TheOne'
    let _: TheOne::<usize>;
}

cuz the idea you mentioned

use std::marker::PhantomData;

type TheOne = PhantomData<()>;

pub fn foo() {
    //@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'TheOne'
    let _: TheOne::<usize> = PhantomData;
}

it ends up genenrating this html

<a href="https://doc.rust-lang.org/nightly/core/marker/struct.PhantomData.html">std::marker::PhantomData</a>
'<a href="../../foo/fn.foo.html">foo</a>'
'<a href="https://doc.rust-lang.org/nightly/core/marker/struct.PhantomData.html">PhantomData</a>'
'<a href="#13">TheOne</a>'
'<a href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>'
'<a href="https://doc.rust-lang.org/nightly/core/marker/struct.PhantomData.html">PhantomData</a>'`

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.

Ah yes, much better. An aliased import is much better!

@GuillaumeGomez
Copy link
Copy Markdown
Member

Thanks!

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 19, 2026

📌 Commit afedb87 has been approved by GuillaumeGomez

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 10. This pull request will be tested once the tree is reopened.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 19, 2026
@rust-bors

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 20, 2026

☀️ Test successful - CI
Approved by: GuillaumeGomez
Duration: 3h 16m 7s
Pushing 1f8e04d to main...

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 20, 2026
@rust-bors rust-bors Bot merged commit 1f8e04d into rust-lang:main May 20, 2026
12 checks passed
@rustbot rustbot added this to the 1.97.0 milestone May 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 4b97926 (parent) -> 1f8e04d (this PR)

Test differences

Show 5 test diffs

Stage 1

  • [rustdoc-html] tests/rustdoc-html/jump-to-def/turbofish.rs: [missing] -> pass (J1)

Stage 2

  • [rustdoc-html] tests/rustdoc-html/jump-to-def/turbofish.rs: [missing] -> pass (J0)

Additionally, 3 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 1f8e04d34ab0c1fd9574840aa6db670e41593bfb --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-apple-various: 2h 32m -> 1h 50m (-27.7%)
  2. dist-i686-msvc: 1h 51m -> 2h 19m (+25.1%)
  3. dist-aarch64-apple: 1h 57m -> 1h 29m (-23.6%)
  4. dist-x86_64-illumos: 1h 27m -> 1h 45m (+20.6%)
  5. dist-x86_64-apple: 2h 9m -> 1h 42m (-20.3%)
  6. dist-powerpc64le-linux-gnu: 1h 38m -> 1h 20m (-18.0%)
  7. dist-ohos-armv7: 1h 13m -> 1h (-17.5%)
  8. dist-powerpc64-linux-musl: 1h 22m -> 1h 35m (+15.1%)
  9. pr-check-1: 27m 53s -> 31m 53s (+14.3%)
  10. dist-aarch64-freebsd: 57m 10s -> 1h 4m (+12.9%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1f8e04d): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.7% [0.7%, 0.7%] 1
Regressions ❌
(secondary)
0.4% [0.4%, 0.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) 0.7% [0.7%, 0.7%] 1

Max RSS (memory usage)

Results (primary 0.2%, secondary -4.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.6% [2.6%, 2.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.3% [-2.3%, -2.3%] 1
Improvements ✅
(secondary)
-4.2% [-5.6%, -2.1%] 3
All ❌✅ (primary) 0.2% [-2.3%, 2.6%] 2

Cycles

Results (secondary -0.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.7% [3.7%, 3.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.3% [-4.3%, -4.3%] 1
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.0%, secondary -0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 8
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 1
All ❌✅ (primary) -0.0% [-0.0%, -0.0%] 8

Bootstrap: 510.83s -> 509.888s (-0.18%)
Artifact size: 400.58 MiB -> 400.62 MiB (0.01%)

@rustbot rustbot added the perf-regression Performance regression. label May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. 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.

rustdoc fails to linkify paths containing turbofish on source code pages under --generate-link-to-definition

7 participants