Skip to content

[rustdoc] Don't document stripped items in JSON renderer. - #83055

Merged
bors merged 3 commits into
rust-lang:masterfrom
aDotInTheVoid:selective-strip-item-doc
Mar 26, 2021
Merged

[rustdoc] Don't document stripped items in JSON renderer.#83055
bors merged 3 commits into
rust-lang:masterfrom
aDotInTheVoid:selective-strip-item-doc

Conversation

@aDotInTheVoid

@aDotInTheVoidaDotInTheVoid commented Mar 12, 2021

Copy link
Copy Markdown
Member

Fixes#80664, see my comment there for why

Note that we already do something similar in convert_item:

let inner = match*kind {
clean::StrippedItem(_) => returnNone,
x => from_clean_item_kind(x,self.tcx,&name),
};

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

r? @jyn514
cc @CraftSpider

@rustbotrustbot 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 Mar 12, 2021
@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 12, 2021
@aDotInTheVoid

Copy link
Copy Markdown
MemberAuthor

This line

StrippedItem(inner) => from_clean_item_kind(*inner, tcx, name),

Should be changed to unreachable I think, as we should never call from_clean_item_kind on a StrippedItem
(or make from_clean_item_kind return an Option)

@jyn514jyn514 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.

Looks good assuming my comment in #80664 (comment) is accurate that JSON doesn't care about inlining.

Comment threadsrc/librustdoc/formats/renderer.rs Outdated
Comment threadsrc/librustdoc/formats/renderer.rs Outdated
@jyn514

jyn514 commented Mar 22, 2021

Copy link
Copy Markdown
Member

This line

StrippedItem(inner) => from_clean_item_kind(*inner, tcx, name),

Should be changed to unreachable I think, as we should never call from_clean_item_kind on a StrippedItem
(or make from_clean_item_kind return an Option)

Sounds good - could you change that to unreachable! as part of this PR?

@jyn514jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 22, 2021
@jyn514jyn514 changed the title [rustdoc] Only document items in striped modules in html renderer.[rustdoc] Only document items in stripped modules in html renderer.Mar 22, 2021
@jyn514jyn514 changed the title [rustdoc] Only document items in stripped modules in html renderer.[rustdoc] Don't document stripped items in JSON renderer.Mar 22, 2021
@aDotInTheVoid
aDotInTheVoidforce-pushed the selective-strip-item-doc branch from 7d9ac84 to a72ef29CompareMarch 22, 2021 17:12

@jyn514jyn514 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.

It looks like you're still making changes, but when you're ready for review - what's going on in bdf6786 ?

Comment threadsrc/librustdoc/json/mod.rs Outdated
@aDotInTheVoid

Copy link
Copy Markdown
MemberAuthor

It looks like you're still making changes, but when you're ready for review - what's going on in bdf6786 ?

It turns out that we also don't need to call item even for no striped modules. And this fixes the Duplication, at least with the current test suite. I'm trying it with tests for #83057 now, and it looks less promizing.

I'll let you know when this is ready for review

@rust-log-analyzer

This comment has been minimized.

@aDotInTheVoid
aDotInTheVoidforce-pushed the selective-strip-item-doc branch from 9cf63eb to fc82df4CompareMarch 22, 2021 22:18
@aDotInTheVoid

Copy link
Copy Markdown
MemberAuthor

This PR is a bit of a mess, but now does 3 things

  1. Avoids recursing in run_format, controlled by a const in FormatRenderer. This fixes ICE on rustdoc-json with re-export due to ID collision #80664. Also add a test for that
  2. Adds tests for where the index still has collisions, even with change 1
  3. Improvements to jsondocck to make the first 2 changes possible

The git history is a mess, and I'd be willing to clean it up and/or split this into 3 pr's if you want

@rustbot modify labels: -S-waiting-on-author +S-waiting-on-review

@rustbotrustbot 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 Mar 22, 2021
@jyn514

Copy link
Copy Markdown
Member

It turns out that we also don't need to call item even for non stripped modules. And this fixes the Duplication, at least with the current test suite. I'm trying it with tests for #83057 now, and it looks less promizing.

Can you post what tests fail when you disable this for the HTML backend too? I'd like to keep it in sync with the JSON backend where possible.

@jyn514

Copy link
Copy Markdown
Member

The git history is a mess, and I'd be willing to clean it up and/or split this into 3 pr's if you want

Splitting this into 2 commits - one changing jsondocck, the other fixing the bug - seems fine.

@jyn514

Copy link
Copy Markdown
Member

Adds tests for where the index still has collisions, even with change 1

It wasn't clear to me by reading: which test is this? Where is the collision? Could you add it as a comment?

@aDotInTheVoid
aDotInTheVoidforce-pushed the selective-strip-item-doc branch from fc82df4 to eb72f7eCompareMarch 24, 2021 15:57
@aDotInTheVoid

Copy link
Copy Markdown
MemberAuthor

Can you post what tests fail when you disable this for the HTML backend too? I'd like to keep it in sync with the JSON backend where possible.

Like every single one. log. If instead we instrad call for non-striped, but dont for non striped the following tests fail

 [rustdoc] rustdoc/inline_local/glob-extern.rs
[rustdoc] rustdoc/inline_local/glob-private.rs
[rustdoc] rustdoc/redirect-const.rs
[rustdoc] rustdoc/redirect-rename.rs
[rustdoc] rustdoc/redirect.rs

(accurate 2 weeks ago, I can rerun now if it realy matters) log

It wasn't clear to me by reading: which test is this? Where is the collision? Could you add it as a comment?

Its the in_root_and_mod ones. Theirs a comment by the assert, because the tests will still be good, even once this is gone.

Splitting this into 2 commits - one changing jsondocck, the other fixing the bug - seems fine.

Done and force pushed

@jyn514 this is now waiting on review, you forgot to set it to waiting on author.

@rust-log-analyzer

This comment has been minimized.

@aDotInTheVoid

aDotInTheVoid commented Mar 24, 2021

Copy link
Copy Markdown
MemberAuthor

Welp, I guess not. Cant reproduce the error (./x.py test src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs) passes

@rustbot modify labels: -S-waiting-on-review +S-waiting-on-author

@rustbotrustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 24, 2021
@aDotInTheVoid
aDotInTheVoidforce-pushed the selective-strip-item-doc branch from eb72f7e to 9ba9297CompareMarch 24, 2021 16:54
@rust-log-analyzer

This comment has been minimized.

@aDotInTheVoid

Copy link
Copy Markdown
MemberAuthor

Rebased onto master, can reproduce

@aDotInTheVoid

Copy link
Copy Markdown
MemberAuthor

@rustbot modify labels: -S-waiting-on-author +S-waiting-on-review

@rustbotrustbot 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 Mar 24, 2021
@jyn514

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Mar 25, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit d9e2d8d has been approved by jyn514

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 25, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 25, 2021
…doc, r=jyn514
[rustdoc] Don't document stripped items in JSON renderer.
Fixesrust-lang#80664, see [my comment there](rust-lang#80664 (comment)) for why
Note that we already do something similar in `convert_item`:
https://github.com/rust-lang/rust/blob/bb4cdf8ec034dca5c056ec9295f38062e5b7e871/src/librustdoc/json/conversions.rs#L28-L31
`@rustbot` modify labels: +T-rustdoc +A-rustdoc-json
r? `@jyn514`
cc `@CraftSpider`
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 26, 2021
Rollup of 8 pull requests
Successful merges:
- rust-lang#83055 ([rustdoc] Don't document stripped items in JSON renderer.)
- rust-lang#83437 (Refactor rust-lang#82270 as lint instead of an error)
- rust-lang#83444 (Fix bootstrap tests on beta)
- rust-lang#83456 (Add docs for Vec::from functions)
- rust-lang#83463 (ExitStatusExt: Fix missing word in two docs messages)
- rust-lang#83470 (Fix patch note about rust-lang#80653 not mentioning nested nor recursive)
- rust-lang#83485 (Mark asm tests as requiring LLVM 10.0.1)
- rust-lang#83486 (Don't ICE when using `#[global_alloc]` on a non-item statement)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 0502815 into rust-lang:masterMar 26, 2021
@rustbotrustbot added this to the 1.53.0 milestone Mar 26, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Apr 24, 2021
rustdoc: Turn `JsonRenderer::mod_item_in` into `unreachable!()`
The JSON renderer no longer gets called on modules (since rust-lang#83055).
r? `@aDotInTheVoid`
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Apr 24, 2021
rustdoc: Turn `JsonRenderer::mod_item_in` into `unreachable!()`
The JSON renderer no longer gets called on modules (since rust-lang#83055).
r? ``@aDotInTheVoid``
@aDotInTheVoid
aDotInTheVoid deleted the selective-strip-item-doc branch December 2, 2024 19:03
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-jsonArea: Rustdoc JSON backendS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE on rustdoc-json with re-export due to ID collision

6 participants

@aDotInTheVoid@jyn514@rust-log-analyzer@bors@rust-highfive@rustbot