about summary refs log tree commit diff
path: root/src/librustdoc/html/render
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2022-02-14 21:42:18 +0100
committerGuillaume Gomez <guillaume.gomez@huawei.com>2022-02-14 21:43:12 +0100
commitbc4b0a774cb371e047310c6777477c754aedbb7e (patch)
treea01de1616126e9bc8cf3c334a575ad12f9f5235b /src/librustdoc/html/render
parent52dd59ed2154f4158ae37e6994b678a6249a7bb0 (diff)
downloadrust-bc4b0a774cb371e047310c6777477c754aedbb7e.tar.gz
rust-bc4b0a774cb371e047310c6777477c754aedbb7e.zip
Fix macro reexports duplicates in the sidebar
Diffstat (limited to 'src/librustdoc/html/render')
-rw-r--r--src/librustdoc/html/render/context.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 2455d56bd2b..a7f852a432c 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -250,6 +250,8 @@ impl<'tcx> Context<'tcx> {
     fn build_sidebar_items(&self, m: &clean::Module) -> BTreeMap<String, Vec<NameDoc>> {
         // BTreeMap instead of HashMap to get a sorted output
         let mut map: BTreeMap<_, Vec<_>> = BTreeMap::new();
+        let mut inserted: FxHashMap<ItemType, FxHashSet<Symbol>> = FxHashMap::default();
+
         for item in &m.items {
             if item.is_stripped() {
                 continue;
@@ -258,13 +260,16 @@ impl<'tcx> Context<'tcx> {
             let short = item.type_();
             let myname = match item.name {
                 None => continue,
-                Some(ref s) => s.to_string(),
+                Some(s) => s,
             };
-            let short = short.to_string();
-            map.entry(short).or_default().push((
-                myname,
-                Some(item.doc_value().map_or_else(String::new, |s| plain_text_summary(&s))),
-            ));
+            if inserted.entry(short).or_default().insert(myname) {
+                let short = short.to_string();
+                let myname = myname.to_string();
+                map.entry(short).or_default().push((
+                    myname,
+                    Some(item.doc_value().map_or_else(String::new, |s| plain_text_summary(&s))),
+                ));
+            }
         }
 
         if self.shared.sort_modules_alphabetically {