]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: Remove some unnecessary `cache` parameters
authorNoah Lev <camelidcamel@gmail.com>
Tue, 28 Dec 2021 02:53:00 +0000 (18:53 -0800)
committerNoah Lev <camelidcamel@gmail.com>
Tue, 28 Dec 2021 02:53:00 +0000 (18:53 -0800)
Based on
https://github.com/rust-lang/rust/pull/80883#issuecomment-774437832.
The `tcx` parameters do seem to be used though, so I only removed the
`cache` parameters.

src/librustdoc/formats/cache.rs
src/librustdoc/html/render/search_index.rs

index 8a5c8651f99925b6770a775492bf520ba36c2cd5..528d48a8d059e45dc25d533011588e1c52fe2429 100644 (file)
@@ -303,7 +303,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                             desc,
                             parent,
                             parent_idx: None,
-                            search_type: get_index_search_type(&item, self.tcx, self.cache),
+                            search_type: get_index_search_type(&item, self.tcx),
                             aliases: item.attrs.get_doc_aliases(),
                         });
                     }
index 631eacc9618286120d88c3b020fbcc8f1cf93671..5d4df3ee5ff3ae8441bbaf7d4c820bf4724b6a02 100644 (file)
@@ -42,7 +42,7 @@
                 desc,
                 parent: Some(did),
                 parent_idx: None,
-                search_type: get_index_search_type(item, tcx, cache),
+                search_type: get_index_search_type(item, tcx),
                 aliases: item.attrs.get_doc_aliases(),
             });
         }
@@ -194,12 +194,11 @@ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
 crate fn get_index_search_type<'tcx>(
     item: &clean::Item,
     tcx: TyCtxt<'tcx>,
-    cache: &Cache,
 ) -> Option<IndexItemFunctionType> {
     let (mut inputs, mut output) = match *item.kind {
-        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),
+        clean::FunctionItem(ref f) => get_all_types(&f.generics, &f.decl, tcx),
+        clean::MethodItem(ref m, _) => get_all_types(&m.generics, &m.decl, tcx),
+        clean::TyMethodItem(ref m) => get_all_types(&m.generics, &m.decl, tcx),
         _ => return None,
     };
 
@@ -254,14 +253,12 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option
     tcx: TyCtxt<'tcx>,
     recurse: usize,
     res: &mut Vec<TypeWithKind>,
-    cache: &Cache,
 ) {
     fn insert_ty(
         res: &mut Vec<TypeWithKind>,
         tcx: TyCtxt<'_>,
         ty: Type,
         mut generics: Vec<TypeWithKind>,
-        _cache: &Cache,
     ) {
         let is_full_generic = ty.is_full_generic();
 
@@ -350,21 +347,14 @@ fn insert_ty(
                     for param_def in poly_trait.generic_params.iter() {
                         match &param_def.kind {
                             clean::GenericParamDefKind::Type { default: Some(ty), .. } => {
-                                get_real_types(
-                                    generics,
-                                    ty,
-                                    tcx,
-                                    recurse + 1,
-                                    &mut ty_generics,
-                                    cache,
-                                )
+                                get_real_types(generics, ty, tcx, recurse + 1, &mut ty_generics)
                             }
                             _ => {}
                         }
                     }
                 }
             }
-            insert_ty(res, tcx, arg.clone(), ty_generics, cache);
+            insert_ty(res, tcx, arg.clone(), ty_generics);
         }
         // Otherwise we check if the trait bounds are "inlined" like `T: Option<u32>`...
         if let Some(bound) = generics.params.iter().find(|g| g.is_type() && g.name == arg_s) {
@@ -372,10 +362,10 @@ fn insert_ty(
             for bound in bound.get_bounds().unwrap_or(&[]) {
                 if let Some(path) = bound.get_trait_path() {
                     let ty = Type::Path { path };
-                    get_real_types(generics, &ty, tcx, recurse + 1, &mut ty_generics, cache);
+                    get_real_types(generics, &ty, tcx, recurse + 1, &mut ty_generics);
                 }
             }
-            insert_ty(res, tcx, arg.clone(), ty_generics, cache);
+            insert_ty(res, tcx, arg.clone(), ty_generics);
         }
     } else {
         // This is not a type parameter. So for example if we have `T, U: Option<T>`, and we're
@@ -386,10 +376,10 @@ fn insert_ty(
         let mut ty_generics = Vec::new();
         if let Some(arg_generics) = arg.generics() {
             for gen in arg_generics.iter() {
-                get_real_types(generics, gen, tcx, recurse + 1, &mut ty_generics, cache);
+                get_real_types(generics, gen, tcx, recurse + 1, &mut ty_generics);
             }
         }
-        insert_ty(res, tcx, arg.clone(), ty_generics, cache);
+        insert_ty(res, tcx, arg.clone(), ty_generics);
     }
 }
 
@@ -401,7 +391,6 @@ fn insert_ty(
     generics: &Generics,
     decl: &FnDecl,
     tcx: TyCtxt<'tcx>,
-    cache: &Cache,
 ) -> (Vec<TypeWithKind>, Vec<TypeWithKind>) {
     let mut all_types = Vec::new();
     for arg in decl.inputs.values.iter() {
@@ -409,7 +398,7 @@ fn insert_ty(
             continue;
         }
         let mut args = Vec::new();
-        get_real_types(generics, &arg.type_, tcx, 0, &mut args, cache);
+        get_real_types(generics, &arg.type_, tcx, 0, &mut args);
         if !args.is_empty() {
             all_types.extend(args);
         } else {
@@ -423,7 +412,7 @@ fn insert_ty(
     let mut ret_types = Vec::new();
     match decl.output {
         FnRetTy::Return(ref return_type) => {
-            get_real_types(generics, return_type, tcx, 0, &mut ret_types, cache);
+            get_real_types(generics, return_type, tcx, 0, &mut ret_types);
             if ret_types.is_empty() {
                 if let Some(kind) =
                     return_type.def_id_no_primitives().map(|did| tcx.def_kind(did).into())