about summary refs log tree commit diff
path: root/src/librustdoc/html/render
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2021-01-28 16:07:24 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2021-02-05 17:23:52 +0100
commit4810910b0b2be1f28a2ed666ad1a3825b00bb933 (patch)
tree959a84a05d7fe79a66680d2c7f3797b662daa70c /src/librustdoc/html/render
parentd5174a4b0d3a72c8edefd65b2c1108f3168b24e0 (diff)
downloadrust-4810910b0b2be1f28a2ed666ad1a3825b00bb933.tar.gz
rust-4810910b0b2be1f28a2ed666ad1a3825b00bb933.zip
Remove Function all_types and ret_types fields
Diffstat (limited to 'src/librustdoc/html/render')
-rw-r--r--src/librustdoc/html/render/cache.rs32
-rw-r--r--src/librustdoc/html/render/mod.rs2
2 files changed, 20 insertions, 14 deletions
diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs
index 4dd7110f331..e47692063bd 100644
--- a/src/librustdoc/html/render/cache.rs
+++ b/src/librustdoc/html/render/cache.rs
@@ -1,11 +1,14 @@
 use std::collections::BTreeMap;
 use std::path::Path;
 
-use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_middle::ty::TyCtxt;
 use rustc_span::symbol::{sym, Symbol};
 use serde::Serialize;
 
-use crate::clean::types::GetDefId;
+use crate::clean::types::{
+    FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, TypeKind, WherePredicate,
+};
 use crate::clean::{self, AttributesExt};
 use crate::formats::cache::Cache;
 use crate::formats::item_type::ItemType;
@@ -62,11 +65,13 @@ crate fn extern_location(
 }
 
 /// Builds the search index from the collected metadata
-crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
+crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<'tcx>) -> String {
     let mut defid_to_pathid = FxHashMap::default();
     let mut crate_items = Vec::with_capacity(cache.search_index.len());
     let mut crate_paths = vec![];
 
+    // For now we don't get the primitive types in the search index.
+    let empty_cache = Cache::default();
     // Attach all orphan items to the type's definition if the type
     // has since been learned.
     for &(did, ref item) in &cache.orphan_impl_items {
@@ -78,7 +83,7 @@ crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
                 desc: item.doc_value().map_or_else(String::new, |s| short_markdown_summary(&s)),
                 parent: Some(did),
                 parent_idx: None,
-                search_type: get_index_search_type(&item, Some(cache)),
+                search_type: get_index_search_type(&item, cache),
             });
             for alias in item.attrs.get_doc_aliases() {
                 cache
@@ -164,14 +169,15 @@ crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
     )
 }
 
-crate fn get_index_search_type(
+crate fn get_index_search_type<'tcx>(
     item: &clean::Item,
-    cache: Option<&Cache>,
+    cache: &Cache,
+    tcx: TyCtxt<'tcx>,
 ) -> Option<IndexItemFunctionType> {
     let (all_types, ret_types) = match *item.kind {
-        clean::FunctionItem(ref f) => (&f.all_types, &f.ret_types),
-        clean::MethodItem(ref m, _) => (&m.all_types, &m.ret_types),
-        clean::TyMethodItem(ref m) => (&m.all_types, &m.ret_types),
+        clean::FunctionItem(ref f) => get_all_types(&f.generics, &f.decl, tcx, &cache),
+        clean::MethodItem(ref m, _) => get_all_types(&m.generics, &m.decl, tcx, &cache),
+        clean::TyMethodItem(ref m) => get_all_types(&m.generics, &m.decl, tcx, &cache),
         _ => return None,
     };
 
@@ -190,9 +196,9 @@ crate fn get_index_search_type(
     Some(IndexItemFunctionType { inputs, output })
 }
 
-fn get_index_type(clean_type: &clean::Type, cache: &Option<&Cache>) -> RenderType {
+fn get_index_type(clean_type: &clean::Type, cache: &Cache) -> RenderType {
     RenderType {
-        ty: cache.map_or_else(|| clean_type.def_id(), |cache| clean_type.def_id_full(cache)),
+        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()),
         generics: get_generics(clean_type, cache),
@@ -227,14 +233,14 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option
     }
 }
 
-fn get_generics(clean_type: &clean::Type, cache: &Option<&Cache>) -> Option<Vec<Generic>> {
+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: cache.map_or_else(|| t.def_id(), |cache| t.def_id_full(cache)),
+                    defid: t.def_id_full(cache),
                     idx: None,
                 })
             })
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 6909ab870db..16366d7b131 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -499,7 +499,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
         krate = sources::render(&dst, &mut scx, krate)?;
 
         // Build our search index
-        let index = build_index(&krate, &mut cache);
+        let index = build_index(&krate, &mut cache, tcx);
 
         let mut cx = Context {
             current: Vec::new(),