Auto merge of #91073 - camelid:small-cleanups, r=jyn514

rustdoc: Make two small cleanups
This commit is contained in:
bors 2021-11-21 01:22:59 +00:00
commit 02913c0788
3 changed files with 10 additions and 6 deletions

View File

@ -917,6 +917,10 @@ crate struct DocFragment {
crate indent: usize,
}
// `DocFragment` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(DocFragment, 32);
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
crate enum DocFragmentKind {
/// A doc fragment created from a `///` or `//!` doc comment.
@ -1109,7 +1113,7 @@ 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)) {
@ -1117,16 +1121,16 @@ impl Attributes {
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()
}
}

View File

@ -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);
}
}

View File

@ -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.