4

[rustdoc] Fix handling of stripped enum variant in JSON output format by Guillau...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/100582
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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')]"

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.

Suggested change
// @!has enum_variant_hidden.json "$.index[*][?(@.name=='u32')]"
// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_kind" '"tuple"'
// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_inner" []
All reactions

Thanks for the suggestion!

All reactions

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK