Skip to content

Commit fba3004

Browse files
authored
Rollup merge of rust-lang#100582 - GuillaumeGomez:rustdoc-json-stripped-enum-variant, r=notriddle
[rustdoc] Fix handling of stripped enum variant in JSON output format Fixes rust-lang#100529. cc ``@aDotInTheVoid`` ``@Enselic`` r? ``@notriddle``
2 parents 5319d24 + 36758a2 commit fba3004

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/librustdoc/json/conversions.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,10 @@ impl FromWithTcx<clean::Variant> for Variant {
662662
Tuple(fields) => Variant::Tuple(
663663
fields
664664
.into_iter()
665-
.map(|f| {
666-
if let clean::StructFieldItem(ty) = *f.kind {
667-
ty.into_tcx(tcx)
668-
} else {
669-
unreachable!()
670-
}
665+
.filter_map(|f| match *f.kind {
666+
clean::StructFieldItem(ty) => Some(ty.into_tcx(tcx)),
667+
clean::StrippedItem(_) => None,
668+
_ => unreachable!(),
671669
})
672670
.collect(),
673671
),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/100529>.
2+
3+
#![no_core]
4+
#![feature(no_core)]
5+
6+
// @has enum_variant_hidden.json "$.index[*][?(@.name=='ParseError')]"
7+
// @has - "$.index[*][?(@.name=='UnexpectedEndTag')]"
8+
// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_kind" '"tuple"'
9+
// @is - "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant_inner" []
10+
11+
pub enum ParseError {
12+
UnexpectedEndTag(#[doc(hidden)] u32),
13+
}

0 commit comments

Comments
 (0)