@@ -97,9 +97,9 @@ pub struct Item {
97
97
pub links : FxHashMap < String , Id > ,
98
98
/// Stringified versions of the attributes on this item (e.g. `"#[inline]"`)
99
99
pub attrs : Vec < String > ,
100
- /// Information about the Item ’s deprecation, if present.
100
+ /// Information about the item ’s deprecation, if present.
101
101
pub deprecation : Option < Deprecation > ,
102
- /// The type-specific fields describing this Item .
102
+ /// The type-specific fields describing this item .
103
103
pub inner : ItemEnum ,
104
104
}
105
105
@@ -117,7 +117,7 @@ pub struct Span {
117
117
/// Information about the deprecation of an [`Item`].
118
118
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
119
119
pub struct Deprecation {
120
- /// Usually a version number when this Item first became deprecated.
120
+ /// Usually a version number when this [` Item`] first became deprecated.
121
121
pub since : Option < String > ,
122
122
/// The reason for deprecation and/or what alternatives to use.
123
123
pub note : Option < String > ,
@@ -138,8 +138,10 @@ pub enum Visibility {
138
138
Restricted {
139
139
/// ID of the module to which this visibility restricts items.
140
140
parent : Id ,
141
- /// The path with which `parent` was referenced
142
- /// (like `"super::super"` or `"crate::foo::bar"`).
141
+ /// The path with which [`parent`] was referenced
142
+ /// (like `super::super` or `crate::foo::bar`).
143
+ ///
144
+ /// [`parent`]: Visibility::Restricted::parent
143
145
path : String ,
144
146
} ,
145
147
}
@@ -203,7 +205,8 @@ pub enum GenericArgs {
203
205
}
204
206
205
207
/// One argument in a list of generic arguments to a path segment.
206
- /// See [`GenericArgs`].
208
+ ///
209
+ /// Part of [`GenericArgs`].
207
210
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
208
211
#[ serde( rename_all = "snake_case" ) ]
209
212
pub enum GenericArg {
@@ -264,7 +267,6 @@ pub struct TypeBinding {
264
267
}
265
268
266
269
/// The way in which an associate type/constant is bound.
267
- /// See [`TypeBinding`].
268
270
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
269
271
#[ serde( rename_all = "snake_case" ) ]
270
272
pub enum TypeBindingKind {
@@ -299,7 +301,7 @@ pub struct Id(pub String);
299
301
300
302
/// The fundamental kind of an item. Unlike [`ItemEnum`], this does not carry any aditional info.
301
303
///
302
- /// See [`ItemSummary`].
304
+ /// Part of [`ItemSummary`].
303
305
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
304
306
#[ serde( rename_all = "snake_case" ) ]
305
307
pub enum ItemKind {
@@ -317,7 +319,7 @@ pub enum ItemKind {
317
319
Union ,
318
320
/// An `enum` declaration.
319
321
Enum ,
320
- /// A variant of a struct .
322
+ /// A variant of a enum .
321
323
Variant ,
322
324
/// A function declaration, e.g. `fn f() {}`
323
325
Function ,
@@ -329,39 +331,48 @@ pub enum ItemKind {
329
331
/// A `trait` declaration.
330
332
Trait ,
331
333
/// A trait alias declaration, e.g. `trait Int = Add + Sub + Mul + Div;`
334
+ ///
332
335
/// See [the tracking issue](https://github.com/rust-lang/rust/issues/41517)
333
336
TraitAlias ,
334
- /// An implementation .
337
+ /// An `impl` block .
335
338
Impl ,
336
- /// A declaration of a `static`.
339
+ /// A `static` declaration .
337
340
Static ,
338
341
/// `type`s from an `extern` block.
342
+ ///
339
343
/// See [the tracking issue](https://github.com/rust-lang/rust/issues/43467)
340
344
ForeignType ,
341
345
/// A macro declaration.
346
+ ///
342
347
/// Corresponds to either `ItemEnum::Macro(_)`
343
348
/// or `ItemEnum::ProcMacro(ProcMacro { kind: MacroKind::Bang })`
344
349
Macro ,
345
350
/// A procedural macro attribute.
351
+ ///
346
352
/// Corresponds to `ItemEnum::ProcMacro(ProcMacro { kind: MacroKind::Attr })`
347
353
ProcAttribute ,
348
354
/// A procedural macro usable in the `#[derive()]` attribute.
355
+ ///
349
356
/// Corresponds to `ItemEnum::ProcMacro(ProcMacro { kind: MacroKind::Derive })`
350
357
ProcDerive ,
351
358
/// An associated constant of a trait or a type.
352
359
AssocConst ,
353
360
/// An associated type of a trait or a type.
354
361
AssocType ,
355
- /// A primitive type, e.g. `u32`. Items of this kind only come from the core library.
362
+ /// A primitive type, e.g. `u32`.
363
+ ///
364
+ /// [`Item`]s of this kind only come from the core library.
356
365
Primitive ,
357
- /// A keyword declaration. Items of this kind only come from the come library and exist solely
366
+ /// A keyword declaration.
367
+ ///
368
+ /// [`Item`]s of this kind only come from the come library and exist solely
358
369
/// to carry documentation for the respective keywords.
359
370
Keyword ,
360
371
}
361
372
362
373
/// Specific fields of an item.
363
374
///
364
- /// See [`Item`].
375
+ /// Part of [`Item`].
365
376
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
366
377
#[ serde( rename_all = "snake_case" ) ]
367
378
pub enum ItemEnum {
@@ -371,7 +382,7 @@ pub enum ItemEnum {
371
382
ExternCrate {
372
383
/// The name of the imported crate.
373
384
name : String ,
374
- /// If the crate is renamed, this is its name in the namespace .
385
+ /// If the crate is renamed, this is its name in the crate .
375
386
rename : Option < String > ,
376
387
} ,
377
388
/// An import of 1 or more items into scope, using the `use` keyword.
@@ -385,7 +396,7 @@ pub enum ItemEnum {
385
396
StructField ( Type ) ,
386
397
/// An `enum` declaration.
387
398
Enum ( Enum ) ,
388
- /// A variant of a struct .
399
+ /// A variant of a enum .
389
400
Variant ( Variant ) ,
390
401
391
402
/// A function declaration (including methods and other associated functions)
@@ -394,9 +405,10 @@ pub enum ItemEnum {
394
405
/// A `trait` declaration.
395
406
Trait ( Trait ) ,
396
407
/// A trait alias declaration, e.g. `trait Int = Add + Sub + Mul + Div;`
408
+ ///
397
409
/// See [the tracking issue](https://github.com/rust-lang/rust/issues/41517)
398
410
TraitAlias ( TraitAlias ) ,
399
- /// An implementation .
411
+ /// An `impl` block .
400
412
Impl ( Impl ) ,
401
413
402
414
/// A type alias declaration, e.g. `type Pig = std::borrow::Cow<'static, str>;`
@@ -416,6 +428,7 @@ pub enum ItemEnum {
416
428
Static ( Static ) ,
417
429
418
430
/// `type`s from an `extern` block.
431
+ ///
419
432
/// See [the tracking issue](https://github.com/rust-lang/rust/issues/43467)
420
433
ForeignType ,
421
434
@@ -425,7 +438,9 @@ pub enum ItemEnum {
425
438
/// A procedural macro.
426
439
ProcMacro ( ProcMacro ) ,
427
440
428
- /// A primitive type, e.g. `u32`. Items of this kind only come from the core library.
441
+ /// A primitive type, e.g. `u32`.
442
+ ///
443
+ /// [`Item`]s of this kind only come from the core library.
429
444
Primitive ( Primitive ) ,
430
445
431
446
/// An associated constant of a trait or a type.
@@ -466,10 +481,11 @@ pub enum ItemEnum {
466
481
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
467
482
pub struct Module {
468
483
/// Whether this is the root item of a crate.
484
+ ///
469
485
/// This item doesn't correspond to any construction in the source code and is generated by the
470
486
/// compiler.
471
487
pub is_crate : bool ,
472
- /// Items declared inside this crate .
488
+ /// [`Item`]s declared inside this module .
473
489
pub items : Vec < Id > ,
474
490
/// If `true`, this module is not part of the public API, but it contains
475
491
/// items that are re-exported as public API.
@@ -484,17 +500,20 @@ pub struct Union {
484
500
/// Whether any fields have been removed from the result, due to being private or hidden.
485
501
pub fields_stripped : bool ,
486
502
/// The list of fields in the union.
503
+ ///
487
504
/// All of the corresponding [`Item`]s are of kind [`ItemEnum::StructField`].
488
505
pub fields : Vec < Id > ,
489
506
/// All impls (both of traits and inherent) for this union.
507
+ ///
490
508
/// All of the corresponding [`Item`]s are of kind [`ItemEnum::Impl`].
491
509
pub impls : Vec < Id > ,
492
510
}
493
511
494
- /// A structure .
512
+ /// A `struct` .
495
513
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
496
514
pub struct Struct {
497
- /// The kind of struct.
515
+ /// The kind of the struct (e.g. unit, tuple-like or struct-like) and the data specific to it,
516
+ /// i.e. fields.
498
517
pub kind : StructKind ,
499
518
/// The generic parameters and where clauses on this struct.
500
519
pub generics : Generics ,
@@ -503,7 +522,7 @@ pub struct Struct {
503
522
pub impls : Vec < Id > ,
504
523
}
505
524
506
- /// The kind of a struct and the data specific to it, e.g . fields.
525
+ /// The kind of a [`Struct`] and the data specific to it, i.e . fields.
507
526
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
508
527
#[ serde( rename_all = "snake_case" ) ]
509
528
pub enum StructKind {
@@ -532,6 +551,7 @@ pub enum StructKind {
532
551
/// ```
533
552
Plain {
534
553
/// The list of fields in the struct.
554
+ ///
535
555
/// All of the corresponding [`Item`]s are of kind [`ItemEnum::StructField`].
536
556
fields : Vec < Id > ,
537
557
/// Whether any fields have been removed from the result, due to being private or hidden.
@@ -546,9 +566,11 @@ pub struct Enum {
546
566
pub generics : Generics ,
547
567
/// Whether any variants have been removed from the result, due to being private or hidden.
548
568
pub variants_stripped : bool ,
549
- /// List of the IDs of the variants.
569
+ /// The list of variants in the enum.
570
+ ///
571
+ /// All of the corresponding [`Item`]s are of kind [`ItemEnum::Variant`]
550
572
pub variants : Vec < Id > ,
551
- /// Implementations for the enum.
573
+ /// `impl`s for the enum.
552
574
pub impls : Vec < Id > ,
553
575
}
554
576
@@ -561,7 +583,7 @@ pub struct Variant {
561
583
pub discriminant : Option < Discriminant > ,
562
584
}
563
585
564
- /// The kind of an enum variant and the data specific to it, e.g . fields.
586
+ /// The kind of an [`Enum`] [`Variant`] and the data specific to it, i.e . fields.
565
587
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
566
588
#[ serde( rename_all = "snake_case" ) ]
567
589
pub enum VariantKind {
@@ -623,10 +645,9 @@ pub struct Discriminant {
623
645
}
624
646
625
647
/// A set of fundamental properties of a function.
626
- /// See [`FnDecl`]
627
648
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
628
649
pub struct Header {
629
- /// Can this function be called at compile-time ?
650
+ /// Is this function marked as `const` ?
630
651
#[ serde( rename = "const" ) ]
631
652
pub const_ : bool ,
632
653
/// Is this function unsafe?
@@ -709,8 +730,7 @@ pub struct GenericParamDef {
709
730
pub kind : GenericParamDefKind ,
710
731
}
711
732
712
- /// The kind of a generic parameter.
713
- /// See [`GenericParamDef`].
733
+ /// The kind of a [`GenericParamDef`].
714
734
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
715
735
#[ serde( rename_all = "snake_case" ) ]
716
736
pub enum GenericParamDefKind {
@@ -909,7 +929,7 @@ pub enum Type {
909
929
DynTrait ( DynTrait ) ,
910
930
/// Parameterized types. The contained string is the name of the parameter.
911
931
Generic ( String ) ,
912
- /// Built-in types, such as the integers, floating-point numbers, `bool`, and `char`.
932
+ /// Built-in types, such as the integers, floating-point numbers, `bool`, `char`.
913
933
Primitive ( String ) ,
914
934
/// A function pointer type, e.g. `fn(u32) -> u32`, `extern "C" fn() -> *const u8`
915
935
FunctionPointer ( Box < FunctionPointer > ) ,
@@ -927,6 +947,7 @@ pub enum Type {
927
947
len : String ,
928
948
} ,
929
949
/// A pattern type, e.g. `u32 is 1..`
950
+ ///
930
951
/// See [the tracking issue](https://github.com/rust-lang/rust/issues/123646)
931
952
Pat {
932
953
/// The base type, e.g. the `u32` in `u32 is 1..`
@@ -951,9 +972,9 @@ pub enum Type {
951
972
BorrowedRef {
952
973
/// The name of the lifetime of the reference, if provided.
953
974
lifetime : Option < String > ,
954
- /// This is `true` for `&mut _ ` and `false` for `&_ `
975
+ /// This is `true` for `&mut i32 ` and `false` for `&i32 `
955
976
mutable : bool ,
956
- /// The type of the pointee.
977
+ /// The type of the pointee, e.g. the `i32` in `&'a mut i32`
957
978
#[ serde( rename = "type" ) ]
958
979
type_ : Box < Type > ,
959
980
} ,
@@ -1054,7 +1075,7 @@ pub struct Trait {
1054
1075
pub is_unsafe : bool ,
1055
1076
/// Whether the trait is [object safe](https://doc.rust-lang.org/reference/items/traits.html#object-safety).
1056
1077
pub is_object_safe : bool ,
1057
- /// Items that can/must be implemented by the implementations .
1078
+ /// Associated [`Item`]s that can/must be implemented by the `impl` blocks .
1058
1079
pub items : Vec < Id > ,
1059
1080
/// Information about the type parameters and `where` clauses of the trait.
1060
1081
pub generics : Generics ,
@@ -1065,6 +1086,7 @@ pub struct Trait {
1065
1086
}
1066
1087
1067
1088
/// A trait alias declaration, e.g. `trait Int = Add + Sub + Mul + Div;`
1089
+ ///
1068
1090
/// See [the tracking issue](https://github.com/rust-lang/rust/issues/41517)
1069
1091
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1070
1092
pub struct TraitAlias {
@@ -1108,12 +1130,17 @@ pub struct Impl {
1108
1130
/// Whether this is an impl that’s implied by the compiler
1109
1131
/// (for autotraits, e.g. `Send` or `Sync`).
1110
1132
pub synthetic : bool ,
1111
- /// The name of the generic parameter used for the blanket impl, if this impl was produced by
1112
- /// one. For example, for `impl<T, U> Into<U> for T` this field would be `"T"`.
1133
+ /// If this is a blanket impl, the name with which [`for_`] is referred to in the original impl.
1134
+ ///
1135
+ /// E.g., for `impl<T, U> Into<U> for T` this field would be `T`.
1136
+ ///
1137
+ /// The contained [`Type`], if present, is always of kind [`Type::Generic`]
1138
+ ///
1139
+ /// [`for_`]: Impl::for_
1113
1140
pub blanket_impl : Option < Type > ,
1114
1141
}
1115
1142
1116
- /// An import of an item into scope .
1143
+ /// A `use` statement .
1117
1144
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1118
1145
#[ serde( rename_all = "snake_case" ) ]
1119
1146
pub struct Import {
@@ -1127,7 +1154,7 @@ pub struct Import {
1127
1154
/// pub use i32 as my_i32;
1128
1155
/// ```
1129
1156
pub id : Option < Id > ,
1130
- /// Whether this import uses a glob: `use source::*;`
1157
+ /// Whether this statement is a wildcard `use`, e.g. `use source::*;`
1131
1158
pub glob : bool ,
1132
1159
}
1133
1160
@@ -1136,13 +1163,25 @@ pub struct Import {
1136
1163
pub struct ProcMacro {
1137
1164
/// How this macro is supposed to be called: `foo!()`, `#[foo]` or `#[derive(foo)]`
1138
1165
pub kind : MacroKind ,
1139
- /// Helped attributes defined by a macro to be used inside it. Defined only be attribute &
1140
- /// derive macros.
1166
+ /// Helper attributes defined by a macro to be used inside it.
1167
+ ///
1168
+ /// Defined only for attribute & derive macros.
1169
+ ///
1170
+ /// E.g. the [`Default`] derive macro defines a `#[default]` helper attribute so that one can
1171
+ /// do:
1172
+ ///
1173
+ /// ```rust
1174
+ /// #[derive(Default)]
1175
+ /// enum Option<T> {
1176
+ /// #[default]
1177
+ /// None,
1178
+ /// Some(T),
1179
+ /// }
1180
+ /// ```
1141
1181
pub helpers : Vec < String > ,
1142
1182
}
1143
1183
1144
- /// The way a procedural macro is declared to be used.
1145
- /// See [`ProcMacro`]
1184
+ /// The way a [`ProcMacro`] is declared to be used.
1146
1185
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1147
1186
#[ serde( rename_all = "snake_case" ) ]
1148
1187
pub enum MacroKind {
@@ -1170,23 +1209,24 @@ pub struct OpaqueTy {
1170
1209
pub generics : Generics ,
1171
1210
}
1172
1211
1173
- /// A global variable declaration.
1212
+ /// A `static` declaration.
1174
1213
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1175
1214
pub struct Static {
1176
1215
/// The type of the static.
1177
1216
#[ serde( rename = "type" ) ]
1178
1217
pub type_ : Type ,
1179
1218
/// This is `true` for mutable statics, declared as `static mut X: T = f();`
1180
1219
pub mutable : bool ,
1181
- /// The stringified expression for the initial value. It's not guaranteed that
1182
- /// it'll match the actual source code for the initial value.
1220
+ /// The stringified expression for the initial value.
1221
+ ///
1222
+ /// It's not guaranteed that it'll match the actual source code for the initial value.
1183
1223
pub expr : String ,
1184
1224
}
1185
1225
1186
1226
/// A primitive type declaration. Declarations of this kind can only come from the core library.
1187
1227
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1188
1228
pub struct Primitive {
1189
- /// The name of the library .
1229
+ /// The name of the type .
1190
1230
pub name : String ,
1191
1231
/// The implementations, inherent and of traits, on the primitive type.
1192
1232
pub impls : Vec < Id > ,
0 commit comments