Allow doc alias attributes to use both list and value

This commit is contained in:
Guillaume Gomez 2021-03-06 21:59:01 +01:00
parent 4b9f5cc4c1
commit bbbefa3edc
3 changed files with 107 additions and 9 deletions

View file

@ -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<_>>()
}
}