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] Don't document stripped items in JSON renderer. #83055

Merged
merged 3 commits into from
Mar 26, 2021

Conversation

aDotInTheVoid
Copy link
Member

@aDotInTheVoid aDotInTheVoid commented Mar 12, 2021

Fixes #80664, see my comment there for why

Note that we already do something similar in convert_item:

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

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

r? @jyn514
cc @CraftSpider

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

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)

Copy link
Member

@jyn514 jyn514 left a comment

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.

src/librustdoc/formats/renderer.rs Outdated Show resolved Hide resolved
src/librustdoc/formats/renderer.rs Outdated Show resolved Hide resolved
@jyn514
Copy link
Member

jyn514 commented Mar 22, 2021

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?

@jyn514 jyn514 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
@jyn514 jyn514 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
@jyn514 jyn514 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
Copy link
Member

@jyn514 jyn514 left a comment

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 ?

src/librustdoc/json/mod.rs Outdated Show resolved Hide resolved
@aDotInTheVoid
Copy link
Member Author

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
Copy link
Member Author

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

@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 Mar 22, 2021
@jyn514
Copy link
Member

jyn514 commented Mar 24, 2021

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
Member

jyn514 commented Mar 24, 2021

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
Member

jyn514 commented Mar 24, 2021

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
Copy link
Member Author

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
Copy link
Member Author

aDotInTheVoid commented Mar 24, 2021

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

@rustbot rustbot 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
@rust-log-analyzer

This comment has been minimized.

@aDotInTheVoid
Copy link
Member Author

Rebased onto master, can reproduce

@aDotInTheVoid
Copy link
Member Author

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

@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 Mar 24, 2021
@jyn514
Copy link
Member

jyn514 commented Mar 25, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Mar 25, 2021

📌 Commit d9e2d8d has been approved by jyn514

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

Fixes rust-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:master Mar 26, 2021
@rustbot rustbot 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``
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.
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