Skip to content

rustdoc: Make two small cleanups #91073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,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.
Expand Down Expand Up @@ -1110,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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