diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 1c162a79c4c4..bf0f70f1a00b 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -1001,8 +1001,8 @@ fn get_full_ident_path(&mut self) -> Option { 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::` → keep `Option`). + break Some(nb_items - nb); } else if has_ident { break Some(nb_items); } else { diff --git a/tests/rustdoc-html/jump-to-def/turbofish.rs b/tests/rustdoc-html/jump-to-def/turbofish.rs new file mode 100644 index 000000000000..1ad7a112a434 --- /dev/null +++ b/tests/rustdoc-html/jump-to-def/turbofish.rs @@ -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::` — `PhantomData` must be linked despite the turbofish. + type TheOne = PhantomData<()>; + + //@ has - '//a[@href="#13"]' 'TheOne' + let _: TheOne:: = PhantomData; +}