Skip to content

Commit e19593f

Browse files
committed
rustdoc: Remove some unnecessary cache parameters
Based on rust-lang#80883 (comment). The `tcx` parameters do seem to be used though, so I only removed the `cache` parameters.
1 parent 60a1abe commit e19593f

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

src/librustdoc/formats/cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
303303
desc,
304304
parent,
305305
parent_idx: None,
306-
search_type: get_index_search_type(&item, self.tcx, self.cache),
306+
search_type: get_index_search_type(&item, self.tcx),
307307
aliases: item.attrs.get_doc_aliases(),
308308
});
309309
}

src/librustdoc/html/render/search_index.rs

+12-23
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
4242
desc,
4343
parent: Some(did),
4444
parent_idx: None,
45-
search_type: get_index_search_type(item, tcx, cache),
45+
search_type: get_index_search_type(item, tcx),
4646
aliases: item.attrs.get_doc_aliases(),
4747
});
4848
}
@@ -194,12 +194,11 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
194194
crate fn get_index_search_type<'tcx>(
195195
item: &clean::Item,
196196
tcx: TyCtxt<'tcx>,
197-
cache: &Cache,
198197
) -> Option<IndexItemFunctionType> {
199198
let (mut inputs, mut output) = match *item.kind {
200-
clean::FunctionItem(ref f) => get_all_types(&f.generics, &f.decl, tcx, cache),
201-
clean::MethodItem(ref m, _) => get_all_types(&m.generics, &m.decl, tcx, cache),
202-
clean::TyMethodItem(ref m) => get_all_types(&m.generics, &m.decl, tcx, cache),
199+
clean::FunctionItem(ref f) => get_all_types(&f.generics, &f.decl, tcx),
200+
clean::MethodItem(ref m, _) => get_all_types(&m.generics, &m.decl, tcx),
201+
clean::TyMethodItem(ref m) => get_all_types(&m.generics, &m.decl, tcx),
203202
_ => return None,
204203
};
205204

@@ -254,14 +253,12 @@ crate fn get_real_types<'tcx>(
254253
tcx: TyCtxt<'tcx>,
255254
recurse: usize,
256255
res: &mut Vec<TypeWithKind>,
257-
cache: &Cache,
258256
) {
259257
fn insert_ty(
260258
res: &mut Vec<TypeWithKind>,
261259
tcx: TyCtxt<'_>,
262260
ty: Type,
263261
mut generics: Vec<TypeWithKind>,
264-
_cache: &Cache,
265262
) {
266263
let is_full_generic = ty.is_full_generic();
267264

@@ -350,32 +347,25 @@ crate fn get_real_types<'tcx>(
350347
for param_def in poly_trait.generic_params.iter() {
351348
match &param_def.kind {
352349
clean::GenericParamDefKind::Type { default: Some(ty), .. } => {
353-
get_real_types(
354-
generics,
355-
ty,
356-
tcx,
357-
recurse + 1,
358-
&mut ty_generics,
359-
cache,
360-
)
350+
get_real_types(generics, ty, tcx, recurse + 1, &mut ty_generics)
361351
}
362352
_ => {}
363353
}
364354
}
365355
}
366356
}
367-
insert_ty(res, tcx, arg.clone(), ty_generics, cache);
357+
insert_ty(res, tcx, arg.clone(), ty_generics);
368358
}
369359
// Otherwise we check if the trait bounds are "inlined" like `T: Option<u32>`...
370360
if let Some(bound) = generics.params.iter().find(|g| g.is_type() && g.name == arg_s) {
371361
let mut ty_generics = Vec::new();
372362
for bound in bound.get_bounds().unwrap_or(&[]) {
373363
if let Some(path) = bound.get_trait_path() {
374364
let ty = Type::Path { path };
375-
get_real_types(generics, &ty, tcx, recurse + 1, &mut ty_generics, cache);
365+
get_real_types(generics, &ty, tcx, recurse + 1, &mut ty_generics);
376366
}
377367
}
378-
insert_ty(res, tcx, arg.clone(), ty_generics, cache);
368+
insert_ty(res, tcx, arg.clone(), ty_generics);
379369
}
380370
} else {
381371
// This is not a type parameter. So for example if we have `T, U: Option<T>`, and we're
@@ -386,10 +376,10 @@ crate fn get_real_types<'tcx>(
386376
let mut ty_generics = Vec::new();
387377
if let Some(arg_generics) = arg.generics() {
388378
for gen in arg_generics.iter() {
389-
get_real_types(generics, gen, tcx, recurse + 1, &mut ty_generics, cache);
379+
get_real_types(generics, gen, tcx, recurse + 1, &mut ty_generics);
390380
}
391381
}
392-
insert_ty(res, tcx, arg.clone(), ty_generics, cache);
382+
insert_ty(res, tcx, arg.clone(), ty_generics);
393383
}
394384
}
395385

@@ -401,15 +391,14 @@ crate fn get_all_types<'tcx>(
401391
generics: &Generics,
402392
decl: &FnDecl,
403393
tcx: TyCtxt<'tcx>,
404-
cache: &Cache,
405394
) -> (Vec<TypeWithKind>, Vec<TypeWithKind>) {
406395
let mut all_types = Vec::new();
407396
for arg in decl.inputs.values.iter() {
408397
if arg.type_.is_self_type() {
409398
continue;
410399
}
411400
let mut args = Vec::new();
412-
get_real_types(generics, &arg.type_, tcx, 0, &mut args, cache);
401+
get_real_types(generics, &arg.type_, tcx, 0, &mut args);
413402
if !args.is_empty() {
414403
all_types.extend(args);
415404
} else {
@@ -423,7 +412,7 @@ crate fn get_all_types<'tcx>(
423412
let mut ret_types = Vec::new();
424413
match decl.output {
425414
FnRetTy::Return(ref return_type) => {
426-
get_real_types(generics, return_type, tcx, 0, &mut ret_types, cache);
415+
get_real_types(generics, return_type, tcx, 0, &mut ret_types);
427416
if ret_types.is_empty() {
428417
if let Some(kind) =
429418
return_type.def_id_no_primitives().map(|did| tcx.def_kind(did).into())

0 commit comments

Comments
 (0)