Skip to content

Commit

Permalink
rustdoc: Record aliases as Symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
camelid committed Nov 20, 2021
1 parent 8b8f1e0 commit a654216
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/librustdoc/clean/types.rs
Expand Up @@ -1114,24 +1114,24 @@ impl Attributes {
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();

for attr in self.other_attrs.lists(sym::doc).filter(|a| a.has_name(sym::alias)) {
if let Some(values) = attr.meta_item_list() {
for l in values {
match l.literal().unwrap().kind {
ast::LitKind::Str(s, _) => {
aliases.insert(s.as_str().to_string());
aliases.insert(s);
}
_ => unreachable!(),
}
}
} 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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/cache.rs
Expand Up @@ -70,7 +70,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
// Set up alias indexes.
for (i, item) in search_index.iter().enumerate() {
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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/mod.rs
Expand Up @@ -103,7 +103,7 @@ crate struct IndexItem {
crate parent: Option<DefId>,
crate parent_idx: Option<usize>,
crate search_type: Option<IndexItemFunctionType>,
crate aliases: Box<[String]>,
crate aliases: Box<[Symbol]>,
}

/// A type used for the search index.
Expand Down

0 comments on commit a654216

Please sign in to comment.