about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-04-27 02:47:11 +0200
committerGitHub <noreply@github.com>2022-04-27 02:47:11 +0200
commit875b22ff3023eab82fe98a33f040ee5c6560683a (patch)
tree226231b33873e27c0a8800ebe40854b94448bd5f
parentdc1f98c6558730fa446e05856d28b09b0ca4ebc8 (diff)
parentc2a9a685819abcf2050bd342385724db9bf35547 (diff)
downloadrust-875b22ff3023eab82fe98a33f040ee5c6560683a.tar.gz
rust-875b22ff3023eab82fe98a33f040ee5c6560683a.zip
Rollup merge of #96410 - notriddle:notriddle/issue-95873, r=GuillaumeGomez
rustdoc: do not write `{{root}}` in `pub use ::foo` docs

Fixes #95873
-rw-r--r--src/librustdoc/html/format.rs3
-rw-r--r--src/test/rustdoc/issue-95873.rs2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index d3545236e3d..118807a8286 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -18,6 +18,7 @@ use rustc_hir::def_id::DefId;
 use rustc_middle::ty;
 use rustc_middle::ty::DefIdTree;
 use rustc_middle::ty::TyCtxt;
+use rustc_span::symbol::kw;
 use rustc_span::{sym, Symbol};
 use rustc_target::spec::abi::Abi;
 
@@ -679,7 +680,7 @@ fn resolved_path<'cx>(
 
     if print_all {
         for seg in &path.segments[..path.segments.len() - 1] {
-            write!(w, "{}::", seg.name)?;
+            write!(w, "{}::", if seg.name == kw::PathRoot { "" } else { seg.name.as_str() })?;
         }
     }
     if w.alternate() {
diff --git a/src/test/rustdoc/issue-95873.rs b/src/test/rustdoc/issue-95873.rs
new file mode 100644
index 00000000000..ff33fb63a0b
--- /dev/null
+++ b/src/test/rustdoc/issue-95873.rs
@@ -0,0 +1,2 @@
+// @has issue_95873/index.html "//*[@class='item-left import-item']" "pub use ::std as x;"
+pub use ::std as x;