diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 1c162a79c4c44..bf0f70f1a00be 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -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::` → 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 0000000000000..a2e8caa38bc9e --- /dev/null +++ b/tests/rustdoc-html/jump-to-def/turbofish.rs @@ -0,0 +1,15 @@ +// 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 as TheOne; + + +pub fn foo() { + //@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'TheOne' + let _: TheOne::; +}