Skip to content

Commit 21424d2

Browse files
committed
rustdoc: Add PrimitiveType to ItemId::Primitive
1 parent 4b1027a commit 21424d2

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/librustdoc/clean/inline.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,11 @@ fn build_module(
483483
}
484484
if let Res::PrimTy(p) = item.res {
485485
// Primitive types can't be inlined so generate an import instead.
486+
let prim_ty = clean::PrimitiveType::from(p);
486487
items.push(clean::Item {
487488
name: None,
488489
attrs: box clean::Attributes::default(),
489-
def_id: ItemId::Primitive(did.krate),
490+
def_id: ItemId::Primitive(prim_ty, did.krate),
490491
visibility: clean::Public,
491492
kind: box clean::ImportItem(clean::Import::new_simple(
492493
item.ident.name,
@@ -495,7 +496,7 @@ fn build_module(
495496
global: false,
496497
res: item.res,
497498
segments: vec![clean::PathSegment {
498-
name: clean::PrimitiveType::from(p).as_sym(),
499+
name: prim_ty.as_sym(),
499500
args: clean::GenericArgs::AngleBracketed {
500501
args: Vec::new(),
501502
bindings: Vec::new(),

src/librustdoc/clean/types.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use self::Type::*;
5050

5151
crate type ItemIdSet = FxHashSet<ItemId>;
5252

53-
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
53+
#[derive(Debug, Clone, PartialEq, Eq, Hash, Copy)]
5454
crate enum ItemId {
5555
/// A "normal" item that uses a [`DefId`] for identification.
5656
DefId(DefId),
@@ -59,7 +59,7 @@ crate enum ItemId {
5959
/// Identifier that is used for blanket implementations.
6060
Blanket { trait_: DefId, for_: DefId },
6161
/// Identifier for primitive types.
62-
Primitive(CrateNum),
62+
Primitive(PrimitiveType, CrateNum),
6363
}
6464

6565
impl ItemId {
@@ -69,7 +69,7 @@ impl ItemId {
6969
ItemId::Auto { for_: id, .. }
7070
| ItemId::Blanket { for_: id, .. }
7171
| ItemId::DefId(id) => id.is_local(),
72-
ItemId::Primitive(krate) => krate == LOCAL_CRATE,
72+
ItemId::Primitive(_, krate) => krate == LOCAL_CRATE,
7373
}
7474
}
7575

@@ -94,7 +94,7 @@ impl ItemId {
9494
ItemId::Auto { for_: id, .. }
9595
| ItemId::Blanket { for_: id, .. }
9696
| ItemId::DefId(id) => id.krate,
97-
ItemId::Primitive(krate) => krate,
97+
ItemId::Primitive(_, krate) => krate,
9898
}
9999
}
100100

src/librustdoc/formats/cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ crate struct Cache {
122122
/// All intra-doc links resolved so far.
123123
///
124124
/// Links are indexed by the DefId of the item they document.
125-
crate intra_doc_links: BTreeMap<ItemId, Vec<clean::ItemLink>>,
125+
crate intra_doc_links: FxHashMap<ItemId, Vec<clean::ItemLink>>,
126126
}
127127

128128
/// This struct is used to wrap the `cache` and `tcx` in order to run `DocFolder`.

src/librustdoc/json/conversions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ crate fn from_item_id(did: ItemId) -> Id {
188188
ItemId::Auto { for_, trait_ } => {
189189
Id(format!("a:{}-{}", DisplayDefId(trait_), DisplayDefId(for_)))
190190
}
191-
ItemId::Primitive(krate) => Id(format!("p:{}", krate.as_u32())),
191+
ItemId::Primitive(ty, krate) => Id(format!("p:{}:{}", krate.as_u32(), ty.as_sym())),
192192
}
193193
}
194194

0 commit comments

Comments
 (0)