chore(rustdoc): remove unused members of RenderType
Commit e629381653
removes the only place
these members variables are actually read.
This commit is contained in:
parent
e629381653
commit
14ca89446c
3 changed files with 7 additions and 52 deletions
|
@ -128,7 +128,6 @@ crate struct Cache {
|
||||||
/// This struct is used to wrap the `cache` and `tcx` in order to run `DocFolder`.
|
/// This struct is used to wrap the `cache` and `tcx` in order to run `DocFolder`.
|
||||||
struct CacheBuilder<'a, 'tcx> {
|
struct CacheBuilder<'a, 'tcx> {
|
||||||
cache: &'a mut Cache,
|
cache: &'a mut Cache,
|
||||||
empty_cache: Cache,
|
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +172,7 @@ impl Cache {
|
||||||
self.primitive_locations.insert(prim, def_id);
|
self.primitive_locations.insert(prim, def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
krate = CacheBuilder { tcx, cache: self, empty_cache: Cache::default() }.fold_crate(krate);
|
krate = CacheBuilder { tcx, cache: self }.fold_crate(krate);
|
||||||
|
|
||||||
for (trait_did, dids, impl_) in self.orphan_trait_impls.drain(..) {
|
for (trait_did, dids, impl_) in self.orphan_trait_impls.drain(..) {
|
||||||
if self.traits.contains_key(&trait_did) {
|
if self.traits.contains_key(&trait_did) {
|
||||||
|
@ -302,7 +301,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
||||||
desc,
|
desc,
|
||||||
parent,
|
parent,
|
||||||
parent_idx: None,
|
parent_idx: None,
|
||||||
search_type: get_index_search_type(&item, &self.empty_cache, self.tcx),
|
search_type: get_index_search_type(&item, self.tcx),
|
||||||
aliases: item.attrs.get_doc_aliases(),
|
aliases: item.attrs.get_doc_aliases(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::clean::types::{
|
||||||
use crate::formats::cache::Cache;
|
use crate::formats::cache::Cache;
|
||||||
use crate::formats::item_type::ItemType;
|
use crate::formats::item_type::ItemType;
|
||||||
use crate::html::markdown::short_markdown_summary;
|
use crate::html::markdown::short_markdown_summary;
|
||||||
use crate::html::render::{Generic, IndexItem, IndexItemFunctionType, RenderType, TypeWithKind};
|
use crate::html::render::{IndexItem, IndexItemFunctionType, RenderType, TypeWithKind};
|
||||||
|
|
||||||
/// Indicates where an external crate can be found.
|
/// Indicates where an external crate can be found.
|
||||||
crate enum ExternalLocation {
|
crate enum ExternalLocation {
|
||||||
|
@ -44,7 +44,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
|
||||||
desc,
|
desc,
|
||||||
parent: Some(did.into()),
|
parent: Some(did.into()),
|
||||||
parent_idx: None,
|
parent_idx: None,
|
||||||
search_type: get_index_search_type(&item, cache, tcx),
|
search_type: get_index_search_type(&item, tcx),
|
||||||
aliases: item.attrs.get_doc_aliases(),
|
aliases: item.attrs.get_doc_aliases(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,6 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
|
||||||
|
|
||||||
crate fn get_index_search_type<'tcx>(
|
crate fn get_index_search_type<'tcx>(
|
||||||
item: &clean::Item,
|
item: &clean::Item,
|
||||||
cache: &Cache,
|
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
) -> Option<IndexItemFunctionType> {
|
) -> Option<IndexItemFunctionType> {
|
||||||
let (all_types, ret_types) = match *item.kind {
|
let (all_types, ret_types) = match *item.kind {
|
||||||
|
@ -204,12 +203,12 @@ crate fn get_index_search_type<'tcx>(
|
||||||
|
|
||||||
let inputs = all_types
|
let inputs = all_types
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(ty, kind)| TypeWithKind::from((get_index_type(&ty, &cache), *kind)))
|
.map(|(ty, kind)| TypeWithKind::from((get_index_type(&ty), *kind)))
|
||||||
.filter(|a| a.ty.name.is_some())
|
.filter(|a| a.ty.name.is_some())
|
||||||
.collect();
|
.collect();
|
||||||
let output = ret_types
|
let output = ret_types
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(ty, kind)| TypeWithKind::from((get_index_type(&ty, &cache), *kind)))
|
.map(|(ty, kind)| TypeWithKind::from((get_index_type(&ty), *kind)))
|
||||||
.filter(|a| a.ty.name.is_some())
|
.filter(|a| a.ty.name.is_some())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let output = if output.is_empty() { None } else { Some(output) };
|
let output = if output.is_empty() { None } else { Some(output) };
|
||||||
|
@ -217,12 +216,9 @@ crate fn get_index_search_type<'tcx>(
|
||||||
Some(IndexItemFunctionType { inputs, output })
|
Some(IndexItemFunctionType { inputs, output })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_index_type(clean_type: &clean::Type, cache: &Cache) -> RenderType {
|
fn get_index_type(clean_type: &clean::Type) -> RenderType {
|
||||||
RenderType {
|
RenderType {
|
||||||
ty: clean_type.def_id_full(cache),
|
|
||||||
idx: None,
|
|
||||||
name: get_index_type_name(clean_type, true).map(|s| s.as_str().to_ascii_lowercase()),
|
name: get_index_type_name(clean_type, true).map(|s| s.as_str().to_ascii_lowercase()),
|
||||||
generics: get_generics(clean_type, cache),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,22 +250,6 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_generics(clean_type: &clean::Type, cache: &Cache) -> Option<Vec<Generic>> {
|
|
||||||
clean_type.generics().and_then(|types| {
|
|
||||||
let r = types
|
|
||||||
.iter()
|
|
||||||
.filter_map(|t| {
|
|
||||||
get_index_type_name(t, false).map(|name| Generic {
|
|
||||||
name: name.as_str().to_ascii_lowercase(),
|
|
||||||
defid: t.def_id_full(cache),
|
|
||||||
idx: None,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
if r.is_empty() { None } else { Some(r) }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The point of this function is to replace bounds with types.
|
/// The point of this function is to replace bounds with types.
|
||||||
///
|
///
|
||||||
/// i.e. `[T, U]` when you have the following bounds: `T: Display, U: Option<T>` will return
|
/// i.e. `[T, U]` when you have the following bounds: `T: Display, U: Option<T>` will return
|
||||||
|
|
|
@ -95,31 +95,7 @@ crate struct IndexItem {
|
||||||
/// A type used for the search index.
|
/// A type used for the search index.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
crate struct RenderType {
|
crate struct RenderType {
|
||||||
ty: Option<DefId>,
|
|
||||||
idx: Option<usize>,
|
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
generics: Option<Vec<Generic>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A type used for the search index.
|
|
||||||
#[derive(Debug)]
|
|
||||||
crate struct Generic {
|
|
||||||
name: String,
|
|
||||||
defid: Option<DefId>,
|
|
||||||
idx: Option<usize>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for Generic {
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: Serializer,
|
|
||||||
{
|
|
||||||
if let Some(id) = self.idx {
|
|
||||||
serializer.serialize_some(&id)
|
|
||||||
} else {
|
|
||||||
serializer.serialize_some(&self.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Full type of functions/methods in the search index.
|
/// Full type of functions/methods in the search index.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue