fix: improve turbofish jump-to-def handling

Handle turbofish syntax correctly in rustdoc jump-to-def links
and add regression tests covering type aliases.
This commit is contained in:
Abdul Rafey Ahmed
2026-05-19 02:13:40 +05:30
committed by abdul2801
parent 7517636f51
commit c454d92f61
2 changed files with 19 additions and 2 deletions
+2 -2
View File
@@ -1001,8 +1001,8 @@ fn get_full_ident_path(&mut self) -> Option<usize> {
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 {
@@ -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'
let _: TheOne::<usize> = PhantomData;
}