Skip to content

Commit 1e537ed

Browse files
authored
wit-parser: change serde format for enum Stability (#1598)
Now consistent with other enums in this crate, using the externally tagged representation: https://serde.rs/enum-representations.html#externally-tagged
1 parent 257818e commit 1e537ed

File tree

3 files changed

+165
-111
lines changed

3 files changed

+165
-111
lines changed

crates/wit-parser/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ impl Function {
827827
/// annotations were added to WIT.
828828
#[derive(Debug, Clone, PartialEq, Eq)]
829829
#[cfg_attr(feature = "serde", derive(serde_derive::Deserialize, Serialize))]
830-
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase", tag = "type"))]
830+
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
831831
pub enum Stability {
832832
/// `@since(version = 1.2.3)`
833833
///

crates/wit-parser/tests/ui/feature-gates.wit.json

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"interface": {
88
"id": 4,
99
"stability": {
10-
"type": "unstable",
11-
"feature": "active"
10+
"unstable": {
11+
"feature": "active"
12+
}
1213
}
1314
}
1415
}
@@ -18,16 +19,18 @@
1819
"interface": {
1920
"id": 4,
2021
"stability": {
21-
"type": "unstable",
22-
"feature": "active"
22+
"unstable": {
23+
"feature": "active"
24+
}
2325
}
2426
}
2527
}
2628
},
2729
"package": 0,
2830
"stability": {
29-
"type": "unstable",
30-
"feature": "active"
31+
"unstable": {
32+
"feature": "active"
33+
}
3134
}
3235
},
3336
{
@@ -37,8 +40,9 @@
3740
"interface": {
3841
"id": 4,
3942
"stability": {
40-
"type": "unstable",
41-
"feature": "active"
43+
"unstable": {
44+
"feature": "active"
45+
}
4246
}
4347
}
4448
}
@@ -48,8 +52,9 @@
4852
"interface": {
4953
"id": 4,
5054
"stability": {
51-
"type": "unstable",
52-
"feature": "active"
55+
"unstable": {
56+
"feature": "active"
57+
}
5358
}
5459
}
5560
}
@@ -68,14 +73,16 @@
6873
"params": [],
6974
"results": [],
7075
"stability": {
71-
"type": "unstable",
72-
"feature": "active"
76+
"unstable": {
77+
"feature": "active"
78+
}
7379
}
7480
}
7581
},
7682
"stability": {
77-
"type": "unstable",
78-
"feature": "active"
83+
"unstable": {
84+
"feature": "active"
85+
}
7986
},
8087
"package": 0
8188
},
@@ -87,8 +94,9 @@
8794
},
8895
"functions": {},
8996
"stability": {
90-
"type": "unstable",
91-
"feature": "active"
97+
"unstable": {
98+
"feature": "active"
99+
}
92100
},
93101
"package": 0
94102
},
@@ -99,8 +107,9 @@
99107
},
100108
"functions": {},
101109
"stability": {
102-
"type": "unstable",
103-
"feature": "active"
110+
"unstable": {
111+
"feature": "active"
112+
}
104113
},
105114
"package": 0
106115
},
@@ -111,8 +120,9 @@
111120
},
112121
"functions": {},
113122
"stability": {
114-
"type": "unstable",
115-
"feature": "active"
123+
"unstable": {
124+
"feature": "active"
125+
}
116126
},
117127
"package": 0
118128
},
@@ -121,8 +131,9 @@
121131
"types": {},
122132
"functions": {},
123133
"stability": {
124-
"type": "unstable",
125-
"feature": "active"
134+
"unstable": {
135+
"feature": "active"
136+
}
126137
},
127138
"package": 0
128139
},
@@ -144,8 +155,9 @@
144155
}
145156
],
146157
"stability": {
147-
"type": "unstable",
148-
"feature": "active"
158+
"unstable": {
159+
"feature": "active"
160+
}
149161
}
150162
},
151163
"[static]ungated.x": {
@@ -156,8 +168,9 @@
156168
"params": [],
157169
"results": [],
158170
"stability": {
159-
"type": "unstable",
160-
"feature": "active"
171+
"unstable": {
172+
"feature": "active"
173+
}
161174
}
162175
},
163176
"[method]ungated.y": {
@@ -173,8 +186,9 @@
173186
],
174187
"results": [],
175188
"stability": {
176-
"type": "unstable",
177-
"feature": "active"
189+
"unstable": {
190+
"feature": "active"
191+
}
178192
}
179193
}
180194
},
@@ -191,8 +205,9 @@
191205
"interface": 1
192206
},
193207
"stability": {
194-
"type": "unstable",
195-
"feature": "active"
208+
"unstable": {
209+
"feature": "active"
210+
}
196211
}
197212
},
198213
{
@@ -204,8 +219,9 @@
204219
"interface": 1
205220
},
206221
"stability": {
207-
"type": "unstable",
208-
"feature": "active"
222+
"unstable": {
223+
"feature": "active"
224+
}
209225
}
210226
},
211227
{
@@ -217,8 +233,9 @@
217233
"interface": 2
218234
},
219235
"stability": {
220-
"type": "unstable",
221-
"feature": "active"
236+
"unstable": {
237+
"feature": "active"
238+
}
222239
}
223240
},
224241
{
@@ -230,8 +247,9 @@
230247
"interface": 3
231248
},
232249
"stability": {
233-
"type": "unstable",
234-
"feature": "active"
250+
"unstable": {
251+
"feature": "active"
252+
}
235253
}
236254
},
237255
{
@@ -241,8 +259,9 @@
241259
"interface": 5
242260
},
243261
"stability": {
244-
"type": "unstable",
245-
"feature": "active"
262+
"unstable": {
263+
"feature": "active"
264+
}
246265
}
247266
},
248267
{
@@ -254,8 +273,9 @@
254273
},
255274
"owner": null,
256275
"stability": {
257-
"type": "unstable",
258-
"feature": "active"
276+
"unstable": {
277+
"feature": "active"
278+
}
259279
}
260280
},
261281
{

0 commit comments

Comments
 (0)