Skip to content

Commit 3106de5

Browse files
committed
Remove struct_type from union output and bump format
1 parent 74500b9 commit 3106de5

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

src/librustdoc/json/conversions.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl From<clean::ItemKind> for ItemEnum {
154154
}
155155
ImportItem(i) => ItemEnum::ImportItem(i.into()),
156156
StructItem(s) => ItemEnum::StructItem(s.into()),
157-
UnionItem(u) => ItemEnum::StructItem(u.into()),
157+
UnionItem(u) => ItemEnum::UnionItem(u.into()),
158158
StructFieldItem(f) => ItemEnum::StructFieldItem(f.into()),
159159
EnumItem(e) => ItemEnum::EnumItem(e.into()),
160160
VariantItem(v) => ItemEnum::VariantItem(v.into()),
@@ -205,11 +205,10 @@ impl From<clean::Struct> for Struct {
205205
}
206206
}
207207

208-
impl From<clean::Union> for Struct {
208+
impl From<clean::Union> for Union {
209209
fn from(struct_: clean::Union) -> Self {
210210
let clean::Union { generics, fields, fields_stripped } = struct_;
211-
Struct {
212-
struct_type: StructType::Union,
211+
Union {
213212
generics: generics.into(),
214213
fields_stripped,
215214
fields: ids(fields),

src/librustdoc/json/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
243243
)
244244
})
245245
.collect(),
246-
format_version: 2,
246+
format_version: 3,
247247
};
248248
let mut p = self.out_path.clone();
249249
p.push(output.index.get(&output.root).unwrap().name.clone().unwrap());

src/rustdoc-json-types/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ pub enum ItemEnum {
194194
},
195195
ImportItem(Import),
196196

197+
UnionItem(Union),
197198
StructItem(Struct),
198199
StructFieldItem(Type),
199200
EnumItem(Enum),
@@ -238,6 +239,14 @@ pub struct Module {
238239
pub items: Vec<Id>,
239240
}
240241

242+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
243+
pub struct Union {
244+
pub generics: Generics,
245+
pub fields_stripped: bool,
246+
pub fields: Vec<Id>,
247+
pub impls: Vec<Id>,
248+
}
249+
241250
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
242251
pub struct Struct {
243252
pub struct_type: StructType,
@@ -270,7 +279,6 @@ pub enum StructType {
270279
Plain,
271280
Tuple,
272281
Unit,
273-
Union,
274282
}
275283

276284
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]

src/test/rustdoc-json/unions/union.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @has union.json "$.index[*][?(@.name=='Union')].visibility" \"public\"
2+
// @has - "$.index[*][?(@.name=='Union')].kind" \"union\"
3+
// @!has - "$.index[*][?(@.name=='Union')].inner.struct_type"
4+
pub union Union {
5+
int: i32,
6+
float: f32,
7+
}

0 commit comments

Comments
 (0)