Repository: rust
Issue: Rustdoc-Json: some item IDs are missing in `paths` field.
Labels: T-rustdoc,C-bug,A-rustdoc-json

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

#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:

```rust
//! [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();
}
```

```console
$ 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.

```console
$ 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.

```console
$ 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
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`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
```