-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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] Fix handling of stripped enum variant in JSON output format #100582
[rustdoc] Fix handling of stripped enum variant in JSON output format #100582
Conversation
This comment has been minimized.
This comment has been minimized.
|
||
// @has enum_variant_hidden.json "$.index[*][?(@.name=='ParseError')]" | ||
// @has enum_variant_hidden.json "$.index[*][?(@.name=='UnexpectedEndTag')]" | ||
// @!has enum_variant_hidden.json "$.index[*][?(@.name=='u32')]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't test that the field was hidden, as
// @has enum_variant_hidden.json "$.index[*][?(@.name=='ParseError')]"
// @has enum_variant_hidden.json "$.index[*][?(@.name=='UnexpectedEndTag')]"
// @!has enum_variant_hidden.json "$.index[*][?(@.name=='u32')]"
pub enum ParseError {
UnexpectedEndTag(u32),
}
will also pass the test.
Primitives arn't stored in the index, but in a varient of Type
, so the output of the above is
"inner": {
"variant_inner": [
{"inner": "u32", "kind": "primitive"}
],
"variant_kind": "tuple"
},
Instead, just directly check that the variant doesn't list having any fields.
// @!has enum_variant_hidden.json "$.index[*][?(@.name=='u32')]" | |
// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_kind" '"tuple"' | |
// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_inner" [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion!
At some point their should also be a enum Foo {
A(i32)
B(i32, #[doc(hidden)] i32)
C(#[doc(hidden)] i32, i32)
} but HTML gets a good representation: The solution is probably to do what we do for structs, and store the enum Foo {
A(#[doc(hidden)] i32),
B(#[doc(hidden)]i32, #[doc(hidden)]i32)
} This also effects struct AFAIKT. I don't think this needs to be done now. I'll file an issue for it. |
c3250f5
to
9d52991
Compare
It makes sense. Let's do it in another PR as you suggested then (and thanks for opening the issue!). |
@@ -0,0 +1,10 @@ | |||
#![no_std] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some stylistic nitpicks (feel free to ignore)
- I don't find it's worth using
#![no_std]
, as it doesnt remove enought to make inspecing the output plesent. (wc -c
for empty rust file: 371,664 for nothing, 97,448 for#[no_std]
, 478 for #![no_core]` - For json, only the first selection needs to use a the path to a json file, the rest can just use
-
(Also, we should change jsondocck to know the name of the json file) - A link to the issue would be convenient for future reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All very good points. I'll apply them all. Can you open an issue for jsondocck improvement idea please?
9d52991
to
36758a2
Compare
Applied your comments. :) |
@bors r+ |
…ed-enum-variant, r=notriddle [rustdoc] Fix handling of stripped enum variant in JSON output format Fixes rust-lang#100529. cc `@aDotInTheVoid` `@Enselic` r? `@notriddle`
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#100031 (improve "try ignoring the field" diagnostic) - rust-lang#100325 (Rustdoc-Json: Don't remove impls for items imported from private modules) - rust-lang#100377 (Replace - with _ in fluent slugs to improve developer workflows) - rust-lang#100458 (Adjust span of fn argument declaration) - rust-lang#100514 (Delay span bug when failing to normalize negative coherence impl subject due to other malformed impls) - rust-lang#100528 (Support 1st group of RISC-V Bitmanip backend target features) - rust-lang#100559 (Parser simplifications) - rust-lang#100568 (Fix STD build for ESP-IDF) - rust-lang#100582 ([rustdoc] Fix handling of stripped enum variant in JSON output format) - rust-lang#100586 (Reland changes replacing num_cpus with available_parallelism ) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
@bors r=aDotInTheVoid |
💡 This pull request was already approved, no need to approve it again.
|
Woups, the update didn't appear until I commented. Sorry. |
Fixes #100529.
cc @aDotInTheVoid @Enselic
r? @notriddle