diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index bb5597b5758..d28f3ce8778 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -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::>().into() + aliases.into_iter().collect::>().into() } } diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs index 0286d2a4c81..9aa69d94215 100644 --- a/src/librustdoc/html/render/cache.rs +++ b/src/librustdoc/html/render/cache.rs @@ -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); } } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index dd592de41bd..ffd09663f82 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -103,7 +103,7 @@ crate struct IndexItem { crate parent: Option, crate parent_idx: Option, crate search_type: Option, - crate aliases: Box<[String]>, + crate aliases: Box<[Symbol]>, } /// A type used for the search index.