about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2021-03-06 21:59:01 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2021-03-10 10:17:37 +0100
commitbbbefa3edc48cb1afd57f1d99bf418731be1ef8f (patch)
tree487c0758a826ae64fb4eaf22423b079a69915b89 /src
parent4b9f5cc4c10a161047475cb9bbe02c4fda57fb07 (diff)
downloadrust-bbbefa3edc48cb1afd57f1d99bf418731be1ef8f.tar.gz
rust-bbbefa3edc48cb1afd57f1d99bf418731be1ef8f.zip
Allow doc alias attributes to use both list and value
Diffstat (limited to 'src')
-rw-r--r--src/doc/rustdoc/src/advanced-features.md7
-rw-r--r--src/librustdoc/clean/types.rs16
2 files changed, 21 insertions, 2 deletions
diff --git a/src/doc/rustdoc/src/advanced-features.md b/src/doc/rustdoc/src/advanced-features.md
index abdc2e4025d..6147bd0a97a 100644
--- a/src/doc/rustdoc/src/advanced-features.md
+++ b/src/doc/rustdoc/src/advanced-features.md
@@ -81,3 +81,10 @@ Then, when looking for it through the `rustdoc` search, if you enter "x" or
 "big", search will show the `BigX` struct first.
 
 There are some limitations on the doc alias names though: you can't use `"` or whitespace.
+
+You can add multiple aliases at the same time by using a list:
+
+```rust,no_run
+#[doc(alias("x", "big"))]
+pub struct BigX;
+```
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index a94ee918c24..b67af484510 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -914,8 +914,20 @@ impl Attributes {
         self.other_attrs
             .lists(sym::doc)
             .filter(|a| a.has_name(sym::alias))
-            .filter_map(|a| a.value_str().map(|s| s.to_string()))
-            .filter(|v| !v.is_empty())
+            .map(|a| {
+                if let Some(values) = a.meta_item_list() {
+                    values
+                        .iter()
+                        .map(|l| match l.literal().unwrap().kind {
+                            ast::LitKind::Str(s, _) => s.as_str().to_string(),
+                            _ => unreachable!(),
+                        })
+                        .collect::<Vec<_>>()
+                } else {
+                    vec![a.value_str().map(|s| s.to_string()).unwrap()]
+                }
+            })
+            .flatten()
             .collect::<FxHashSet<_>>()
     }
 }