Skip to content

Commit

Permalink
Rollup merge of #100582 - GuillaumeGomez:rustdoc-json-stripped-enum-v…
Browse files Browse the repository at this point in the history
…ariant, r=notriddle

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

Fixes #100529.

cc ``@aDotInTheVoid`` ``@Enselic``
r? ``@notriddle``
  • Loading branch information
matthiaskrgr authored Aug 15, 2022
2 parents 5319d24 + 36758a2 commit fba3004
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
Expand Down
13 changes: 13 additions & 0 deletions src/test/rustdoc-json/enum_variant_hidden.rs
Original file line number Diff line number Diff line change
@@ -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),
}

0 comments on commit fba3004

Please sign in to comment.