Skip to content

Commit f3ef4b2

Browse files
committed
Use ItemType in cache
1 parent 1481af9 commit f3ef4b2

File tree

4 files changed

+11
-32
lines changed

4 files changed

+11
-32
lines changed

src/librustdoc/clean/types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,6 @@ crate enum TypeKind {
14561456
Foreign,
14571457
Macro,
14581458
TraitAlias,
1459-
Primitive,
14601459
}
14611460

14621461
impl From<hir::def::DefKind> for TypeKind {

src/librustdoc/formats/item_type.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::clean;
2020
/// module headings. If you are adding to this enum and want to ensure that the sidebar also prints
2121
/// a heading, edit the listing in `html/render.rs`, function `sidebar_module`. This uses an
2222
/// ordering based on a helper function inside `item_module`, in the same file.
23-
#[derive(Copy, PartialEq, Eq, Clone, Debug, PartialOrd, Ord)]
23+
#[derive(Copy, PartialEq, Eq, Hash, Clone, Debug, PartialOrd, Ord)]
2424
crate enum ItemType {
2525
Module = 0,
2626
ExternCrate = 1,
@@ -103,26 +103,6 @@ impl<'a> From<&'a clean::Item> for ItemType {
103103
}
104104
}
105105

106-
impl From<clean::TypeKind> for ItemType {
107-
fn from(kind: clean::TypeKind) -> ItemType {
108-
match kind {
109-
clean::TypeKind::Struct => ItemType::Struct,
110-
clean::TypeKind::Union => ItemType::Union,
111-
clean::TypeKind::Enum => ItemType::Enum,
112-
clean::TypeKind::Function => ItemType::Function,
113-
clean::TypeKind::Trait => ItemType::Trait,
114-
clean::TypeKind::Module => ItemType::Module,
115-
clean::TypeKind::Static => ItemType::Static,
116-
clean::TypeKind::Const => ItemType::Constant,
117-
clean::TypeKind::Typedef => ItemType::Typedef,
118-
clean::TypeKind::Foreign => ItemType::ForeignType,
119-
clean::TypeKind::Macro => ItemType::Macro,
120-
clean::TypeKind::TraitAlias => ItemType::TraitAlias,
121-
clean::TypeKind::Primitive => ItemType::Primitive,
122-
}
123-
}
124-
}
125-
126106
impl From<hir::def::DefKind> for ItemType {
127107
fn from(other: hir::def::DefKind) -> Self {
128108
match other {

src/librustdoc/html/render/cache.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_span::symbol::{sym, Symbol};
77
use serde::ser::{Serialize, SerializeStruct, Serializer};
88

99
use crate::clean::types::{
10-
FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, TypeKind, WherePredicate,
10+
FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, WherePredicate,
1111
};
1212
use crate::clean::{self, AttributesExt};
1313
use crate::formats::cache::Cache;
@@ -316,15 +316,15 @@ crate fn get_real_types<'tcx>(
316316
arg: &Type,
317317
tcx: TyCtxt<'tcx>,
318318
recurse: i32,
319-
res: &mut FxHashSet<(Type, TypeKind)>,
319+
res: &mut FxHashSet<(Type, ItemType)>,
320320
) -> usize {
321-
fn insert(res: &mut FxHashSet<(Type, TypeKind)>, tcx: TyCtxt<'_>, ty: Type) -> usize {
321+
fn insert(res: &mut FxHashSet<(Type, ItemType)>, tcx: TyCtxt<'_>, ty: Type) -> usize {
322322
if let Some(kind) = ty.def_id().map(|did| tcx.def_kind(did).into()) {
323323
res.insert((ty, kind));
324324
1
325325
} else if ty.is_primitive() {
326326
// This is a primitive, let's store it as such.
327-
res.insert((ty, TypeKind::Primitive));
327+
res.insert((ty, ItemType::Primitive));
328328
1
329329
} else {
330330
0
@@ -394,7 +394,7 @@ crate fn get_all_types<'tcx>(
394394
generics: &Generics,
395395
decl: &FnDecl,
396396
tcx: TyCtxt<'tcx>,
397-
) -> (Vec<(Type, TypeKind)>, Vec<(Type, TypeKind)>) {
397+
) -> (Vec<(Type, ItemType)>, Vec<(Type, ItemType)>) {
398398
let mut all_types = FxHashSet::default();
399399
for arg in decl.inputs.values.iter() {
400400
if arg.type_.is_self_type() {

src/librustdoc/html/render/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use rustc_span::symbol::{kw, sym, Symbol};
5454
use serde::ser::SerializeSeq;
5555
use serde::{Serialize, Serializer};
5656

57-
use crate::clean::{self, GetDefId, RenderedLink, SelfTy, TypeKind};
57+
use crate::clean::{self, GetDefId, RenderedLink, SelfTy};
5858
use crate::docfs::PathError;
5959
use crate::error::Error;
6060
use crate::formats::cache::Cache;
@@ -182,11 +182,11 @@ impl Serialize for IndexItemFunctionType {
182182
#[derive(Debug)]
183183
crate struct TypeWithKind {
184184
ty: RenderType,
185-
kind: TypeKind,
185+
kind: ItemType,
186186
}
187187

188-
impl From<(RenderType, TypeKind)> for TypeWithKind {
189-
fn from(x: (RenderType, TypeKind)) -> TypeWithKind {
188+
impl From<(RenderType, ItemType)> for TypeWithKind {
189+
fn from(x: (RenderType, ItemType)) -> TypeWithKind {
190190
TypeWithKind { ty: x.0, kind: x.1 }
191191
}
192192
}
@@ -196,7 +196,7 @@ impl Serialize for TypeWithKind {
196196
where
197197
S: Serializer,
198198
{
199-
(&self.ty.name, ItemType::from(self.kind)).serialize(serializer)
199+
(&self.ty.name, self.kind).serialize(serializer)
200200
}
201201
}
202202

0 commit comments

Comments
 (0)