Closed
Description
With this code:
#![feature(no_core)]
#![no_core]
mod inner {
pub struct Public;
}
pub use inner::Public;
We produce the following JSON (redacted for clarity):
{
"crate_version": null,
"external_crates": {},
"format_version": 37,
"includes_private": false,
"index": {
"0": {
"attrs": [],
"docs": null,
"inner": {"struct": {"generics": {"params": [], "where_predicates": []}, "impls": [], "kind": "unit"}},
"name": "Public",
"visibility": "public"
},
"2": {
"attrs": [],
"docs": null,
"inner": {"use": {"id": 0, "is_glob": false, "name": "Public", "source": "inner::Public"}},
"name": null,
"visibility": "public"
},
"3": {
"attrs": ["#![feature(no_core)]", "#![no_core]"],
"docs": null,
"inner": {"module": {"is_crate": true, "is_stripped": false, "items": [2]}},
"name": "simple_private",
"visibility": "public"
}
},
"paths": {"3": {"crate_id": 0, "kind": "module", "path": ["simple_private"]}},
"root": 3
}
There's no path entry for 0
, but there should be.
Found while looking at #134880.
We should have the jsondoclint validator check this, something like
diff --git a/src/tools/jsondoclint/src/validator.rs b/src/tools/jsondoclint/src/validator.rs
index f7c752033c5..73aa86d9c90 100644
--- a/src/tools/jsondoclint/src/validator.rs
+++ b/src/tools/jsondoclint/src/validator.rs
@@ -303,7 +303,12 @@ fn check_path(&mut self, x: &'a Path, kind: PathKind) {
PathKind::Trait => self.add_trait_or_alias_id(&x.id),
PathKind::Type => self.add_type_id(&x.id),
}
- if let Some(args) = &x.args {
+
+ if !self.krate.paths.contains_key(&x.id) {
+ panic!("no $.paths entry for {x:?}");
+ }
+
+ if let Some(args) = &*x.args {
self.check_generic_args(&**args);
}
}