Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 58a9e1d

Browse files
committedDec 6, 2024
rustdoc-json: Be clear which layer types are from.
Given that this file iteracts with clean and rustdoc-json-types, it's nice to make it very obvious which layer any given type is from, without having to know the imports.
1 parent 19544a5 commit 58a9e1d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
 

‎src/librustdoc/json/ids.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ use rustc_data_structures::fx::FxHashMap;
99
use rustc_hir::def::DefKind;
1010
use rustc_hir::def_id::DefId;
1111
use rustc_span::{Symbol, sym};
12-
use rustdoc_json_types::{self as types, Id}; // FIXME: Consistant.
12+
use rustdoc_json_types as types;
1313

1414
use super::JsonRenderer;
15-
use crate::clean::{self, ItemId};
15+
use crate::clean;
1616

1717
pub(super) type IdInterner = FxHashMap<FullItemId, types::Id>;
1818

@@ -66,20 +66,20 @@ pub(super) struct FullItemId {
6666
}
6767

6868
impl JsonRenderer<'_> {
69-
pub(crate) fn id_from_item_default(&self, item_id: ItemId) -> Id {
69+
pub(crate) fn id_from_item_default(&self, item_id: clean::ItemId) -> types::Id {
7070
self.id_from_item_inner(item_id, None, None)
7171
}
7272

7373
fn id_from_item_inner(
7474
&self,
75-
item_id: ItemId,
75+
item_id: clean::ItemId,
7676
name: Option<Symbol>,
7777
imported_id: Option<DefId>,
78-
) -> Id {
78+
) -> types::Id {
7979
let (def_id, mut extra_id) = match item_id {
80-
ItemId::DefId(did) => (did, None),
81-
ItemId::Blanket { for_, impl_id } => (for_, Some(impl_id)),
82-
ItemId::Auto { for_, trait_ } => (for_, Some(trait_)),
80+
clean::ItemId::DefId(did) => (did, None),
81+
clean::ItemId::Blanket { for_, impl_id } => (for_, Some(impl_id)),
82+
clean::ItemId::Auto { for_, trait_ } => (for_, Some(trait_)),
8383
};
8484

8585
let name = match name {
@@ -112,10 +112,10 @@ impl JsonRenderer<'_> {
112112
let len = interner.len();
113113
*interner
114114
.entry(key)
115-
.or_insert_with(|| Id(len.try_into().expect("too many items in a crate")))
115+
.or_insert_with(|| types::Id(len.try_into().expect("too many items in a crate")))
116116
}
117117

118-
pub(crate) fn id_from_item(&self, item: &clean::Item) -> Id {
118+
pub(crate) fn id_from_item(&self, item: &clean::Item) -> types::Id {
119119
match item.kind {
120120
clean::ItemKind::ImportItem(ref import) => {
121121
let imported_id = import.source.did;

0 commit comments

Comments
 (0)
Failed to load comments.