Skip to content

Add paths for linked associated items#156474

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
qaijuang:rustdoc-json-link-paths
Jul 22, 2026
Merged

Add paths for linked associated items#156474
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
qaijuang:rustdoc-json-link-paths

Conversation

@qaijuang

@qaijuang qaijuang commented May 11, 2026

Copy link
Copy Markdown
Contributor

View all comments

rustdoc-json emits intra-doc links to associated items using the associated item's id. For external associated items, that id is not present in index, and it was also missing from paths.

This PR backfills missing paths summaries for intra-doc link targets from the resolved page item and cached parent paths. Local targets are only added when already present in index, preserving jsondoclint's local-path invariant.

Fixes #152511

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 11, 2026
@qaijuang
qaijuang marked this pull request as ready for review May 12, 2026 05:29
@rustbot

rustbot commented May 12, 2026

Copy link
Copy Markdown
Collaborator

These commits modify tests/rustdoc-json.
rustdoc-json is a public (but unstable) interface.

Please ensure that if you've changed the output:

  • It's intentional.
  • The FORMAT_VERSION in src/librustdoc-json-types is bumped if necessary.

cc @aDotInTheVoid, @obi1kenobi

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 12, 2026
@rustbot

rustbot commented May 12, 2026

Copy link
Copy Markdown
Collaborator

r? @lolbinarycat

rustbot has assigned @lolbinarycat.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 9 candidates
  • Random selection from GuillaumeGomez, camelid, fmease, lolbinarycat, notriddle

@aDotInTheVoid

Copy link
Copy Markdown
Member

r? @aDotInTheVoid

@aDotInTheVoid aDotInTheVoid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up. Sorry for taking so long to get back to you.

View changes since this review

Comment thread src/librustdoc/json/mod.rs Outdated
paths
}

#[allow(rustc::potential_query_instability)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Could this attribute be more tightly scoped on the call causing the instability.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still not clear (to me) which call is causing the instability here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the diag without it:

warning: using `values` can result in unstable query results
   --> src/librustdoc/json/mod.rs:137:48
    |
137 |         let links = self.cache.intra_doc_links.values();
    |                                                ^^^^^^
    |
    = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
note: the lint level is defined here
   --> src/librustdoc/lib.rs:18:9
    |
 18 | #![warn(rustc::internal)]
    |         ^^^^^^^^^^^^^^^
    = note: `#[warn(rustc::potential_query_instability)]` implied by `#[warn(rustc::internal)]`

Comment thread src/librustdoc/json/mod.rs Outdated
Comment thread src/librustdoc/json/mod.rs Outdated
Comment thread src/librustdoc/json/mod.rs Outdated
//@ is "$.index[?(@.name=='non_page')].links['`Trait::method`']" $method

// Regression test for <https://github.com/rust-lang/rust/issues/152511>:
// link target IDs for associated items need matching `paths` entries.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like this to test that the ID's are also correct, but I think that would need something like #142479 to be able to express.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we wait on #142479 ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, this implementation is hairy enough that I don't think it should be merged without more robust tests, to provide assurance of present and ongoing correctness.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IDs are still not tested, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, unless @aDotInTheVoid says otherwise.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#142479 was merged, allowing to test IDs (which is the blocker for this PR). So what's blocking you?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing with the IDs which i landed in c78d0a7

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. Then looks good to me.

@rustbot

This comment has been minimized.

@qaijuang
qaijuang force-pushed the rustdoc-json-link-paths branch from a6a1fe3 to 3003031 Compare June 15, 2026 11:32
@rustbot

This comment has been minimized.

@aDotInTheVoid

Copy link
Copy Markdown
Member

Blocked on #142479 (see #156474 (comment))

@rustbot blocked

I can no longer approve this (rust-lang/team#2523)

r? rustdoc-json-backend

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-rustdoc-json-backend Relevant to the rustdoc JSON backend team, which will review and decide on the PR/issue. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 20, 2026
@qaijuang
qaijuang force-pushed the rustdoc-json-link-paths branch from 3003031 to c78d0a7 Compare July 16, 2026 11:52
@rustbot

rustbot commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@qaijuang

Copy link
Copy Markdown
Contributor Author

Blocked on #142479 (see #156474 (comment))

@rustbot blocked

I can no longer approve this (rust-lang/team#2523)

r? rustdoc-json-backend

@aDotInTheVoid I believe we're good to go with c78d0a7

@GuillaumeGomez

Copy link
Copy Markdown
Member

@bors r=aDotInTheVoid,GuillaumeGomez rollup

@rust-bors

rust-bors Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

📋 This PR cannot be approved because it currently has the following label: S-blocked.

@GuillaumeGomez GuillaumeGomez removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Jul 21, 2026
@GuillaumeGomez

Copy link
Copy Markdown
Member

Interesting, didn't know about this feature.

@bors r=aDotInTheVoid,GuillaumeGomez rollup

@rust-bors

rust-bors Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c78d0a7 has been approved by aDotInTheVoid,GuillaumeGomez

It is now in the queue for this repository.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 21, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 21, 2026
…r=aDotInTheVoid,GuillaumeGomez

Add paths for linked associated items

rustdoc-json emits intra-doc links to associated items using the associated item's id. For external associated items, that id is not present in `index`, and it was also missing from `paths`.

This PR backfills missing `paths` summaries for intra-doc link targets from the resolved page item and cached parent paths. Local targets are only added when already present in `index`, preserving jsondoclint's local-path invariant.

Fixes rust-lang#152511
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 21, 2026
…r=aDotInTheVoid,GuillaumeGomez

Add paths for linked associated items

rustdoc-json emits intra-doc links to associated items using the associated item's id. For external associated items, that id is not present in `index`, and it was also missing from `paths`.

This PR backfills missing `paths` summaries for intra-doc link targets from the resolved page item and cached parent paths. Local targets are only added when already present in `index`, preserving jsondoclint's local-path invariant.

Fixes rust-lang#152511
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 21, 2026
…r=aDotInTheVoid,GuillaumeGomez

Add paths for linked associated items

rustdoc-json emits intra-doc links to associated items using the associated item's id. For external associated items, that id is not present in `index`, and it was also missing from `paths`.

This PR backfills missing `paths` summaries for intra-doc link targets from the resolved page item and cached parent paths. Local targets are only added when already present in `index`, preserving jsondoclint's local-path invariant.

Fixes rust-lang#152511
rust-bors Bot pushed a commit that referenced this pull request Jul 21, 2026
Rollup of 12 pull requests

Successful merges:

 - #159582 (Sync from portable simd 2026 07 20)
 - #158890 (Fix splat v0 mangling)
 - #159411 ([rustdoc] Correctly handle output options with --show-coverage)
 - #159647 (Remove `early_exit` closures)
 - #159656 (define a `Simd` type in `minicore`)
 - #156474 (Add paths for linked associated items)
 - #159211 (Fix debuginfo argument when invoking LLBC linker)
 - #159527 (Bring runtime symbols statics on par with foreign functions)
 - #159625 (Refactor is_opsem_inhabited)
 - #159652 (Remove `cfg(not(no_global_oom_handling))` from the `Drop` impl of `UniqueArcUninit`)
 - #159657 (Remove the blanket `#![cfg_attr(test, allow(unused))]` from bootstrap )
 - #159663 (Add layout cycle hang regression test)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 22, 2026
…r=aDotInTheVoid,GuillaumeGomez

Add paths for linked associated items

rustdoc-json emits intra-doc links to associated items using the associated item's id. For external associated items, that id is not present in `index`, and it was also missing from `paths`.

This PR backfills missing `paths` summaries for intra-doc link targets from the resolved page item and cached parent paths. Local targets are only added when already present in `index`, preserving jsondoclint's local-path invariant.

Fixes rust-lang#152511
rust-bors Bot pushed a commit that referenced this pull request Jul 22, 2026
Rollup of 13 pull requests

Successful merges:

 - #159582 (Sync from portable simd 2026 07 20)
 - #158890 (Fix splat v0 mangling)
 - #159614 (debuginfo generation for unsafe binders)
 - #159647 (Remove `early_exit` closures)
 - #159656 (define a `Simd` type in `minicore`)
 - #156474 (Add paths for linked associated items)
 - #159211 (Fix debuginfo argument when invoking LLBC linker)
 - #159527 (Bring runtime symbols statics on par with foreign functions)
 - #159625 (Refactor is_opsem_inhabited)
 - #159629 (Add more splat rust-call regression tests)
 - #159652 (Remove `cfg(not(no_global_oom_handling))` from the `Drop` impl of `UniqueArcUninit`)
 - #159657 (Remove the blanket `#![cfg_attr(test, allow(unused))]` from bootstrap )
 - #159663 (Add layout cycle hang regression test)
rust-bors Bot pushed a commit that referenced this pull request Jul 22, 2026
Rollup of 13 pull requests

Successful merges:

 - #159582 (Sync from portable simd 2026 07 20)
 - #158890 (Fix splat v0 mangling)
 - #159614 (debuginfo generation for unsafe binders)
 - #159647 (Remove `early_exit` closures)
 - #159656 (define a `Simd` type in `minicore`)
 - #156474 (Add paths for linked associated items)
 - #159211 (Fix debuginfo argument when invoking LLBC linker)
 - #159527 (Bring runtime symbols statics on par with foreign functions)
 - #159625 (Refactor is_opsem_inhabited)
 - #159629 (Add more splat rust-call regression tests)
 - #159652 (Remove `cfg(not(no_global_oom_handling))` from the `Drop` impl of `UniqueArcUninit`)
 - #159657 (Remove the blanket `#![cfg_attr(test, allow(unused))]` from bootstrap )
 - #159663 (Add layout cycle hang regression test)
@rust-bors
rust-bors Bot merged commit 38d03cc into rust-lang:main Jul 22, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 22, 2026
rust-timer added a commit that referenced this pull request Jul 22, 2026
Rollup merge of #156474 - qaijuang:rustdoc-json-link-paths, r=aDotInTheVoid,GuillaumeGomez

Add paths for linked associated items

rustdoc-json emits intra-doc links to associated items using the associated item's id. For external associated items, that id is not present in `index`, and it was also missing from `paths`.

This PR backfills missing `paths` summaries for intra-doc link targets from the resolved page item and cached parent paths. Local targets are only added when already present in `index`, preserving jsondoclint's local-path invariant.

Fixes #152511
@qaijuang
qaijuang deleted the rustdoc-json-link-paths branch July 22, 2026 10:13
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jul 22, 2026
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#159582 (Sync from portable simd 2026 07 20)
 - rust-lang/rust#158890 (Fix splat v0 mangling)
 - rust-lang/rust#159614 (debuginfo generation for unsafe binders)
 - rust-lang/rust#159647 (Remove `early_exit` closures)
 - rust-lang/rust#159656 (define a `Simd` type in `minicore`)
 - rust-lang/rust#156474 (Add paths for linked associated items)
 - rust-lang/rust#159211 (Fix debuginfo argument when invoking LLBC linker)
 - rust-lang/rust#159527 (Bring runtime symbols statics on par with foreign functions)
 - rust-lang/rust#159625 (Refactor is_opsem_inhabited)
 - rust-lang/rust#159629 (Add more splat rust-call regression tests)
 - rust-lang/rust#159652 (Remove `cfg(not(no_global_oom_handling))` from the `Drop` impl of `UniqueArcUninit`)
 - rust-lang/rust#159657 (Remove the blanket `#![cfg_attr(test, allow(unused))]` from bootstrap )
 - rust-lang/rust#159663 (Add layout cycle hang regression test)
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 S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-json-backend Relevant to the rustdoc JSON backend team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustdoc-json: links to associated items like methods have ids that don't exist in index or paths

5 participants