Skip to content

Rustdoc-Json: Store Variant Fields as their own item. #101462

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Sep 6, 2022

Conversation

aDotInTheVoid
Copy link
Member

Closes #100587
Closes #92945

Successor to #100762

Unlike that one, we don't have merge StructType and Variant, as after #101386 Variant stores enum specific information (discriminant).

Resolves the naming discussion (#100762 (comment)) by having seperate enums for struct and enum kinds

Resolves #[doc(hidden)] on tuple structs (#100762 (comment)) by storing as a Vec<Option<Id>>

r? @GuillaumeGomez

@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 5, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 5, 2022
@rustbot
Copy link
Collaborator

rustbot commented Sep 5, 2022

rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing src/librustdoc/json/conversions.rs; otherwise, make sure you bump the FORMAT_VERSION constant.

cc @CraftSpider, @aDotInTheVoid, @Enselic

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member

I really like this approach. Just one comment: shouldn't we unify the stripped_fields thing? We could either store Struct fields into a Vec<Option<Id>> too or add a stripped_variants into Enum.

@aDotInTheVoid
Copy link
Member Author

aDotInTheVoid commented Sep 6, 2022

In my mind what should happen to Struct is we put fields in StructType, eg

enum StructKind {
   Unit,
   Tuple(Vec<Option<Id>>),
   Normal {
       fields: Vec<Id>,
       fields_stripped: bool,
  },
}

That way we only show the position of #[doc(hidden)] in the tuple case where it's relevant.

If that sounds good I'll send a follow up PR

@GuillaumeGomez
Copy link
Member

This is a good argument indeed. Let's keep it this way then!

@GuillaumeGomez
Copy link
Member

Thanks for the improvement (and the docs too!).

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Sep 6, 2022

📌 Commit 065e0b9 has been approved by GuillaumeGomez

It is now in the queue for this repository.

@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 Sep 6, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 6, 2022
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#101357 (Include enum path in variant suggestion)
 - rust-lang#101434 (Update `SessionDiagnostic::into_diagnostic` to take `Handler` instead of `ParseSess`)
 - rust-lang#101445 (Suggest introducing an explicit lifetime if it does not exist)
 - rust-lang#101457 (Recover from using `;` as separator between fields)
 - rust-lang#101462 (Rustdoc-Json: Store Variant Fields as their own item.)
 - rust-lang#101471 (Report number of delayed bugs properly with `-Ztreat-err-as-bug`)
 - rust-lang#101473 (Add more size assertions for MIR types.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b59c1aa into rust-lang:master Sep 6, 2022
@rustbot rustbot added this to the 1.65.0 milestone Sep 6, 2022
aDotInTheVoid added a commit to rust-lang/rustdoc-types that referenced this pull request Sep 7, 2022
# for free to join this conversation on GitHub. Already have an account? # 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
6 participants