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: some item IDs are missing in paths field. #101687

Open
gifnksm opened this issue Sep 11, 2022 · 3 comments
Open

Rustdoc-Json: some item IDs are missing in paths field. #101687

gifnksm opened this issue Sep 11, 2022 · 3 comments
Labels
A-rustdoc-json Area: Rustdoc JSON backend C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@gifnksm
Copy link
Contributor

gifnksm commented Sep 11, 2022

#101531 fixed an issue that some IDs in the links field are incorrect.
Now, IDs in the links field are correct, but some IDs are missing in the paths field.

I tried this code:

//! [FooStruct::foo_field]
//! [FooEnum::FooVariant]
//! [FooTrait::FOO_CONSTANT]
//! [FooTrait::FooType]
//! [FooTrait::foo_method]
//!
//! [Option::Some]

pub struct FooStruct {
    pub foo_field: bool,
}

pub enum FooEnum {
    FooVariant,
}

pub trait FooTrait {
    const FOO_CONSTANT: bool;
    type FooType;
    fn foo_method();
}
$ rustdoc +nightly foo_mod.rs --output-format json -Z unstable-options

$ jq -C < doc/foo_mod.json '.index[.root]'
{
  "id": "0:0:1593",
  "crate_id": 0,
  "name": "foo_mod",
  "span": {
    "filename": "foo_mod.rs",
    "begin": [
      1,
      0
    ],
    "end": [
      20,
      1
    ]
  },
  "visibility": "public",
  "docs": "[FooStruct::foo_field]\n[FooEnum::FooVariant]\n[FooTrait::FOO_CONSTANT]\n[FooTrait::FooType]\n[FooTrait::foo_method]\n[Option::Some]",
  "links": {
    "FooStruct::foo_field": "0:4:1586",
    "FooTrait::FOO_CONSTANT": "0:9:1590",
    "FooTrait::foo_method": "0:11:1592",
    "FooEnum::FooVariant": "0:6:1588",
    "FooTrait::FooType": "0:10:1591",
    "Option::Some": "2:47812:219"
  },
  "attrs": [],
  "deprecation": null,
  "kind": "module",
  "inner": {
    "is_crate": true,
    "items": [
      "0:3:1585",
      "0:5:1587",
      "0:8:1589"
    ],
    "is_stripped": false
  }
}

I expected to see this happen: links field contains the IDs of link targets, and we can retrieve the path of the item from paths field.

$ jq -C < doc/foo_mod.json '.paths[.index[.root].links["FooStruct::foo_field"]]'
{
  "crate_id": 0,
  "path": [
    "foo_mod",
    "FooStruct",
    "foo_field"
  ],
  "kind": "struct_field"
}

$ jq -C < doc/foo_mod.json '.paths[.index[.root].links["FooEnum::FooVariant"]]'
{
  "crate_id": 0,
  "path": [
    "foo_mod",
    "FooEnum",
    "Variant"
  ],
  "kind": "variant"
}

$ jq -C < doc/foo_mod.json '.paths[.index[.root].links["Option::Some"]]'
{
  "crate_id": 1,
  "path": [
    "std",
    "option",
    "Option",
    "Some"
   ],
  "kind": "variant"
}

$  jq -C < doc/foo_mod.json '.paths[.index[.root].links["FooTrait::FOO_CONSTANT"]]'
{
  "crate_id": 0,
  "path": [
    "foo_mod",
    "FooTrait",
    "FOO_CONSTANT"
  ],
  "kind": "assoc_const"
}

$ jq -C < doc/foo_mod.json '.paths[.index[.root].links["FooTrait::FooType"]]'
{
  "crate_id": 0,
  "path": [
    "foo_mod",
    "FooTrait",
    "FooType"
  ],
  "kind": "assoc_type"
}

$ jq -C < doc/foo_mod.json '.paths[.index[.root].links["FooTrait::foo_method"]]'
{
  "crate_id": 0,
  "path": [
    "foo_mod",
    "FooTrait",
    "foo_method"
  ],
  "kind": "method"
}

Instead, this happened: paths does not contain some items.

$ jq -C < doc/foo_mod.json '.paths[.index[.root].links["FooStruct::foo_field"]]'
null

$ jq -C < doc/foo_mod.json '.paths[.index[.root].links["FooEnum::FooVariant"]]'
{
  "crate_id": 0,
  "path": [
    "foo_mod",
    "FooEnum",
    "FooVariant"
  ],
  "kind": "variant"
}

$ jq -C < doc/foo_mod.json '.paths[.index[.root].links["Option::Some"]]'
null

$  jq -C < doc/foo_mod.json '.paths[.index[.root].links["FooTrait::FOO_CONSTANT"]]'
null

$ jq -C < doc/foo_mod.json '.paths[.index[.root].links["FooTrait::FooType"]]'
null

$ jq -C < doc/foo_mod.json '.paths[.index[.root].links["FooTrait::foo_method"]]'

Meta

rustdoc +nightly --version --verbose:

rustdoc 1.65.0-nightly (228710758 2022-09-10)
binary: rustdoc
commit-hash: 2287107588d92889d282e6cd3c1ca5df34cd34a5
commit-date: 2022-09-10
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0
@gifnksm gifnksm added the C-bug Category: This is a bug. label Sep 11, 2022
@Urgau
Copy link
Member

Urgau commented Sep 11, 2022

paths have being broken for a while. They also don't take into account re-export. We should just remove paths completely.

cf. #93522

@jyn514
Copy link
Member

jyn514 commented Sep 11, 2022

cc #86798

@aDotInTheVoid
Copy link
Member

@rustbot modify labels: +A-rustdoc-json +T-rustdoc

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Sep 11, 2022
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 C-bug Category: This is a bug. 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

5 participants