about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-03-15 11:34:37 -0700
committerMichael Howell <michael@notriddle.com>2023-03-15 11:34:37 -0700
commit683c12cb910f2ee3fbbaf659dafdfef6eb3d6ec5 (patch)
treeba29647f511e568eb7c626722df7bd0c0151a158
parente4b9f86054c581d931f8bad0c87523c53e1e8e3f (diff)
downloadrust-683c12cb910f2ee3fbbaf659dafdfef6eb3d6ec5.tar.gz
rust-683c12cb910f2ee3fbbaf659dafdfef6eb3d6ec5.zip
rustdoc: remove `std::` from primitive intra-doc link tooltips
-rw-r--r--src/librustdoc/html/format.rs6
-rw-r--r--tests/rustdoc/intra-doc/prim-methods.rs2
2 files changed, 8 insertions, 0 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index 024ea62c31a..27010b771d3 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -771,6 +771,12 @@ pub(crate) fn link_tooltip(did: DefId, fragment: &Option<UrlFragment>, cx: &Cont
         .or_else(|| cache.external_paths.get(&did))
         else { return String::new() };
     let mut buf = Buffer::new();
+    let fqp = if *shortty == ItemType::Primitive {
+        // primitives are documented in a crate, but not actually part of it
+        &fqp[fqp.len() - 1..]
+    } else {
+        &fqp
+    };
     if let &Some(UrlFragment::Item(id)) = fragment {
         write!(buf, "{} ", cx.tcx().def_descr(id));
         for component in fqp {
diff --git a/tests/rustdoc/intra-doc/prim-methods.rs b/tests/rustdoc/intra-doc/prim-methods.rs
index a412a23fda8..bc1965aac55 100644
--- a/tests/rustdoc/intra-doc/prim-methods.rs
+++ b/tests/rustdoc/intra-doc/prim-methods.rs
@@ -2,6 +2,8 @@
 
 // @has prim_methods/index.html
 // @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html"]' 'char'
+// @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html"]/@title' 'primitive char'
 // @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8'
+// @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html#method.len_utf8"]/@title' 'method char::len_utf8'
 
 //! A [`char`] and its [`char::len_utf8`].