Closed aDotInTheVoid closed 3 years ago
0d88d824 is fine cae2d308 panics
cargo +stage1 rustdoc -vv -- --output-format json
[src/librustdoc/json/mod.rs:228] &output.index.get(&output.root).unwrap() = Item {
id: Id(
"0:0",
),
crate_id: 0,
name: None,
source: Some(
Span {
filename: "src/html_render/content/mod.rs",
begin: (
10,
0,
),
end: (
10,
22,
),
},
),
visibility: Public,
docs: "",
links: {},
attrs: [],
deprecation: None,
kind: Import,
inner: ImportItem(
Import {
span: "collect::Dirs",
name: "Dirs",
id: Some(
Id(
"0:562",
),
),
glob: false,
},
),
}
The thing is expected name
to be Some
here
Turns out this change is needed. I removed it in my PR, as I didn't understand, but it's nessesary
I'm pritty sure this has the wrong ID, as 0:0
should be the root.
eca9ecf0 panics a3cb263388c3cc32efa4570dc51d75b66da86d3a is fine
A reproduction
pub mod l1 {
pub mod l3 {
pub struct L4;
}
pub use l3::L4;
}
rustdoc +stage1 src/lib.rs --edition 2018 --output-format json
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 8c344338de7..4418a4f3864 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -2263,7 +2263,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
name: None,
attrs: self.attrs.clean(cx),
source: self.span.clean(cx),
- def_id: DefId::local(CRATE_DEF_INDEX),
+ def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
visibility: self.vis.clean(cx),
stability: None,
const_stability: None,
diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs
index c080ad21c0f..38f40ac143c 100644
--- a/src/librustdoc/json/mod.rs
+++ b/src/librustdoc/json/mod.rs
@@ -151,7 +151,11 @@ fn item(&mut self, item: clean::Item, cache: &Cache) -> Result<(), Error> {
} else if let types::ItemEnum::EnumItem(ref mut e) = new_item.inner {
e.impls = self.get_impls(id, cache)
}
- self.index.borrow_mut().insert(id.into(), new_item);
+ let res = self.index.borrow_mut().insert(id.into(), new_item.clone());
+
+ if let Some(res) = res {
+ dbg!((id, res == new_item));
+ }
}
Ok(())
pub mod l1 {
pub mod l3 {
pub struct L4;
}
pub use l3::L4;
}
rustdoc +stage1 egg.rs --output-format json --edition 2018
58c4024bf0eb2f908492272aab57525c924750f3 panics 41f76da920fcd9ed80f35186373feb93d654562a is fine