Skip to content
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: Items who'se original path isn't visiable doen't appear in Crate::paths #135309

Open
aDotInTheVoid opened this issue Jan 9, 2025 · 0 comments
Labels
A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@aDotInTheVoid
Copy link
Member

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);
         }
     }
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 9, 2025
@aDotInTheVoid aDotInTheVoid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-json Area: Rustdoc JSON backend and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants