-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rustdoc json doesn't work #5
Comments
[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 |
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 |
A reproduction pub mod l1 {
pub mod l3 {
pub struct L4;
}
pub use l3::L4;
}
|
```rust
Item {
source: Span {
filename: Real(
Named(
"egg.rs",
),
),
cnum: crate0,
loline: 7,
locol: 4,
hiline: 7,
hicol: 19,
original: Span {
lo: BytePos(
65,
),
hi: BytePos(
80,
),
ctxt: #0,
},
},
name: None,
attrs: Attributes {
doc_strings: [],
other_attrs: [],
cfg: None,
span: None,
links: [],
inner_docs: true,
},
kind: ImportItem(
Import {
kind: Simple(
"L4",
),
source: ImportSource {
path: Path {
global: false,
res: Def(
Struct,
DefId(0:5),
),
segments: [
PathSegment {
name: "l3",
args: AngleBracketed {
args: [],
bindings: [],
},
},
PathSegment {
name: "L4",
args: AngleBracketed {
args: [],
bindings: [],
},
},
],
},
did: Some(
DefId(0:5),
),
},
should_be_displayed: true,
},
),
visibility: Public,
def_id: DefId(0:0),
stability: None,
deprecation: None,
}
Item {
source: Span {
filename: Real(
Named(
"egg.rs",
),
),
cnum: crate0,
loline: 3,
locol: 0,
hiline: 8,
hicol: 1,
original: Span {
lo: BytePos(
2,
),
hi: BytePos(
82,
),
ctxt: #0,
},
},
name: Some(
"egg",
),
attrs: Attributes {
doc_strings: [],
other_attrs: [],
cfg: None,
span: None,
links: [],
inner_docs: true,
},
kind: ModuleItem(
Module {
items: [
Item {
source: Span {
filename: Real(
Named(
"egg.rs",
),
),
cnum: crate0,
loline: 3,
locol: 0,
hiline: 8,
hicol: 1,
original: Span {
lo: BytePos(
2,
),
hi: BytePos(
82,
),
ctxt: #0,
},
},
name: Some(
"l1",
),
attrs: Attributes {
doc_strings: [],
other_attrs: [],
cfg: None,
span: None,
links: [],
inner_docs: true,
},
kind: ModuleItem(
Module {
items: [
Item {
source: Span {
filename: Real(
Named(
"egg.rs",
),
),
cnum: crate0,
loline: 7,
locol: 4,
hiline: 7,
hicol: 19,
original: Span {
lo: BytePos(
65,
),
hi: BytePos(
80,
),
ctxt: #0,
},
},
name: None,
attrs: Attributes {
doc_strings: [],
other_attrs: [],
cfg: None,
span: None,
links: [],
inner_docs: true,
},
kind: ImportItem(
Import {
kind: Simple(
"L4",
),
source: ImportSource {
path: Path {
global: false,
res: Def(
Struct,
DefId(0:5),
),
segments: [
PathSegment {
name: "l3",
args: AngleBracketed {
args: [],
bindings: [],
},
},
PathSegment {
name: "L4",
args: AngleBracketed {
args: [],
bindings: [],
},
},
],
},
did: Some(
DefId(0:5),
),
},
should_be_displayed: true,
},
),
visibility: Public,
def_id: DefId(0:0),
stability: None,
deprecation: None,
},
Item {
source: Span {
filename: Real(
Named(
"egg.rs",
),
),
cnum: crate0,
loline: 4,
locol: 4,
hiline: 6,
hicol: 5,
original: Span {
lo: BytePos(
19,
),
hi: BytePos(
60,
),
ctxt: #0,
},
},
name: Some(
"l3",
),
attrs: Attributes {
doc_strings: [],
other_attrs: [],
cfg: None,
span: None,
links: [],
inner_docs: true,
},
kind: ModuleItem(
Module {
items: [
Item {
source: Span {
filename: Real(
Named(
"egg.rs",
),
),
cnum: crate0,
loline: 5,
locol: 8,
hiline: 5,
hicol: 22,
original: Span {
lo: BytePos(
40,
),
hi: BytePos(
54,
),
ctxt: #0,
},
},
name: Some(
"L4",
),
attrs: Attributes {
doc_strings: [],
other_attrs: [],
cfg: None,
span: None,
links: [],
inner_docs: true,
},
kind: StructItem(
Struct {
struct_type: Unit,
generics: Generics {
params: [],
where_predicates: [],
},
fields: [],
fields_stripped: false,
},
),
visibility: Public,
def_id: DefId(0:5),
stability: None,
deprecation: None,
},
],
is_crate: false,
},
),
visibility: Public,
def_id: DefId(0:4),
stability: None,
deprecation: None,
},
],
is_crate: false,
},
),
visibility: Public,
def_id: DefId(0:3),
stability: None,
deprecation: None,
},
],
is_crate: true,
},
),
visibility: Public,
def_id: DefId(0:0),
stability: None,
deprecation: None,
}
Item {
source: Span {
filename: Real(
Named(
"egg.rs",
),
),
cnum: crate0,
loline: 7,
locol: 4,
hiline: 7,
hicol: 19,
original: Span {
lo: BytePos(
65,
),
hi: BytePos(
80,
),
ctxt: #0,
},
},
name: None,
attrs: Attributes {
doc_strings: [],
other_attrs: [],
cfg: None,
span: None,
links: [],
inner_docs: true,
},
kind: ImportItem(
Import {
kind: Simple(
"L4",
),
source: ImportSource {
path: Path {
global: false,
res: Def(
Struct,
DefId(0:5),
),
segments: [
PathSegment {
name: "l3",
args: AngleBracketed {
args: [],
bindings: [],
},
},
PathSegment {
name: "L4",
args: AngleBracketed {
args: [],
bindings: [],
},
},
],
},
did: Some(
DefId(0:5),
),
},
should_be_displayed: true,
},
),
visibility: Public,
def_id: DefId(0:0),
stability: None,
deprecation: None,
}
Item {
source: Span {
filename: Real(
Named(
"egg.rs",
),
),
cnum: crate0,
loline: 7,
locol: 4,
hiline: 7,
hicol: 19,
original: Span {
lo: BytePos(
65,
),
hi: BytePos(
80,
),
ctxt: #0,
},
},
name: None,
attrs: Attributes {
doc_strings: [],
other_attrs: [],
cfg: None,
span: None,
links: [],
inner_docs: true,
},
kind: ImportItem(
Import {
kind: Simple(
"L4",
),
source: ImportSource {
path: Path {
global: false,
res: Def(
Struct,
DefId(0:5),
),
segments: [
PathSegment {
name: "l3",
args: AngleBracketed {
args: [],
bindings: [],
},
},
PathSegment {
name: "L4",
args: AngleBracketed {
args: [],
bindings: [],
},
},
],
},
did: Some(
DefId(0:5),
),
},
should_be_displayed: true,
},
),
visibility: Public,
def_id: DefId(0:0),
stability: None,
deprecation: None,
}
|
Rustc Patchdiff --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(()) Egg.rspub mod l1 {
pub mod l3 {
pub struct L4;
}
pub use l3::L4;
}
Output (all true)``` [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:7), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:7), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:10), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:11), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:12), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:14), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:15), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:5), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:4), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:3), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:10), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:11), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:12), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:14), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:15), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:5), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:4), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:10), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:11), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:12), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:14), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:15), true, ) [src/librustdoc/json/mod.rs:157] (id, res == new_item) = ( DefId(0:5), true, ) ``` |
Closed by rust-lang/rust#79751 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
58c4024 panics
41f76da is fine
The text was updated successfully, but these errors were encountered: