Skip to content

Commit ff88b59

Browse files
zredbGuillaumeGomez
authored andcommitted
fix #90187
1 parent b13a5bf commit ff88b59

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
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_function_type_for_search(&item, self.tcx),
306+
search_type: get_function_type_for_search(&item, self.tcx, self.cache),
307307
aliases: item.attrs.get_doc_aliases(),
308308
});
309309
}

src/librustdoc/html/render/search_index.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
3333
desc,
3434
parent: Some(did),
3535
parent_idx: None,
36-
search_type: get_function_type_for_search(item, tcx),
36+
search_type: get_function_type_for_search(item, tcx, &cache),
3737
aliases: item.attrs.get_doc_aliases(),
3838
});
3939
}
@@ -188,11 +188,12 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
188188
crate fn get_function_type_for_search<'tcx>(
189189
item: &clean::Item,
190190
tcx: TyCtxt<'tcx>,
191+
cache: &Cache,
191192
) -> Option<IndexItemFunctionType> {
192193
let (mut inputs, mut output) = match *item.kind {
193-
clean::FunctionItem(ref f) => get_fn_inputs_and_outputs(f, tcx),
194-
clean::MethodItem(ref m, _) => get_fn_inputs_and_outputs(m, tcx),
195-
clean::TyMethodItem(ref m) => get_fn_inputs_and_outputs(m, tcx),
194+
clean::FunctionItem(ref f) => get_fn_inputs_and_outputs(f, tcx, cache),
195+
clean::MethodItem(ref m, _) => get_fn_inputs_and_outputs(m, tcx, cache),
196+
clean::TyMethodItem(ref m) => get_fn_inputs_and_outputs(m, tcx, cache),
196197
_ => return None,
197198
};
198199

@@ -311,7 +312,7 @@ fn add_generics_and_bounds_as_types<'tcx>(
311312
// We remove the name of the full generic because we have no use for it.
312313
index_ty.name = Some(String::new());
313314
res.push(TypeWithKind::from((index_ty, ItemType::Generic)));
314-
} else if let Some(kind) = ty.def_id_no_primitives().map(|did| tcx.def_kind(did).into()) {
315+
} else if let Some(kind) = ty.def_id(cache).map(|did| tcx.def_kind(did).into()) {
315316
res.push(TypeWithKind::from((index_ty, kind)));
316317
} else if ty.is_primitive() {
317318
// This is a primitive, let's store it as such.
@@ -330,9 +331,7 @@ fn add_generics_and_bounds_as_types<'tcx>(
330331
if let Type::Generic(arg_s) = *arg {
331332
// First we check if the bounds are in a `where` predicate...
332333
if let Some(where_pred) = generics.where_predicates.iter().find(|g| match g {
333-
WherePredicate::BoundPredicate { ty, .. } => {
334-
ty.def_id_no_primitives() == arg.def_id_no_primitives()
335-
}
334+
WherePredicate::BoundPredicate { ty, .. } => ty.def_id(cache) == arg.def_id(cache),
336335
_ => false,
337336
}) {
338337
let mut ty_generics = Vec::new();
@@ -397,6 +396,7 @@ fn add_generics_and_bounds_as_types<'tcx>(
397396
fn get_fn_inputs_and_outputs<'tcx>(
398397
func: &Function,
399398
tcx: TyCtxt<'tcx>,
399+
cache: &Cache,
400400
) -> (Vec<TypeWithKind>, Vec<TypeWithKind>) {
401401
let decl = &func.decl;
402402
let generics = &func.generics;
@@ -411,8 +411,7 @@ fn get_fn_inputs_and_outputs<'tcx>(
411411
if !args.is_empty() {
412412
all_types.extend(args);
413413
} else {
414-
if let Some(kind) = arg.type_.def_id_no_primitives().map(|did| tcx.def_kind(did).into())
415-
{
414+
if let Some(kind) = arg.type_.def_id(cache).map(|did| tcx.def_kind(did).into()) {
416415
all_types.push(TypeWithKind::from((get_index_type(&arg.type_, vec![]), kind)));
417416
}
418417
}
@@ -423,9 +422,7 @@ fn get_fn_inputs_and_outputs<'tcx>(
423422
FnRetTy::Return(ref return_type) => {
424423
add_generics_and_bounds_as_types(generics, return_type, tcx, 0, &mut ret_types);
425424
if ret_types.is_empty() {
426-
if let Some(kind) =
427-
return_type.def_id_no_primitives().map(|did| tcx.def_kind(did).into())
428-
{
425+
if let Some(kind) = return_type.def_id(cache).map(|did| tcx.def_kind(did).into()) {
429426
ret_types.push(TypeWithKind::from((get_index_type(return_type, vec![]), kind)));
430427
}
431428
}

src/librustdoc/passes/collect_trait_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ crate fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) -> Crate
102102
} else if let Some(did) = target.def_id(&cx.cache) {
103103
cleaner.items.insert(did.into());
104104
}
105-
if let Some(for_did) = for_.def_id_no_primitives() {
105+
if let Some(for_did) = for_.def_id(&cx.cache) {
106106
if type_did_to_deref_target.insert(for_did, target).is_none() {
107107
// Since only the `DefId` portion of the `Type` instances is known to be same for both the
108108
// `Deref` target type and the impl for type positions, this map of types is keyed by
@@ -216,7 +216,7 @@ impl BadImplStripper {
216216
true
217217
} else if let Some(prim) = ty.primitive_type() {
218218
self.prims.contains(&prim)
219-
} else if let Some(did) = ty.def_id_no_primitives() {
219+
} else if let Some(did) = ty.def_id(&cx.cache) {
220220
is_deref || self.keep_impl_with_def_id(did.into())
221221
} else {
222222
false

src/librustdoc/passes/stripper.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ impl<'a> DocFolder for Stripper<'a> {
118118
/// This stripper discards all impls which reference stripped items
119119
crate struct ImplStripper<'a> {
120120
crate retained: &'a ItemIdSet,
121+
crate cache: &'a Cache,
121122
}
122123

123124
impl<'a> DocFolder for ImplStripper<'a> {
@@ -127,7 +128,7 @@ impl<'a> DocFolder for ImplStripper<'a> {
127128
if imp.trait_.is_none() && imp.items.is_empty() {
128129
return None;
129130
}
130-
if let Some(did) = imp.for_.def_id_no_primitives() {
131+
if let Some(did) = imp.for_.def_id(self.cache) {
131132
if did.is_local() && !imp.for_.is_assoc_ty() && !self.retained.contains(&did.into())
132133
{
133134
debug!("ImplStripper: impl item for stripped type; removing");

0 commit comments

Comments
 (0)