fix #90187
This commit is contained in:
parent
b13a5bf3c4
commit
ff88b59e58
4 changed files with 15 additions and 17 deletions
|
@ -303,7 +303,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
||||||
desc,
|
desc,
|
||||||
parent,
|
parent,
|
||||||
parent_idx: None,
|
parent_idx: None,
|
||||||
search_type: get_function_type_for_search(&item, self.tcx),
|
search_type: get_function_type_for_search(&item, self.tcx, self.cache),
|
||||||
aliases: item.attrs.get_doc_aliases(),
|
aliases: item.attrs.get_doc_aliases(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
|
||||||
desc,
|
desc,
|
||||||
parent: Some(did),
|
parent: Some(did),
|
||||||
parent_idx: None,
|
parent_idx: None,
|
||||||
search_type: get_function_type_for_search(item, tcx),
|
search_type: get_function_type_for_search(item, tcx, &cache),
|
||||||
aliases: item.attrs.get_doc_aliases(),
|
aliases: item.attrs.get_doc_aliases(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -188,11 +188,12 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
|
||||||
crate fn get_function_type_for_search<'tcx>(
|
crate fn get_function_type_for_search<'tcx>(
|
||||||
item: &clean::Item,
|
item: &clean::Item,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
cache: &Cache,
|
||||||
) -> Option<IndexItemFunctionType> {
|
) -> Option<IndexItemFunctionType> {
|
||||||
let (mut inputs, mut output) = match *item.kind {
|
let (mut inputs, mut output) = match *item.kind {
|
||||||
clean::FunctionItem(ref f) => get_fn_inputs_and_outputs(f, tcx),
|
clean::FunctionItem(ref f) => get_fn_inputs_and_outputs(f, tcx, cache),
|
||||||
clean::MethodItem(ref m, _) => get_fn_inputs_and_outputs(m, tcx),
|
clean::MethodItem(ref m, _) => get_fn_inputs_and_outputs(m, tcx, cache),
|
||||||
clean::TyMethodItem(ref m) => get_fn_inputs_and_outputs(m, tcx),
|
clean::TyMethodItem(ref m) => get_fn_inputs_and_outputs(m, tcx, cache),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -311,7 +312,7 @@ fn add_generics_and_bounds_as_types<'tcx>(
|
||||||
// We remove the name of the full generic because we have no use for it.
|
// We remove the name of the full generic because we have no use for it.
|
||||||
index_ty.name = Some(String::new());
|
index_ty.name = Some(String::new());
|
||||||
res.push(TypeWithKind::from((index_ty, ItemType::Generic)));
|
res.push(TypeWithKind::from((index_ty, ItemType::Generic)));
|
||||||
} else if let Some(kind) = ty.def_id_no_primitives().map(|did| tcx.def_kind(did).into()) {
|
} else if let Some(kind) = ty.def_id(cache).map(|did| tcx.def_kind(did).into()) {
|
||||||
res.push(TypeWithKind::from((index_ty, kind)));
|
res.push(TypeWithKind::from((index_ty, kind)));
|
||||||
} else if ty.is_primitive() {
|
} else if ty.is_primitive() {
|
||||||
// This is a primitive, let's store it as such.
|
// This is a primitive, let's store it as such.
|
||||||
|
@ -330,9 +331,7 @@ fn add_generics_and_bounds_as_types<'tcx>(
|
||||||
if let Type::Generic(arg_s) = *arg {
|
if let Type::Generic(arg_s) = *arg {
|
||||||
// First we check if the bounds are in a `where` predicate...
|
// First we check if the bounds are in a `where` predicate...
|
||||||
if let Some(where_pred) = generics.where_predicates.iter().find(|g| match g {
|
if let Some(where_pred) = generics.where_predicates.iter().find(|g| match g {
|
||||||
WherePredicate::BoundPredicate { ty, .. } => {
|
WherePredicate::BoundPredicate { ty, .. } => ty.def_id(cache) == arg.def_id(cache),
|
||||||
ty.def_id_no_primitives() == arg.def_id_no_primitives()
|
|
||||||
}
|
|
||||||
_ => false,
|
_ => false,
|
||||||
}) {
|
}) {
|
||||||
let mut ty_generics = Vec::new();
|
let mut ty_generics = Vec::new();
|
||||||
|
@ -397,6 +396,7 @@ fn add_generics_and_bounds_as_types<'tcx>(
|
||||||
fn get_fn_inputs_and_outputs<'tcx>(
|
fn get_fn_inputs_and_outputs<'tcx>(
|
||||||
func: &Function,
|
func: &Function,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
cache: &Cache,
|
||||||
) -> (Vec<TypeWithKind>, Vec<TypeWithKind>) {
|
) -> (Vec<TypeWithKind>, Vec<TypeWithKind>) {
|
||||||
let decl = &func.decl;
|
let decl = &func.decl;
|
||||||
let generics = &func.generics;
|
let generics = &func.generics;
|
||||||
|
@ -411,8 +411,7 @@ fn get_fn_inputs_and_outputs<'tcx>(
|
||||||
if !args.is_empty() {
|
if !args.is_empty() {
|
||||||
all_types.extend(args);
|
all_types.extend(args);
|
||||||
} else {
|
} else {
|
||||||
if let Some(kind) = arg.type_.def_id_no_primitives().map(|did| tcx.def_kind(did).into())
|
if let Some(kind) = arg.type_.def_id(cache).map(|did| tcx.def_kind(did).into()) {
|
||||||
{
|
|
||||||
all_types.push(TypeWithKind::from((get_index_type(&arg.type_, vec![]), kind)));
|
all_types.push(TypeWithKind::from((get_index_type(&arg.type_, vec![]), kind)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,9 +422,7 @@ fn get_fn_inputs_and_outputs<'tcx>(
|
||||||
FnRetTy::Return(ref return_type) => {
|
FnRetTy::Return(ref return_type) => {
|
||||||
add_generics_and_bounds_as_types(generics, return_type, tcx, 0, &mut ret_types);
|
add_generics_and_bounds_as_types(generics, return_type, tcx, 0, &mut ret_types);
|
||||||
if ret_types.is_empty() {
|
if ret_types.is_empty() {
|
||||||
if let Some(kind) =
|
if let Some(kind) = return_type.def_id(cache).map(|did| tcx.def_kind(did).into()) {
|
||||||
return_type.def_id_no_primitives().map(|did| tcx.def_kind(did).into())
|
|
||||||
{
|
|
||||||
ret_types.push(TypeWithKind::from((get_index_type(return_type, vec![]), kind)));
|
ret_types.push(TypeWithKind::from((get_index_type(return_type, vec![]), kind)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ crate fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) -> Crate
|
||||||
} else if let Some(did) = target.def_id(&cx.cache) {
|
} else if let Some(did) = target.def_id(&cx.cache) {
|
||||||
cleaner.items.insert(did.into());
|
cleaner.items.insert(did.into());
|
||||||
}
|
}
|
||||||
if let Some(for_did) = for_.def_id_no_primitives() {
|
if let Some(for_did) = for_.def_id(&cx.cache) {
|
||||||
if type_did_to_deref_target.insert(for_did, target).is_none() {
|
if type_did_to_deref_target.insert(for_did, target).is_none() {
|
||||||
// Since only the `DefId` portion of the `Type` instances is known to be same for both the
|
// Since only the `DefId` portion of the `Type` instances is known to be same for both the
|
||||||
// `Deref` target type and the impl for type positions, this map of types is keyed by
|
// `Deref` target type and the impl for type positions, this map of types is keyed by
|
||||||
|
@ -216,7 +216,7 @@ impl BadImplStripper {
|
||||||
true
|
true
|
||||||
} else if let Some(prim) = ty.primitive_type() {
|
} else if let Some(prim) = ty.primitive_type() {
|
||||||
self.prims.contains(&prim)
|
self.prims.contains(&prim)
|
||||||
} else if let Some(did) = ty.def_id_no_primitives() {
|
} else if let Some(did) = ty.def_id(&cx.cache) {
|
||||||
is_deref || self.keep_impl_with_def_id(did.into())
|
is_deref || self.keep_impl_with_def_id(did.into())
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
|
@ -118,6 +118,7 @@ impl<'a> DocFolder for Stripper<'a> {
|
||||||
/// This stripper discards all impls which reference stripped items
|
/// This stripper discards all impls which reference stripped items
|
||||||
crate struct ImplStripper<'a> {
|
crate struct ImplStripper<'a> {
|
||||||
crate retained: &'a ItemIdSet,
|
crate retained: &'a ItemIdSet,
|
||||||
|
crate cache: &'a Cache,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DocFolder for ImplStripper<'a> {
|
impl<'a> DocFolder for ImplStripper<'a> {
|
||||||
|
@ -127,7 +128,7 @@ impl<'a> DocFolder for ImplStripper<'a> {
|
||||||
if imp.trait_.is_none() && imp.items.is_empty() {
|
if imp.trait_.is_none() && imp.items.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if let Some(did) = imp.for_.def_id_no_primitives() {
|
if let Some(did) = imp.for_.def_id(self.cache) {
|
||||||
if did.is_local() && !imp.for_.is_assoc_ty() && !self.retained.contains(&did.into())
|
if did.is_local() && !imp.for_.is_assoc_ty() && !self.retained.contains(&did.into())
|
||||||
{
|
{
|
||||||
debug!("ImplStripper: impl item for stripped type; removing");
|
debug!("ImplStripper: impl item for stripped type; removing");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue