@@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
11
11
/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
12
12
/// about the language items in the local crate, as well as info about external items to allow
13
13
/// tools to find or link to them.
14
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
14
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
15
15
pub struct Crate {
16
16
/// The id of the root [`Module`] item of the local crate.
17
17
pub root : Id ,
@@ -31,7 +31,7 @@ pub struct Crate {
31
31
pub format_version : u32 ,
32
32
}
33
33
34
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
34
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
35
35
pub struct ExternalCrate {
36
36
pub name : String ,
37
37
pub html_root_url : Option < String > ,
@@ -41,7 +41,7 @@ pub struct ExternalCrate {
41
41
/// information. This struct should contain enough to generate a link/reference to the item in
42
42
/// question, or can be used by a tool that takes the json output of multiple crates to find
43
43
/// the actual item definition with all the relevant info.
44
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
44
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
45
45
pub struct ItemSummary {
46
46
/// Can be used to look up the name and html_root_url of the crate this item came from in the
47
47
/// `external_crates` map.
@@ -53,7 +53,7 @@ pub struct ItemSummary {
53
53
pub kind : ItemKind ,
54
54
}
55
55
56
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
56
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
57
57
pub struct Item {
58
58
/// The unique identifier of this item. Can be used to find this item in various mappings.
59
59
pub id : Id ,
@@ -68,8 +68,9 @@ pub struct Item {
68
68
/// By default all documented items are public, but you can tell rustdoc to output private items
69
69
/// so this field is needed to differentiate.
70
70
pub visibility : Visibility ,
71
- /// The full markdown docstring of this item.
72
- pub docs : String ,
71
+ /// The full markdown docstring of this item. Absent if there is no documentation at all,
72
+ /// Some("") if there is some documentation but it is empty (EG `#[doc = ""]`).
73
+ pub docs : Option < String > ,
73
74
/// This mapping resolves [intra-doc links](https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md) from the docstring to their IDs
74
75
pub links : HashMap < String , Id > ,
75
76
/// Stringified versions of the attributes on this item (e.g. `"#[inline]"`)
@@ -79,7 +80,7 @@ pub struct Item {
79
80
pub inner : ItemEnum ,
80
81
}
81
82
82
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
83
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
83
84
pub struct Span {
84
85
/// The path to the source file for this span relative to the path `rustdoc` was invoked with.
85
86
pub filename : PathBuf ,
@@ -89,14 +90,14 @@ pub struct Span {
89
90
pub end : ( usize , usize ) ,
90
91
}
91
92
92
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
93
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
93
94
pub struct Deprecation {
94
95
pub since : Option < String > ,
95
96
pub note : Option < String > ,
96
97
}
97
98
98
99
#[ serde( rename_all = "snake_case" ) ]
99
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
100
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
100
101
pub enum Visibility {
101
102
Public ,
102
103
/// For the most part items are private by default. The exceptions are associated items of
@@ -112,7 +113,7 @@ pub enum Visibility {
112
113
}
113
114
114
115
#[ serde( rename_all = "snake_case" ) ]
115
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
116
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
116
117
pub enum GenericArgs {
117
118
/// <'a, 32, B: Copy, C = u32>
118
119
AngleBracketed { args : Vec < GenericArg > , bindings : Vec < TypeBinding > } ,
@@ -121,14 +122,14 @@ pub enum GenericArgs {
121
122
}
122
123
123
124
#[ serde( rename_all = "snake_case" ) ]
124
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
125
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
125
126
pub enum GenericArg {
126
127
Lifetime ( String ) ,
127
128
Type ( Type ) ,
128
129
Const ( Constant ) ,
129
130
}
130
131
131
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
132
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
132
133
pub struct Constant {
133
134
#[ serde( rename = "type" ) ]
134
135
pub type_ : Type ,
@@ -137,14 +138,14 @@ pub struct Constant {
137
138
pub is_literal : bool ,
138
139
}
139
140
140
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
141
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
141
142
pub struct TypeBinding {
142
143
pub name : String ,
143
144
pub binding : TypeBindingKind ,
144
145
}
145
146
146
147
#[ serde( rename_all = "snake_case" ) ]
147
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
148
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
148
149
pub enum TypeBindingKind {
149
150
Equality ( Type ) ,
150
151
Constraint ( Vec < GenericBound > ) ,
@@ -154,7 +155,7 @@ pub enum TypeBindingKind {
154
155
pub struct Id ( pub String ) ;
155
156
156
157
#[ serde( rename_all = "snake_case" ) ]
157
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
158
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
158
159
pub enum ItemKind {
159
160
Module ,
160
161
ExternCrate ,
@@ -184,7 +185,7 @@ pub enum ItemKind {
184
185
}
185
186
186
187
#[ serde( untagged) ]
187
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
188
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
188
189
pub enum ItemEnum {
189
190
ModuleItem ( Module ) ,
190
191
ExternCrateItem {
@@ -231,13 +232,13 @@ pub enum ItemEnum {
231
232
} ,
232
233
}
233
234
234
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
235
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
235
236
pub struct Module {
236
237
pub is_crate : bool ,
237
238
pub items : Vec < Id > ,
238
239
}
239
240
240
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
241
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
241
242
pub struct Struct {
242
243
pub struct_type : StructType ,
243
244
pub generics : Generics ,
@@ -246,7 +247,7 @@ pub struct Struct {
246
247
pub impls : Vec < Id > ,
247
248
}
248
249
249
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
250
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
250
251
pub struct Enum {
251
252
pub generics : Generics ,
252
253
pub variants_stripped : bool ,
@@ -256,67 +257,68 @@ pub struct Enum {
256
257
257
258
#[ serde( rename_all = "snake_case" ) ]
258
259
#[ serde( tag = "variant_kind" , content = "variant_inner" ) ]
259
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
260
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
260
261
pub enum Variant {
261
262
Plain ,
262
263
Tuple ( Vec < Type > ) ,
263
264
Struct ( Vec < Id > ) ,
264
265
}
265
266
266
267
#[ serde( rename_all = "snake_case" ) ]
267
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
268
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
268
269
pub enum StructType {
269
270
Plain ,
270
271
Tuple ,
271
272
Unit ,
273
+ Union ,
272
274
}
273
275
274
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
276
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
275
277
pub struct Function {
276
278
pub decl : FnDecl ,
277
279
pub generics : Generics ,
278
280
pub header : String ,
279
281
pub abi : String ,
280
282
}
281
283
282
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
284
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
283
285
pub struct Method {
284
286
pub decl : FnDecl ,
285
287
pub generics : Generics ,
286
288
pub header : String ,
287
289
pub has_body : bool ,
288
290
}
289
291
290
- #[ derive( Clone , Debug , Default , Serialize , Deserialize ) ]
292
+ #[ derive( Clone , Debug , Default , Serialize , Deserialize , PartialEq ) ]
291
293
pub struct Generics {
292
294
pub params : Vec < GenericParamDef > ,
293
295
pub where_predicates : Vec < WherePredicate > ,
294
296
}
295
297
296
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
298
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
297
299
pub struct GenericParamDef {
298
300
pub name : String ,
299
301
pub kind : GenericParamDefKind ,
300
302
}
301
303
302
304
#[ serde( rename_all = "snake_case" ) ]
303
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
305
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
304
306
pub enum GenericParamDefKind {
305
307
Lifetime ,
306
308
Type { bounds : Vec < GenericBound > , default : Option < Type > } ,
307
309
Const ( Type ) ,
308
310
}
309
311
310
312
#[ serde( rename_all = "snake_case" ) ]
311
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
313
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
312
314
pub enum WherePredicate {
313
315
BoundPredicate { ty : Type , bounds : Vec < GenericBound > } ,
314
316
RegionPredicate { lifetime : String , bounds : Vec < GenericBound > } ,
315
317
EqPredicate { lhs : Type , rhs : Type } ,
316
318
}
317
319
318
320
#[ serde( rename_all = "snake_case" ) ]
319
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
321
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
320
322
pub enum GenericBound {
321
323
TraitBound {
322
324
#[ serde( rename = "trait" ) ]
@@ -329,7 +331,7 @@ pub enum GenericBound {
329
331
}
330
332
331
333
#[ serde( rename_all = "snake_case" ) ]
332
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
334
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
333
335
pub enum TraitBoundModifier {
334
336
None ,
335
337
Maybe ,
@@ -338,7 +340,7 @@ pub enum TraitBoundModifier {
338
340
339
341
#[ serde( rename_all = "snake_case" ) ]
340
342
#[ serde( tag = "kind" , content = "inner" ) ]
341
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
343
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
342
344
pub enum Type {
343
345
/// Structs, enums, and traits
344
346
ResolvedPath {
@@ -391,22 +393,22 @@ pub enum Type {
391
393
} ,
392
394
}
393
395
394
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
396
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
395
397
pub struct FunctionPointer {
396
398
pub is_unsafe : bool ,
397
399
pub generic_params : Vec < GenericParamDef > ,
398
400
pub decl : FnDecl ,
399
401
pub abi : String ,
400
402
}
401
403
402
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
404
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
403
405
pub struct FnDecl {
404
406
pub inputs : Vec < ( String , Type ) > ,
405
407
pub output : Option < Type > ,
406
408
pub c_variadic : bool ,
407
409
}
408
410
409
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
411
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
410
412
pub struct Trait {
411
413
pub is_auto : bool ,
412
414
pub is_unsafe : bool ,
@@ -416,13 +418,13 @@ pub struct Trait {
416
418
pub implementors : Vec < Id > ,
417
419
}
418
420
419
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
421
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
420
422
pub struct TraitAlias {
421
423
pub generics : Generics ,
422
424
pub params : Vec < GenericBound > ,
423
425
}
424
426
425
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
427
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
426
428
pub struct Impl {
427
429
pub is_unsafe : bool ,
428
430
pub generics : Generics ,
@@ -438,7 +440,7 @@ pub struct Impl {
438
440
}
439
441
440
442
#[ serde( rename_all = "snake_case" ) ]
441
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
443
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
442
444
pub struct Import {
443
445
/// The full path being imported.
444
446
pub span : String ,
@@ -451,14 +453,14 @@ pub struct Import {
451
453
pub glob : bool ,
452
454
}
453
455
454
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
456
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
455
457
pub struct ProcMacro {
456
458
pub kind : MacroKind ,
457
459
pub helpers : Vec < String > ,
458
460
}
459
461
460
462
#[ serde( rename_all = "snake_case" ) ]
461
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
463
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
462
464
pub enum MacroKind {
463
465
/// A bang macro `foo!()`.
464
466
Bang ,
@@ -468,20 +470,20 @@ pub enum MacroKind {
468
470
Derive ,
469
471
}
470
472
471
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
473
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
472
474
pub struct Typedef {
473
475
#[ serde( rename = "type" ) ]
474
476
pub type_ : Type ,
475
477
pub generics : Generics ,
476
478
}
477
479
478
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
480
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
479
481
pub struct OpaqueTy {
480
482
pub bounds : Vec < GenericBound > ,
481
483
pub generics : Generics ,
482
484
}
483
485
484
- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
486
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
485
487
pub struct Static {
486
488
#[ serde( rename = "type" ) ]
487
489
pub type_ : Type ,
0 commit comments