Rollup merge of #100582 - GuillaumeGomez:rustdoc-json-stripped-enum-variant, r=notriddle

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

Fixes https://github.com/rust-lang/rust/issues/100529.

cc ``@aDotInTheVoid`` ``@Enselic``
r? ``@notriddle``
This commit is contained in:
Matthias Krüger 2022-08-15 20:11:40 +02:00 committed by GitHub
commit fba30041f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View file

@ -662,12 +662,10 @@ impl FromWithTcx<clean::Variant> for Variant {
Tuple(fields) => Variant::Tuple(
fields
.into_iter()
.map(|f| {
if let clean::StructFieldItem(ty) = *f.kind {
ty.into_tcx(tcx)
} else {
unreachable!()
}
.filter_map(|f| match *f.kind {
clean::StructFieldItem(ty) => Some(ty.into_tcx(tcx)),
clean::StrippedItem(_) => None,
_ => unreachable!(),
})
.collect(),
),

View file

@ -0,0 +1,13 @@
// Regression test for <https://github.com/rust-lang/rust/issues/100529>.
#![no_core]
#![feature(no_core)]
// @has enum_variant_hidden.json "$.index[*][?(@.name=='ParseError')]"
// @has - "$.index[*][?(@.name=='UnexpectedEndTag')]"
// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_kind" '"tuple"'
// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_inner" []
pub enum ParseError {
UnexpectedEndTag(#[doc(hidden)] u32),
}