Skip to content

Commit 35add17

Browse files
aDotInTheVoidfmease
andcommitted
More code-review stuf
Co-authored-by: León Orell Valerian Liehr <[email protected]>
1 parent d5b6d35 commit 35add17

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

src/librustdoc/json/ids.rs

+12-17
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(super) type IdInterner = FxHashMap<FullItemId, types::Id>;
1919
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
2020
/// An uninterned id.
2121
///
22-
/// One of these corresponds to every:
22+
/// Each one corresponds to exactly one of both:
2323
/// 1. [`rustdoc_json_types::Item`].
2424
/// 2. [`rustdoc_json_types::Id`] transitively (as each `Item` has an `Id`).
2525
///
@@ -42,16 +42,16 @@ pub(super) struct FullItemId {
4242
/// E.g:
4343
///
4444
/// ```rust
45-
/// mod module {
46-
/// pub struct Foo {} // Exists in type namespace
47-
/// pub fn Foo(){} // Exists in value namespace
48-
/// }
45+
/// mod module {
46+
/// pub struct Foo {} // Exists in type namespace
47+
/// pub fn Foo(){} // Exists in value namespace
48+
/// }
49+
///
50+
/// pub use module::Foo; // Imports both items
51+
/// ```
4952
///
50-
/// pub use module::Foo; // Imports both items
51-
/// ```
52-
///
53-
/// In HIR, the `pub use` is just 1 item, but in rustdoc-json it's 2, so
54-
/// we need to disambiguate.
53+
/// In HIR, the `pub use` is just 1 item, but in rustdoc-json it's 2, so
54+
/// we need to disambiguate.
5555
extra_id: Option<DefId>,
5656

5757
/// Needed for `#[rustc_doc_primitive]` modules.
@@ -76,8 +76,8 @@ impl JsonRenderer<'_> {
7676
name: Option<Symbol>,
7777
imported_id: Option<DefId>,
7878
) -> types::Id {
79-
let (def_id, mut extra_id) = match item_id {
80-
clean::ItemId::DefId(did) => (did, None),
79+
let (def_id, extra_id) = match item_id {
80+
clean::ItemId::DefId(did) => (did, imported_id),
8181
clean::ItemId::Blanket { for_, impl_id } => (for_, Some(impl_id)),
8282
clean::ItemId::Auto { for_, trait_ } => (for_, Some(trait_)),
8383
};
@@ -101,11 +101,6 @@ impl JsonRenderer<'_> {
101101
}
102102
};
103103

104-
if let Some(imported_id) = imported_id {
105-
assert_eq!(extra_id, None, "On an import item, so won't have extra from impl");
106-
extra_id = Some(imported_id);
107-
}
108-
109104
let key = FullItemId { def_id, extra_id, name };
110105

111106
let mut interner = self.id_interner.borrow_mut();

0 commit comments

Comments
 (0)