Skip to content

rustdoc-json: Items who'se original path isn't visiable doen't appear in Crate::paths #135309

Closed
@aDotInTheVoid

Description

@aDotInTheVoid
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);
         }
     }

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Jan 9, 2025
added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Jan 9, 2025
aDotInTheVoid

aDotInTheVoid commented on Jan 10, 2025

@aDotInTheVoid
MemberAuthor

Found a fix, PR soon(tm)

@rustbot claim

added 2 commits that reference this issue on Jan 12, 2025

Rollup merge of rust-lang#135348 - aDotInTheVoid:pathspathspaths, r=G…

3a01c2a

Rollup merge of rust-lang#135348 - aDotInTheVoid:pathspathspaths, r=G…

9d3ae11
added a commit that references this issue on Jan 13, 2025
95259f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-rustdoc-jsonArea: Rustdoc JSON backendT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @aDotInTheVoid@rustbot

    Issue actions

      rustdoc-json: Items who'se original path isn't visiable doen't appear in `Crate::paths` · Issue #135309 · rust-lang/rust