mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 14:10:03 +03:00
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:
committed by
abdul2801
parent
7517636f51
commit
c454d92f61
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user