1
Fork 0

Rollup merge of #84464 - jyn514:type-kind, r=CraftSpider

rustdoc: Get rid of `clean::TypeKind`

It does exactly the same thing as ItemType.
This commit is contained in:
Yuki Okushi 2021-04-25 01:53:15 +09:00 committed by GitHub
commit e25c5e2c25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 93 additions and 134 deletions

View file

@ -15,7 +15,7 @@ use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span; use rustc_span::Span;
use crate::clean::{self, Attributes, GetDefId, ToSource, TypeKind}; use crate::clean::{self, Attributes, GetDefId, ToSource};
use crate::core::DocContext; use crate::core::DocContext;
use crate::formats::item_type::ItemType; use crate::formats::item_type::ItemType;
@ -56,36 +56,36 @@ crate fn try_inline(
let kind = match res { let kind = match res {
Res::Def(DefKind::Trait, did) => { Res::Def(DefKind::Trait, did) => {
record_extern_fqn(cx, did, clean::TypeKind::Trait); record_extern_fqn(cx, did, ItemType::Trait);
build_impls(cx, Some(parent_module), did, attrs, &mut ret); build_impls(cx, Some(parent_module), did, attrs, &mut ret);
clean::TraitItem(build_external_trait(cx, did)) clean::TraitItem(build_external_trait(cx, did))
} }
Res::Def(DefKind::Fn, did) => { Res::Def(DefKind::Fn, did) => {
record_extern_fqn(cx, did, clean::TypeKind::Function); record_extern_fqn(cx, did, ItemType::Function);
clean::FunctionItem(build_external_function(cx, did)) clean::FunctionItem(build_external_function(cx, did))
} }
Res::Def(DefKind::Struct, did) => { Res::Def(DefKind::Struct, did) => {
record_extern_fqn(cx, did, clean::TypeKind::Struct); record_extern_fqn(cx, did, ItemType::Struct);
build_impls(cx, Some(parent_module), did, attrs, &mut ret); build_impls(cx, Some(parent_module), did, attrs, &mut ret);
clean::StructItem(build_struct(cx, did)) clean::StructItem(build_struct(cx, did))
} }
Res::Def(DefKind::Union, did) => { Res::Def(DefKind::Union, did) => {
record_extern_fqn(cx, did, clean::TypeKind::Union); record_extern_fqn(cx, did, ItemType::Union);
build_impls(cx, Some(parent_module), did, attrs, &mut ret); build_impls(cx, Some(parent_module), did, attrs, &mut ret);
clean::UnionItem(build_union(cx, did)) clean::UnionItem(build_union(cx, did))
} }
Res::Def(DefKind::TyAlias, did) => { Res::Def(DefKind::TyAlias, did) => {
record_extern_fqn(cx, did, clean::TypeKind::Typedef); record_extern_fqn(cx, did, ItemType::Typedef);
build_impls(cx, Some(parent_module), did, attrs, &mut ret); build_impls(cx, Some(parent_module), did, attrs, &mut ret);
clean::TypedefItem(build_type_alias(cx, did), false) clean::TypedefItem(build_type_alias(cx, did), false)
} }
Res::Def(DefKind::Enum, did) => { Res::Def(DefKind::Enum, did) => {
record_extern_fqn(cx, did, clean::TypeKind::Enum); record_extern_fqn(cx, did, ItemType::Enum);
build_impls(cx, Some(parent_module), did, attrs, &mut ret); build_impls(cx, Some(parent_module), did, attrs, &mut ret);
clean::EnumItem(build_enum(cx, did)) clean::EnumItem(build_enum(cx, did))
} }
Res::Def(DefKind::ForeignTy, did) => { Res::Def(DefKind::ForeignTy, did) => {
record_extern_fqn(cx, did, clean::TypeKind::Foreign); record_extern_fqn(cx, did, ItemType::ForeignType);
build_impls(cx, Some(parent_module), did, attrs, &mut ret); build_impls(cx, Some(parent_module), did, attrs, &mut ret);
clean::ForeignTypeItem clean::ForeignTypeItem
} }
@ -95,24 +95,24 @@ crate fn try_inline(
// their constructors. // their constructors.
Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) => return Some(Vec::new()), Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) => return Some(Vec::new()),
Res::Def(DefKind::Mod, did) => { Res::Def(DefKind::Mod, did) => {
record_extern_fqn(cx, did, clean::TypeKind::Module); record_extern_fqn(cx, did, ItemType::Module);
clean::ModuleItem(build_module(cx, did, visited)) clean::ModuleItem(build_module(cx, did, visited))
} }
Res::Def(DefKind::Static, did) => { Res::Def(DefKind::Static, did) => {
record_extern_fqn(cx, did, clean::TypeKind::Static); record_extern_fqn(cx, did, ItemType::Static);
clean::StaticItem(build_static(cx, did, cx.tcx.is_mutable_static(did))) clean::StaticItem(build_static(cx, did, cx.tcx.is_mutable_static(did)))
} }
Res::Def(DefKind::Const, did) => { Res::Def(DefKind::Const, did) => {
record_extern_fqn(cx, did, clean::TypeKind::Const); record_extern_fqn(cx, did, ItemType::Constant);
clean::ConstantItem(build_const(cx, did)) clean::ConstantItem(build_const(cx, did))
} }
Res::Def(DefKind::Macro(kind), did) => { Res::Def(DefKind::Macro(kind), did) => {
let mac = build_macro(cx, did, name); let mac = build_macro(cx, did, name);
let type_kind = match kind { let type_kind = match kind {
MacroKind::Bang => TypeKind::Macro, MacroKind::Bang => ItemType::Macro,
MacroKind::Attr => TypeKind::Attr, MacroKind::Attr => ItemType::ProcAttribute,
MacroKind::Derive => TypeKind::Derive, MacroKind::Derive => ItemType::ProcDerive,
}; };
record_extern_fqn(cx, did, type_kind); record_extern_fqn(cx, did, type_kind);
mac mac
@ -157,7 +157,7 @@ crate fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> Attrs<'hir> {
/// ///
/// These names are used later on by HTML rendering to generate things like /// These names are used later on by HTML rendering to generate things like
/// source links back to the original item. /// source links back to the original item.
crate fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: clean::TypeKind) { crate fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemType) {
let crate_name = cx.tcx.crate_name(did.krate).to_string(); let crate_name = cx.tcx.crate_name(did.krate).to_string();
let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| { let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| {
@ -165,7 +165,7 @@ crate fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: clean::Typ
let s = elem.data.to_string(); let s = elem.data.to_string();
if !s.is_empty() { Some(s) } else { None } if !s.is_empty() { Some(s) } else { None }
}); });
let fqn = if let clean::TypeKind::Macro = kind { let fqn = if let ItemType::Macro = kind {
// Check to see if it is a macro 2.0 or built-in macro // Check to see if it is a macro 2.0 or built-in macro
if matches!( if matches!(
cx.enter_resolver(|r| r.cstore().load_macro_untracked(did, cx.sess())), cx.enter_resolver(|r| r.cstore().load_macro_untracked(did, cx.sess())),

View file

@ -36,6 +36,7 @@ use std::{mem, vec};
use crate::core::{self, DocContext, ImplTraitParam}; use crate::core::{self, DocContext, ImplTraitParam};
use crate::doctree; use crate::doctree;
use crate::formats::item_type::ItemType;
use utils::*; use utils::*;
@ -154,7 +155,7 @@ impl Clean<GenericBound> for hir::GenericBound<'_> {
impl Clean<Type> for (ty::TraitRef<'_>, &[TypeBinding]) { impl Clean<Type> for (ty::TraitRef<'_>, &[TypeBinding]) {
fn clean(&self, cx: &mut DocContext<'_>) -> Type { fn clean(&self, cx: &mut DocContext<'_>) -> Type {
let (trait_ref, bounds) = *self; let (trait_ref, bounds) = *self;
inline::record_extern_fqn(cx, trait_ref.def_id, TypeKind::Trait); inline::record_extern_fqn(cx, trait_ref.def_id, ItemType::Trait);
let path = external_path( let path = external_path(
cx, cx,
cx.tcx.item_name(trait_ref.def_id), cx.tcx.item_name(trait_ref.def_id),
@ -909,12 +910,6 @@ impl Clean<PolyTrait> for hir::PolyTraitRef<'_> {
} }
} }
impl Clean<TypeKind> for hir::def::DefKind {
fn clean(&self, _: &mut DocContext<'_>) -> TypeKind {
(*self).into()
}
}
impl Clean<Item> for hir::TraitItem<'_> { impl Clean<Item> for hir::TraitItem<'_> {
fn clean(&self, cx: &mut DocContext<'_>) -> Item { fn clean(&self, cx: &mut DocContext<'_>) -> Item {
let local_did = self.def_id.to_def_id(); let local_did = self.def_id.to_def_id();
@ -1449,16 +1444,16 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
ty::Adt(def, substs) => { ty::Adt(def, substs) => {
let did = def.did; let did = def.did;
let kind = match def.adt_kind() { let kind = match def.adt_kind() {
AdtKind::Struct => TypeKind::Struct, AdtKind::Struct => ItemType::Struct,
AdtKind::Union => TypeKind::Union, AdtKind::Union => ItemType::Union,
AdtKind::Enum => TypeKind::Enum, AdtKind::Enum => ItemType::Enum,
}; };
inline::record_extern_fqn(cx, did, kind); inline::record_extern_fqn(cx, did, kind);
let path = external_path(cx, cx.tcx.item_name(did), None, false, vec![], substs); let path = external_path(cx, cx.tcx.item_name(did), None, false, vec![], substs);
ResolvedPath { path, param_names: None, did, is_generic: false } ResolvedPath { path, param_names: None, did, is_generic: false }
} }
ty::Foreign(did) => { ty::Foreign(did) => {
inline::record_extern_fqn(cx, did, TypeKind::Foreign); inline::record_extern_fqn(cx, did, ItemType::ForeignType);
let path = external_path( let path = external_path(
cx, cx,
cx.tcx.item_name(did), cx.tcx.item_name(did),
@ -1483,7 +1478,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
_ => cx.tcx.intern_substs(&[]), _ => cx.tcx.intern_substs(&[]),
}; };
inline::record_extern_fqn(cx, did, TypeKind::Trait); inline::record_extern_fqn(cx, did, ItemType::Trait);
let mut param_names = vec![]; let mut param_names = vec![];
if let Some(b) = reg.clean(cx) { if let Some(b) = reg.clean(cx) {
@ -1493,7 +1488,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
let empty = cx.tcx.intern_substs(&[]); let empty = cx.tcx.intern_substs(&[]);
let path = let path =
external_path(cx, cx.tcx.item_name(did), Some(did), false, vec![], empty); external_path(cx, cx.tcx.item_name(did), Some(did), false, vec![], empty);
inline::record_extern_fqn(cx, did, TypeKind::Trait); inline::record_extern_fqn(cx, did, ItemType::Trait);
let bound = GenericBound::TraitBound( let bound = GenericBound::TraitBound(
PolyTrait { PolyTrait {
trait_: ResolvedPath { trait_: ResolvedPath {

View file

@ -1099,7 +1099,7 @@ impl GenericBound {
let did = cx.tcx.require_lang_item(LangItem::Sized, None); let did = cx.tcx.require_lang_item(LangItem::Sized, None);
let empty = cx.tcx.intern_substs(&[]); let empty = cx.tcx.intern_substs(&[]);
let path = external_path(cx, cx.tcx.item_name(did), Some(did), false, vec![], empty); let path = external_path(cx, cx.tcx.item_name(did), Some(did), false, vec![], empty);
inline::record_extern_fqn(cx, did, TypeKind::Trait); inline::record_extern_fqn(cx, did, ItemType::Trait);
GenericBound::TraitBound( GenericBound::TraitBound(
PolyTrait { PolyTrait {
trait_: ResolvedPath { path, param_names: None, did, is_generic: false }, trait_: ResolvedPath { path, param_names: None, did, is_generic: false },
@ -1438,62 +1438,6 @@ crate enum PrimitiveType {
Never, Never,
} }
#[derive(Clone, PartialEq, Eq, Hash, Copy, Debug)]
crate enum TypeKind {
Enum,
Function,
Module,
Const,
Static,
Struct,
Union,
Trait,
Typedef,
Foreign,
Macro,
Attr,
Derive,
TraitAlias,
Primitive,
}
impl From<hir::def::DefKind> for TypeKind {
fn from(other: hir::def::DefKind) -> Self {
match other {
hir::def::DefKind::Enum => Self::Enum,
hir::def::DefKind::Fn => Self::Function,
hir::def::DefKind::Mod => Self::Module,
hir::def::DefKind::Const => Self::Const,
hir::def::DefKind::Static => Self::Static,
hir::def::DefKind::Struct => Self::Struct,
hir::def::DefKind::Union => Self::Union,
hir::def::DefKind::Trait => Self::Trait,
hir::def::DefKind::TyAlias => Self::Typedef,
hir::def::DefKind::TraitAlias => Self::TraitAlias,
hir::def::DefKind::Macro(_) => Self::Macro,
hir::def::DefKind::ForeignTy
| hir::def::DefKind::Variant
| hir::def::DefKind::AssocTy
| hir::def::DefKind::TyParam
| hir::def::DefKind::ConstParam
| hir::def::DefKind::Ctor(..)
| hir::def::DefKind::AssocFn
| hir::def::DefKind::AssocConst
| hir::def::DefKind::ExternCrate
| hir::def::DefKind::Use
| hir::def::DefKind::ForeignMod
| hir::def::DefKind::AnonConst
| hir::def::DefKind::OpaqueTy
| hir::def::DefKind::Field
| hir::def::DefKind::LifetimeParam
| hir::def::DefKind::GlobalAsm
| hir::def::DefKind::Impl
| hir::def::DefKind::Closure
| hir::def::DefKind::Generator => Self::Foreign,
}
}
}
crate trait GetDefId { crate trait GetDefId {
/// Use this method to get the [`DefId`] of a [`clean`] AST node. /// Use this method to get the [`DefId`] of a [`clean`] AST node.
/// This will return [`None`] when called on a primitive [`clean::Type`]. /// This will return [`None`] when called on a primitive [`clean::Type`].

View file

@ -3,9 +3,9 @@ use crate::clean::blanket_impl::BlanketImplFinder;
use crate::clean::{ use crate::clean::{
inline, Clean, Crate, Generic, GenericArg, GenericArgs, ImportSource, Item, ItemKind, Lifetime, inline, Clean, Crate, Generic, GenericArg, GenericArgs, ImportSource, Item, ItemKind, Lifetime,
MacroKind, Path, PathSegment, Primitive, PrimitiveType, ResolvedPath, Type, TypeBinding, MacroKind, Path, PathSegment, Primitive, PrimitiveType, ResolvedPath, Type, TypeBinding,
TypeKind,
}; };
use crate::core::DocContext; use crate::core::DocContext;
use crate::formats::item_type::ItemType;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};
@ -435,29 +435,29 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
debug!("register_res({:?})", res); debug!("register_res({:?})", res);
let (did, kind) = match res { let (did, kind) = match res {
Res::Def(DefKind::Fn, i) => (i, TypeKind::Function), Res::Def(DefKind::Fn, i) => (i, ItemType::Function),
Res::Def(DefKind::TyAlias, i) => (i, TypeKind::Typedef), Res::Def(DefKind::TyAlias, i) => (i, ItemType::Typedef),
Res::Def(DefKind::Enum, i) => (i, TypeKind::Enum), Res::Def(DefKind::Enum, i) => (i, ItemType::Enum),
Res::Def(DefKind::Trait, i) => (i, TypeKind::Trait), Res::Def(DefKind::Trait, i) => (i, ItemType::Trait),
Res::Def(DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst, i) => { Res::Def(DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst, i) => {
(cx.tcx.parent(i).unwrap(), TypeKind::Trait) (cx.tcx.parent(i).unwrap(), ItemType::Trait)
} }
Res::Def(DefKind::Struct, i) => (i, TypeKind::Struct), Res::Def(DefKind::Struct, i) => (i, ItemType::Struct),
Res::Def(DefKind::Union, i) => (i, TypeKind::Union), Res::Def(DefKind::Union, i) => (i, ItemType::Union),
Res::Def(DefKind::Mod, i) => (i, TypeKind::Module), Res::Def(DefKind::Mod, i) => (i, ItemType::Module),
Res::Def(DefKind::ForeignTy, i) => (i, TypeKind::Foreign), Res::Def(DefKind::ForeignTy, i) => (i, ItemType::ForeignType),
Res::Def(DefKind::Const, i) => (i, TypeKind::Const), Res::Def(DefKind::Const, i) => (i, ItemType::Constant),
Res::Def(DefKind::Static, i) => (i, TypeKind::Static), Res::Def(DefKind::Static, i) => (i, ItemType::Static),
Res::Def(DefKind::Variant, i) => { Res::Def(DefKind::Variant, i) => {
(cx.tcx.parent(i).expect("cannot get parent def id"), TypeKind::Enum) (cx.tcx.parent(i).expect("cannot get parent def id"), ItemType::Enum)
} }
Res::Def(DefKind::Macro(mac_kind), i) => match mac_kind { Res::Def(DefKind::Macro(mac_kind), i) => match mac_kind {
MacroKind::Bang => (i, TypeKind::Macro), MacroKind::Bang => (i, ItemType::Macro),
MacroKind::Attr => (i, TypeKind::Attr), MacroKind::Attr => (i, ItemType::ProcAttribute),
MacroKind::Derive => (i, TypeKind::Derive), MacroKind::Derive => (i, ItemType::ProcDerive),
}, },
Res::Def(DefKind::TraitAlias, i) => (i, TypeKind::TraitAlias), Res::Def(DefKind::TraitAlias, i) => (i, ItemType::TraitAlias),
Res::SelfTy(Some(def_id), _) => (def_id, TypeKind::Trait), Res::SelfTy(Some(def_id), _) => (def_id, ItemType::Trait),
Res::SelfTy(_, Some((impl_def_id, _))) => return impl_def_id, Res::SelfTy(_, Some((impl_def_id, _))) => return impl_def_id,
_ => return res.def_id(), _ => return res.def_id(),
}; };
@ -465,7 +465,7 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
return did; return did;
} }
inline::record_extern_fqn(cx, did, kind); inline::record_extern_fqn(cx, did, kind);
if let TypeKind::Trait = kind { if let ItemType::Trait = kind {
inline::record_extern_trait(cx, did); inline::record_extern_trait(cx, did);
} }
did did

View file

@ -4,6 +4,7 @@ use std::fmt;
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};
use rustc_hir::def::DefKind;
use rustc_span::hygiene::MacroKind; use rustc_span::hygiene::MacroKind;
use crate::clean; use crate::clean;
@ -19,7 +20,7 @@ use crate::clean;
/// module headings. If you are adding to this enum and want to ensure that the sidebar also prints /// module headings. If you are adding to this enum and want to ensure that the sidebar also prints
/// a heading, edit the listing in `html/render.rs`, function `sidebar_module`. This uses an /// a heading, edit the listing in `html/render.rs`, function `sidebar_module`. This uses an
/// ordering based on a helper function inside `item_module`, in the same file. /// ordering based on a helper function inside `item_module`, in the same file.
#[derive(Copy, PartialEq, Eq, Clone, Debug, PartialOrd, Ord)] #[derive(Copy, PartialEq, Eq, Hash, Clone, Debug, PartialOrd, Ord)]
crate enum ItemType { crate enum ItemType {
Module = 0, Module = 0,
ExternCrate = 1, ExternCrate = 1,
@ -102,24 +103,43 @@ impl<'a> From<&'a clean::Item> for ItemType {
} }
} }
impl From<clean::TypeKind> for ItemType { impl From<DefKind> for ItemType {
fn from(kind: clean::TypeKind) -> ItemType { fn from(other: DefKind) -> Self {
match kind { match other {
clean::TypeKind::Struct => ItemType::Struct, DefKind::Enum => Self::Enum,
clean::TypeKind::Union => ItemType::Union, DefKind::Fn => Self::Function,
clean::TypeKind::Enum => ItemType::Enum, DefKind::Mod => Self::Module,
clean::TypeKind::Function => ItemType::Function, DefKind::Const => Self::Constant,
clean::TypeKind::Trait => ItemType::Trait, DefKind::Static => Self::Static,
clean::TypeKind::Module => ItemType::Module, DefKind::Struct => Self::Struct,
clean::TypeKind::Static => ItemType::Static, DefKind::Union => Self::Union,
clean::TypeKind::Const => ItemType::Constant, DefKind::Trait => Self::Trait,
clean::TypeKind::Typedef => ItemType::Typedef, DefKind::TyAlias => Self::Typedef,
clean::TypeKind::Foreign => ItemType::ForeignType, DefKind::TraitAlias => Self::TraitAlias,
clean::TypeKind::Macro => ItemType::Macro, DefKind::Macro(kind) => match kind {
clean::TypeKind::Attr => ItemType::ProcAttribute, MacroKind::Bang => ItemType::Macro,
clean::TypeKind::Derive => ItemType::ProcDerive, MacroKind::Attr => ItemType::ProcAttribute,
clean::TypeKind::TraitAlias => ItemType::TraitAlias, MacroKind::Derive => ItemType::ProcDerive,
clean::TypeKind::Primitive => ItemType::Primitive, },
DefKind::ForeignTy
| DefKind::Variant
| DefKind::AssocTy
| DefKind::TyParam
| DefKind::ConstParam
| DefKind::Ctor(..)
| DefKind::AssocFn
| DefKind::AssocConst
| DefKind::ExternCrate
| DefKind::Use
| DefKind::ForeignMod
| DefKind::AnonConst
| DefKind::OpaqueTy
| DefKind::Field
| DefKind::LifetimeParam
| DefKind::GlobalAsm
| DefKind::Impl
| DefKind::Closure
| DefKind::Generator => Self::ForeignType,
} }
} }
} }

View file

@ -7,7 +7,7 @@ use rustc_span::symbol::{sym, Symbol};
use serde::ser::{Serialize, SerializeStruct, Serializer}; use serde::ser::{Serialize, SerializeStruct, Serializer};
use crate::clean::types::{ use crate::clean::types::{
FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, TypeKind, WherePredicate, FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, WherePredicate,
}; };
use crate::clean::{self, AttributesExt}; use crate::clean::{self, AttributesExt};
use crate::formats::cache::Cache; use crate::formats::cache::Cache;
@ -316,15 +316,15 @@ crate fn get_real_types<'tcx>(
arg: &Type, arg: &Type,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
recurse: i32, recurse: i32,
res: &mut FxHashSet<(Type, TypeKind)>, res: &mut FxHashSet<(Type, ItemType)>,
) -> usize { ) -> usize {
fn insert(res: &mut FxHashSet<(Type, TypeKind)>, tcx: TyCtxt<'_>, ty: Type) -> usize { fn insert(res: &mut FxHashSet<(Type, ItemType)>, tcx: TyCtxt<'_>, ty: Type) -> usize {
if let Some(kind) = ty.def_id().map(|did| tcx.def_kind(did).into()) { if let Some(kind) = ty.def_id().map(|did| tcx.def_kind(did).into()) {
res.insert((ty, kind)); res.insert((ty, kind));
1 1
} 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.
res.insert((ty, TypeKind::Primitive)); res.insert((ty, ItemType::Primitive));
1 1
} else { } else {
0 0
@ -394,7 +394,7 @@ crate fn get_all_types<'tcx>(
generics: &Generics, generics: &Generics,
decl: &FnDecl, decl: &FnDecl,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
) -> (Vec<(Type, TypeKind)>, Vec<(Type, TypeKind)>) { ) -> (Vec<(Type, ItemType)>, Vec<(Type, ItemType)>) {
let mut all_types = FxHashSet::default(); let mut all_types = FxHashSet::default();
for arg in decl.inputs.values.iter() { for arg in decl.inputs.values.iter() {
if arg.type_.is_self_type() { if arg.type_.is_self_type() {

View file

@ -54,7 +54,7 @@ use rustc_span::symbol::{kw, sym, Symbol};
use serde::ser::SerializeSeq; use serde::ser::SerializeSeq;
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};
use crate::clean::{self, GetDefId, RenderedLink, SelfTy, TypeKind}; use crate::clean::{self, GetDefId, RenderedLink, SelfTy};
use crate::docfs::PathError; use crate::docfs::PathError;
use crate::error::Error; use crate::error::Error;
use crate::formats::cache::Cache; use crate::formats::cache::Cache;
@ -182,11 +182,11 @@ impl Serialize for IndexItemFunctionType {
#[derive(Debug)] #[derive(Debug)]
crate struct TypeWithKind { crate struct TypeWithKind {
ty: RenderType, ty: RenderType,
kind: TypeKind, kind: ItemType,
} }
impl From<(RenderType, TypeKind)> for TypeWithKind { impl From<(RenderType, ItemType)> for TypeWithKind {
fn from(x: (RenderType, TypeKind)) -> TypeWithKind { fn from(x: (RenderType, ItemType)) -> TypeWithKind {
TypeWithKind { ty: x.0, kind: x.1 } TypeWithKind { ty: x.0, kind: x.1 }
} }
} }
@ -196,7 +196,7 @@ impl Serialize for TypeWithKind {
where where
S: Serializer, S: Serializer,
{ {
(&self.ty.name, ItemType::from(self.kind)).serialize(serializer) (&self.ty.name, self.kind).serialize(serializer)
} }
} }