Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustdoc/html/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,8 +1001,8 @@ impl<'src> Classifier<'src> {
has_ident = true;
nb_items += 1;
} else if nb > 0 && has_ident {
// Following `;` will be handled on its own.
break Some(nb_items - 1);
// Drop all the colons we just peeked (e.g. `Option::<T>` → keep `Option`).
break Some(nb_items - nb);
} else if has_ident {
break Some(nb_items);
} else {
Expand Down
17 changes: 17 additions & 0 deletions tests/rustdoc-html/jump-to-def/turbofish.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// This test ensures that turbofish (`::<...>`) does not prevent jump-to-definition
// links from being generated.

//@ compile-flags: -Zunstable-options --generate-link-to-definition

#![crate_name = "foo"]

//@ has 'src/foo/turbofish.rs.html'
use std::marker::PhantomData;

pub fn foo() {
// `PhantomData::<usize>` — `PhantomData` must be linked despite the turbofish.
type TheOne = PhantomData<()>;

//@ has - '//a[@href="#13"]' 'TheOne'

@GuillaumeGomez GuillaumeGomez May 19, 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.

That doesn't fix anything. ^^'

View changes since the review

@abdul2801 abdul2801 May 19, 2026

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.

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!

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