rustdoc: Record aliases as Symbols

This commit is contained in:
Noah Lev 2021-11-19 21:54:43 -05:00
parent 8b8f1e069f
commit a65421651a
3 changed files with 6 additions and 6 deletions

View File

@ -1114,7 +1114,7 @@ fn update_need_backline(doc_strings: &mut Vec<DocFragment>) {
if self.doc_strings.is_empty() { None } else { Some(self.doc_strings.iter().collect()) } if self.doc_strings.is_empty() { None } else { Some(self.doc_strings.iter().collect()) }
} }
crate fn get_doc_aliases(&self) -> Box<[String]> { crate fn get_doc_aliases(&self) -> Box<[Symbol]> {
let mut aliases = FxHashSet::default(); let mut aliases = FxHashSet::default();
for attr in self.other_attrs.lists(sym::doc).filter(|a| a.has_name(sym::alias)) { for attr in self.other_attrs.lists(sym::doc).filter(|a| a.has_name(sym::alias)) {
@ -1122,16 +1122,16 @@ fn update_need_backline(doc_strings: &mut Vec<DocFragment>) {
for l in values { for l in values {
match l.literal().unwrap().kind { match l.literal().unwrap().kind {
ast::LitKind::Str(s, _) => { ast::LitKind::Str(s, _) => {
aliases.insert(s.as_str().to_string()); aliases.insert(s);
} }
_ => unreachable!(), _ => unreachable!(),
} }
} }
} else { } else {
aliases.insert(attr.value_str().map(|s| s.to_string()).unwrap()); aliases.insert(attr.value_str().unwrap());
} }
} }
aliases.into_iter().collect::<Vec<String>>().into() aliases.into_iter().collect::<Vec<_>>().into()
} }
} }

View File

@ -70,7 +70,7 @@
// Set up alias indexes. // Set up alias indexes.
for (i, item) in search_index.iter().enumerate() { for (i, item) in search_index.iter().enumerate() {
for alias in &item.aliases[..] { for alias in &item.aliases[..] {
aliases.entry(alias.to_lowercase()).or_insert_with(Vec::new).push(i); aliases.entry(alias.as_str().to_lowercase()).or_default().push(i);
} }
} }

View File

@ -103,7 +103,7 @@
crate parent: Option<DefId>, crate parent: Option<DefId>,
crate parent_idx: Option<usize>, crate parent_idx: Option<usize>,
crate search_type: Option<IndexItemFunctionType>, crate search_type: Option<IndexItemFunctionType>,
crate aliases: Box<[String]>, crate aliases: Box<[Symbol]>,
} }
/// A type used for the search index. /// A type used for the search index.