IndexItem.name String -> Symbol
This commit is contained in:
parent
60cc7783da
commit
4e1258c6b6
@ -242,7 +242,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
||||
}
|
||||
|
||||
// Index this method for searching later on.
|
||||
if let Some(ref s) = item.name.or_else(|| {
|
||||
if let Some(s) = item.name.or_else(|| {
|
||||
if item.is_stripped() {
|
||||
None
|
||||
} else if let clean::ImportItem(ref i) = *item.kind &&
|
||||
@ -317,14 +317,15 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
||||
short_markdown_summary(x.as_str(), &item.link_names(self.cache))
|
||||
});
|
||||
let ty = item.type_();
|
||||
let name = s.to_string();
|
||||
if ty != ItemType::StructField || u16::from_str_radix(&name, 10).is_err() {
|
||||
if ty != ItemType::StructField
|
||||
|| u16::from_str_radix(s.as_str(), 10).is_err()
|
||||
{
|
||||
// In case this is a field from a tuple struct, we don't add it into
|
||||
// the search index because its name is something like "0", which is
|
||||
// not useful for rustdoc search.
|
||||
self.cache.search_index.push(IndexItem {
|
||||
ty,
|
||||
name,
|
||||
name: s,
|
||||
path: join_with_double_colon(path),
|
||||
desc,
|
||||
parent,
|
||||
|
@ -100,7 +100,7 @@ pub(crate) fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct IndexItem {
|
||||
pub(crate) ty: ItemType,
|
||||
pub(crate) name: String,
|
||||
pub(crate) name: Symbol,
|
||||
pub(crate) path: String,
|
||||
pub(crate) desc: String,
|
||||
pub(crate) parent: Option<DefId>,
|
||||
|
@ -35,7 +35,7 @@ pub(crate) fn build_index<'tcx>(
|
||||
.map_or_else(String::new, |s| short_markdown_summary(&s, &item.link_names(cache)));
|
||||
cache.search_index.push(IndexItem {
|
||||
ty: item.type_(),
|
||||
name: item.name.unwrap().to_string(),
|
||||
name: item.name.unwrap(),
|
||||
path: join_with_double_colon(&fqp[..fqp.len() - 1]),
|
||||
desc,
|
||||
parent: Some(parent),
|
||||
@ -58,8 +58,8 @@ pub(crate) fn build_index<'tcx>(
|
||||
// Sort search index items. This improves the compressibility of the search index.
|
||||
cache.search_index.sort_unstable_by(|k1, k2| {
|
||||
// `sort_unstable_by_key` produces lifetime errors
|
||||
let k1 = (&k1.path, &k1.name, &k1.ty, &k1.parent);
|
||||
let k2 = (&k2.path, &k2.name, &k2.ty, &k2.parent);
|
||||
let k1 = (&k1.path, k1.name.as_str(), &k1.ty, &k1.parent);
|
||||
let k2 = (&k2.path, k2.name.as_str(), &k2.ty, &k2.parent);
|
||||
std::cmp::Ord::cmp(&k1, &k2)
|
||||
});
|
||||
|
||||
@ -240,7 +240,7 @@ pub(crate) fn build_index<'tcx>(
|
||||
)?;
|
||||
crate_data.serialize_field(
|
||||
"n",
|
||||
&self.items.iter().map(|item| &item.name).collect::<Vec<_>>(),
|
||||
&self.items.iter().map(|item| item.name.as_str()).collect::<Vec<_>>(),
|
||||
)?;
|
||||
crate_data.serialize_field(
|
||||
"q",
|
||||
|
Loading…
x
Reference in New Issue
Block a user