Skip to content

Commit 033584d

Browse files
committed
0.2
1 parent 9381be3 commit 033584d

File tree

5 files changed

+49
-59
lines changed

5 files changed

+49
-59
lines changed

CHANGELOG.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

COMMIT.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2ceee724270f2186e5e85acff49acd35bf8a652a

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustdoc-types"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = ["Nixon Enraght-Moony <[email protected]>", "The Rust Project Developers"]
55
edition = "2018"
66
license = "MIT OR Apache-2.0"

src/lib.rs

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
1111
/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
1212
/// about the language items in the local crate, as well as info about external items to allow
1313
/// tools to find or link to them.
14-
#[derive(Clone, Debug, Serialize, Deserialize)]
14+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
1515
pub struct Crate {
1616
/// The id of the root [`Module`] item of the local crate.
1717
pub root: Id,
@@ -31,7 +31,7 @@ pub struct Crate {
3131
pub format_version: u32,
3232
}
3333

34-
#[derive(Clone, Debug, Serialize, Deserialize)]
34+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
3535
pub struct ExternalCrate {
3636
pub name: String,
3737
pub html_root_url: Option<String>,
@@ -41,7 +41,7 @@ pub struct ExternalCrate {
4141
/// information. This struct should contain enough to generate a link/reference to the item in
4242
/// question, or can be used by a tool that takes the json output of multiple crates to find
4343
/// the actual item definition with all the relevant info.
44-
#[derive(Clone, Debug, Serialize, Deserialize)]
44+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
4545
pub struct ItemSummary {
4646
/// Can be used to look up the name and html_root_url of the crate this item came from in the
4747
/// `external_crates` map.
@@ -53,7 +53,7 @@ pub struct ItemSummary {
5353
pub kind: ItemKind,
5454
}
5555

56-
#[derive(Clone, Debug, Serialize, Deserialize)]
56+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
5757
pub struct Item {
5858
/// The unique identifier of this item. Can be used to find this item in various mappings.
5959
pub id: Id,
@@ -68,8 +68,9 @@ pub struct Item {
6868
/// By default all documented items are public, but you can tell rustdoc to output private items
6969
/// so this field is needed to differentiate.
7070
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>,
7374
/// 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
7475
pub links: HashMap<String, Id>,
7576
/// Stringified versions of the attributes on this item (e.g. `"#[inline]"`)
@@ -79,7 +80,7 @@ pub struct Item {
7980
pub inner: ItemEnum,
8081
}
8182

82-
#[derive(Clone, Debug, Serialize, Deserialize)]
83+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
8384
pub struct Span {
8485
/// The path to the source file for this span relative to the path `rustdoc` was invoked with.
8586
pub filename: PathBuf,
@@ -89,14 +90,14 @@ pub struct Span {
8990
pub end: (usize, usize),
9091
}
9192

92-
#[derive(Clone, Debug, Serialize, Deserialize)]
93+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
9394
pub struct Deprecation {
9495
pub since: Option<String>,
9596
pub note: Option<String>,
9697
}
9798

9899
#[serde(rename_all = "snake_case")]
99-
#[derive(Clone, Debug, Serialize, Deserialize)]
100+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
100101
pub enum Visibility {
101102
Public,
102103
/// For the most part items are private by default. The exceptions are associated items of
@@ -112,7 +113,7 @@ pub enum Visibility {
112113
}
113114

114115
#[serde(rename_all = "snake_case")]
115-
#[derive(Clone, Debug, Serialize, Deserialize)]
116+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
116117
pub enum GenericArgs {
117118
/// <'a, 32, B: Copy, C = u32>
118119
AngleBracketed { args: Vec<GenericArg>, bindings: Vec<TypeBinding> },
@@ -121,14 +122,14 @@ pub enum GenericArgs {
121122
}
122123

123124
#[serde(rename_all = "snake_case")]
124-
#[derive(Clone, Debug, Serialize, Deserialize)]
125+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
125126
pub enum GenericArg {
126127
Lifetime(String),
127128
Type(Type),
128129
Const(Constant),
129130
}
130131

131-
#[derive(Clone, Debug, Serialize, Deserialize)]
132+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
132133
pub struct Constant {
133134
#[serde(rename = "type")]
134135
pub type_: Type,
@@ -137,14 +138,14 @@ pub struct Constant {
137138
pub is_literal: bool,
138139
}
139140

140-
#[derive(Clone, Debug, Serialize, Deserialize)]
141+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
141142
pub struct TypeBinding {
142143
pub name: String,
143144
pub binding: TypeBindingKind,
144145
}
145146

146147
#[serde(rename_all = "snake_case")]
147-
#[derive(Clone, Debug, Serialize, Deserialize)]
148+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
148149
pub enum TypeBindingKind {
149150
Equality(Type),
150151
Constraint(Vec<GenericBound>),
@@ -154,7 +155,7 @@ pub enum TypeBindingKind {
154155
pub struct Id(pub String);
155156

156157
#[serde(rename_all = "snake_case")]
157-
#[derive(Clone, Debug, Serialize, Deserialize)]
158+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
158159
pub enum ItemKind {
159160
Module,
160161
ExternCrate,
@@ -184,7 +185,7 @@ pub enum ItemKind {
184185
}
185186

186187
#[serde(untagged)]
187-
#[derive(Clone, Debug, Serialize, Deserialize)]
188+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
188189
pub enum ItemEnum {
189190
ModuleItem(Module),
190191
ExternCrateItem {
@@ -231,13 +232,13 @@ pub enum ItemEnum {
231232
},
232233
}
233234

234-
#[derive(Clone, Debug, Serialize, Deserialize)]
235+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
235236
pub struct Module {
236237
pub is_crate: bool,
237238
pub items: Vec<Id>,
238239
}
239240

240-
#[derive(Clone, Debug, Serialize, Deserialize)]
241+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
241242
pub struct Struct {
242243
pub struct_type: StructType,
243244
pub generics: Generics,
@@ -246,7 +247,7 @@ pub struct Struct {
246247
pub impls: Vec<Id>,
247248
}
248249

249-
#[derive(Clone, Debug, Serialize, Deserialize)]
250+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
250251
pub struct Enum {
251252
pub generics: Generics,
252253
pub variants_stripped: bool,
@@ -256,67 +257,68 @@ pub struct Enum {
256257

257258
#[serde(rename_all = "snake_case")]
258259
#[serde(tag = "variant_kind", content = "variant_inner")]
259-
#[derive(Clone, Debug, Serialize, Deserialize)]
260+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
260261
pub enum Variant {
261262
Plain,
262263
Tuple(Vec<Type>),
263264
Struct(Vec<Id>),
264265
}
265266

266267
#[serde(rename_all = "snake_case")]
267-
#[derive(Clone, Debug, Serialize, Deserialize)]
268+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
268269
pub enum StructType {
269270
Plain,
270271
Tuple,
271272
Unit,
273+
Union,
272274
}
273275

274-
#[derive(Clone, Debug, Serialize, Deserialize)]
276+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
275277
pub struct Function {
276278
pub decl: FnDecl,
277279
pub generics: Generics,
278280
pub header: String,
279281
pub abi: String,
280282
}
281283

282-
#[derive(Clone, Debug, Serialize, Deserialize)]
284+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
283285
pub struct Method {
284286
pub decl: FnDecl,
285287
pub generics: Generics,
286288
pub header: String,
287289
pub has_body: bool,
288290
}
289291

290-
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
292+
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)]
291293
pub struct Generics {
292294
pub params: Vec<GenericParamDef>,
293295
pub where_predicates: Vec<WherePredicate>,
294296
}
295297

296-
#[derive(Clone, Debug, Serialize, Deserialize)]
298+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
297299
pub struct GenericParamDef {
298300
pub name: String,
299301
pub kind: GenericParamDefKind,
300302
}
301303

302304
#[serde(rename_all = "snake_case")]
303-
#[derive(Clone, Debug, Serialize, Deserialize)]
305+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
304306
pub enum GenericParamDefKind {
305307
Lifetime,
306308
Type { bounds: Vec<GenericBound>, default: Option<Type> },
307309
Const(Type),
308310
}
309311

310312
#[serde(rename_all = "snake_case")]
311-
#[derive(Clone, Debug, Serialize, Deserialize)]
313+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
312314
pub enum WherePredicate {
313315
BoundPredicate { ty: Type, bounds: Vec<GenericBound> },
314316
RegionPredicate { lifetime: String, bounds: Vec<GenericBound> },
315317
EqPredicate { lhs: Type, rhs: Type },
316318
}
317319

318320
#[serde(rename_all = "snake_case")]
319-
#[derive(Clone, Debug, Serialize, Deserialize)]
321+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
320322
pub enum GenericBound {
321323
TraitBound {
322324
#[serde(rename = "trait")]
@@ -329,7 +331,7 @@ pub enum GenericBound {
329331
}
330332

331333
#[serde(rename_all = "snake_case")]
332-
#[derive(Clone, Debug, Serialize, Deserialize)]
334+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
333335
pub enum TraitBoundModifier {
334336
None,
335337
Maybe,
@@ -338,7 +340,7 @@ pub enum TraitBoundModifier {
338340

339341
#[serde(rename_all = "snake_case")]
340342
#[serde(tag = "kind", content = "inner")]
341-
#[derive(Clone, Debug, Serialize, Deserialize)]
343+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
342344
pub enum Type {
343345
/// Structs, enums, and traits
344346
ResolvedPath {
@@ -391,22 +393,22 @@ pub enum Type {
391393
},
392394
}
393395

394-
#[derive(Clone, Debug, Serialize, Deserialize)]
396+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
395397
pub struct FunctionPointer {
396398
pub is_unsafe: bool,
397399
pub generic_params: Vec<GenericParamDef>,
398400
pub decl: FnDecl,
399401
pub abi: String,
400402
}
401403

402-
#[derive(Clone, Debug, Serialize, Deserialize)]
404+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
403405
pub struct FnDecl {
404406
pub inputs: Vec<(String, Type)>,
405407
pub output: Option<Type>,
406408
pub c_variadic: bool,
407409
}
408410

409-
#[derive(Clone, Debug, Serialize, Deserialize)]
411+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
410412
pub struct Trait {
411413
pub is_auto: bool,
412414
pub is_unsafe: bool,
@@ -416,13 +418,13 @@ pub struct Trait {
416418
pub implementors: Vec<Id>,
417419
}
418420

419-
#[derive(Clone, Debug, Serialize, Deserialize)]
421+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
420422
pub struct TraitAlias {
421423
pub generics: Generics,
422424
pub params: Vec<GenericBound>,
423425
}
424426

425-
#[derive(Clone, Debug, Serialize, Deserialize)]
427+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
426428
pub struct Impl {
427429
pub is_unsafe: bool,
428430
pub generics: Generics,
@@ -438,7 +440,7 @@ pub struct Impl {
438440
}
439441

440442
#[serde(rename_all = "snake_case")]
441-
#[derive(Clone, Debug, Serialize, Deserialize)]
443+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
442444
pub struct Import {
443445
/// The full path being imported.
444446
pub span: String,
@@ -451,14 +453,14 @@ pub struct Import {
451453
pub glob: bool,
452454
}
453455

454-
#[derive(Clone, Debug, Serialize, Deserialize)]
456+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
455457
pub struct ProcMacro {
456458
pub kind: MacroKind,
457459
pub helpers: Vec<String>,
458460
}
459461

460462
#[serde(rename_all = "snake_case")]
461-
#[derive(Clone, Debug, Serialize, Deserialize)]
463+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
462464
pub enum MacroKind {
463465
/// A bang macro `foo!()`.
464466
Bang,
@@ -468,20 +470,20 @@ pub enum MacroKind {
468470
Derive,
469471
}
470472

471-
#[derive(Clone, Debug, Serialize, Deserialize)]
473+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
472474
pub struct Typedef {
473475
#[serde(rename = "type")]
474476
pub type_: Type,
475477
pub generics: Generics,
476478
}
477479

478-
#[derive(Clone, Debug, Serialize, Deserialize)]
480+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
479481
pub struct OpaqueTy {
480482
pub bounds: Vec<GenericBound>,
481483
pub generics: Generics,
482484
}
483485

484-
#[derive(Clone, Debug, Serialize, Deserialize)]
486+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
485487
pub struct Static {
486488
#[serde(rename = "type")]
487489
pub type_: Type,

update.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#!/bin/sh
22

3-
curl https://raw.githubusercontent.com/rust-lang/rust/master/src/librustdoc/json/types.rs | sed 's/rustc_data_structures::fx::/std::collections::/g' | sed 's/FxHashMap/HashMap/g' > src/lib.rs
3+
curl -# https://raw.githubusercontent.com/rust-lang/rust/master/src/librustdoc/json/types.rs | sed 's/rustc_data_structures::fx::/std::collections::/g' | sed 's/FxHashMap/HashMap/g' > src/lib.rs
4+
5+
6+
curl -# "https://api.github.com/repos/rust-lang/rust/commits?path=src/librustdoc/json/types.rs" | jq -r ".[0].sha" > COMMIT.txt

0 commit comments

Comments
 (0)