3
3
//! These types are the public API exposed through the `--output-format json` flag. The [`Crate`]
4
4
//! struct is the root of the JSON blob and all other items are contained within.
5
5
6
- #![ warn( missing_docs) ]
7
-
8
6
use rustc_hash:: FxHashMap ;
9
7
use serde:: { Deserialize , Serialize } ;
10
8
use std:: path:: PathBuf ;
11
9
12
10
/// rustdoc format-version.
13
11
pub const FORMAT_VERSION : u32 = 31 ;
14
12
15
- /// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
13
+ /// The root of the emitted JSON blob.
14
+ ///
15
+ /// It contains all type/documentation information
16
16
/// about the language items in the local crate, as well as info about external items to allow
17
17
/// tools to find or link to them.
18
18
#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
@@ -44,7 +44,9 @@ pub struct ExternalCrate {
44
44
pub html_root_url : Option < String > ,
45
45
}
46
46
47
- /// For external (not defined in the local crate) items, you don't get the same level of
47
+ /// Information about an external (not defined in the local crate) [`Item`].
48
+ ///
49
+ /// For external items, you don't get the same level of
48
50
/// information. This struct should contain enough to generate a link/reference to the item in
49
51
/// question, or can be used by a tool that takes the json output of multiple crates to find
50
52
/// the actual item definition with all the relevant info.
@@ -65,8 +67,9 @@ pub struct ItemSummary {
65
67
pub kind : ItemKind ,
66
68
}
67
69
68
- /// An Item represents anything that can hold documentation - modules, structs, enums, functions,
69
- /// traits, type aliases, and more. The `Item` data type holds fields that can apply to any of these,
70
+ /// Anything that can hold documentation - modules, structs, enums, functions, traits, etc.
71
+ ///
72
+ /// The `Item` data type holds fields that can apply to any of these,
70
73
/// and leaves kind-specific details (like function args or enum variants) to the `inner` field.
71
74
#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
72
75
pub struct Item {
@@ -107,7 +110,7 @@ pub struct Span {
107
110
pub end : ( usize , usize ) ,
108
111
}
109
112
110
- /// Information about the deprecation of an API entry .
113
+ /// Information about the deprecation of an [`Item`] .
111
114
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
112
115
pub struct Deprecation {
113
116
/// Usually a version number when this Item first became deprecated.
@@ -116,7 +119,7 @@ pub struct Deprecation {
116
119
pub note : Option < String > ,
117
120
}
118
121
119
- /// Visibility of an API entry .
122
+ /// Visibility of an [`Item`] .
120
123
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
121
124
#[ serde( rename_all = "snake_case" ) ]
122
125
pub enum Visibility {
@@ -162,13 +165,11 @@ pub struct PolyTrait {
162
165
/// ```text
163
166
/// dyn for<'a> Fn() -> &'a i32"
164
167
/// ^^^^^^^
165
- /// |
166
- /// this part
167
168
/// ```
168
169
pub generic_params : Vec < GenericParamDef > ,
169
170
}
170
171
171
- /// A set of generic parameters provided to a path segment, e.g.
172
+ /// A set of generic arguments provided to a path segment, e.g.
172
173
///
173
174
/// ```text
174
175
/// std::option::Option::<u32>::None
@@ -314,21 +315,20 @@ pub enum ItemKind {
314
315
Function ,
315
316
/// A type alias declaration, e.g. `type Pig = std::borrow::Cow<'static, str>;`
316
317
TypeAlias ,
317
- #[ allow( missing_docs) ]
318
318
OpaqueTy ,
319
319
/// The declaration of a constant, e.g. `const GREETING: &str = "Hi :3";`
320
320
Constant ,
321
321
/// A `trait` declaration.
322
322
Trait ,
323
323
/// A trait alias declaration, e.g. `trait Int = Add + Sub + Mul + Div;`
324
- /// See https://github.com/rust-lang/rust/issues/41517
324
+ /// See [the tracking issue]( https://github.com/rust-lang/rust/issues/41517)
325
325
TraitAlias ,
326
326
/// An implementation.
327
327
Impl ,
328
328
/// A declaration of a `static`.
329
329
Static ,
330
330
/// `type`s from an `extern` block.
331
- /// See https://github.com/rust-lang/rust/issues/43467
331
+ /// See [the tracking issue]( https://github.com/rust-lang/rust/issues/43467)
332
332
ForeignType ,
333
333
/// A macro declaration.
334
334
/// Corresponds to either `ItemEnum::Macro(_)`
@@ -385,14 +385,13 @@ pub enum ItemEnum {
385
385
/// A `trait` declaration.
386
386
Trait ( Trait ) ,
387
387
/// A trait alias declaration, e.g. `trait Int = Add + Sub + Mul + Div;`
388
- /// See https://github.com/rust-lang/rust/issues/41517
388
+ /// See [the tracking issue]( https://github.com/rust-lang/rust/issues/41517)
389
389
TraitAlias ( TraitAlias ) ,
390
390
/// An implementation.
391
391
Impl ( Impl ) ,
392
392
393
393
/// A type alias declaration, e.g. `type Pig = std::borrow::Cow<'static, str>;`
394
394
TypeAlias ( TypeAlias ) ,
395
- #[ allow( missing_docs) ]
396
395
OpaqueTy ( OpaqueTy ) ,
397
396
/// The declaration of a constant, e.g. `const GREETING: &str = "Hi :3";`
398
397
Constant {
@@ -408,7 +407,7 @@ pub enum ItemEnum {
408
407
Static ( Static ) ,
409
408
410
409
/// `type`s from an `extern` block.
411
- /// See https://github.com/rust-lang/rust/issues/43467
410
+ /// See [the tracking issue]( https://github.com/rust-lang/rust/issues/43467)
412
411
ForeignType ,
413
412
414
413
/// A macro_rules! declarative macro. Contains a single string with the source
@@ -434,7 +433,7 @@ pub enum ItemEnum {
434
433
} ,
435
434
/// An associated type of a trait or a type.
436
435
AssocType {
437
- /// The generic arguments and where clauses on ahis associated type.
436
+ /// The generic parameters and where clauses on ahis associated type.
438
437
generics : Generics ,
439
438
/// The bounds for this associated type. e.g.
440
439
/// ```rust
@@ -471,7 +470,7 @@ pub struct Module {
471
470
/// A `union`.
472
471
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
473
472
pub struct Union {
474
- /// The generic arguments and where clauses on this union.
473
+ /// The generic parameters and where clauses on this union.
475
474
pub generics : Generics ,
476
475
/// Whether any fields have been removed from the result, due to being private or hidden.
477
476
pub fields_stripped : bool ,
@@ -488,7 +487,7 @@ pub struct Union {
488
487
pub struct Struct {
489
488
/// The kind of struct.
490
489
pub kind : StructKind ,
491
- /// The generic arguments and where clauses on this union .
490
+ /// The generic parameters and where clauses on this struct .
492
491
pub generics : Generics ,
493
492
/// All impls (both of traits and inherent) for this struct.
494
493
/// All of the corresponding [`Item`]s are of kind [`ItemEnum::Impl`].
@@ -531,7 +530,7 @@ pub enum StructKind {
531
530
} ,
532
531
}
533
532
534
- /// An enumeration .
533
+ /// An `enum` .
535
534
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
536
535
pub struct Enum {
537
536
/// Information about the type parameters and `where` clauses of the enum.
@@ -596,7 +595,7 @@ pub enum VariantKind {
596
595
} ,
597
596
}
598
597
599
- /// The value that distinguishes a variant in an enum from other variants.
598
+ /// The value that distinguishes a variant in an [`Enum`] from other variants.
600
599
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
601
600
pub struct Discriminant {
602
601
/// The expression that produced the discriminant.
@@ -631,53 +630,36 @@ pub struct Header {
631
630
pub abi : Abi ,
632
631
}
633
632
634
- /// The calling convention used by a function.
633
+ /// The ABI (Application Binary Interface) used by a function.
634
+ ///
635
+ /// If a variant has an `unwind` field, this means the ABI that it represents can be specified in 2
636
+ /// ways: `extern "_"` and `extern "_-unwind"`, and a value of `true` for that field signifies the
637
+ /// latter variant.
638
+ ///
639
+ /// See the [Rustonomicon section](https://doc.rust-lang.org/nightly/nomicon/ffi.html#ffi-and-unwinding)
640
+ /// on unwinding for more info.
635
641
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
636
642
pub enum Abi {
637
643
// We only have a concrete listing here for stable ABI's because their are so many
638
644
// See rustc_ast_passes::feature_gate::PostExpansionVisitor::check_abi for the list
639
645
/// The default ABI, but that can also be written explicitly with `extern "Rust"`.
640
646
Rust ,
641
647
/// Can be specified as `extern "C"` or, as a shorthand, just `extern`.
642
- C {
643
- /// If this is `true`, the ABI was specified as `extern "C-unwind"`.
644
- unwind : bool ,
645
- } ,
648
+ C { unwind : bool } ,
646
649
/// Can be specified as `extern "cdecl"`.
647
- Cdecl {
648
- /// If this is `true`, the ABI was specified as `extern "cdecl-unwind"`
649
- unwind : bool ,
650
- } ,
650
+ Cdecl { unwind : bool } ,
651
651
/// Can be specified as `extern "stdcall"`.
652
- Stdcall {
653
- /// If this is `true`, the ABI was specified as `extern "stdcall-unwind"`.
654
- unwind : bool ,
655
- } ,
652
+ Stdcall { unwind : bool } ,
656
653
/// Can be specified as `extern "fastcall"`.
657
- Fastcall {
658
- /// If this is `true`, the ABI was specified as `extern "fastcall-unwind"`.
659
- unwind : bool ,
660
- } ,
654
+ Fastcall { unwind : bool } ,
661
655
/// Can be specified as `extern "aapcs"`.
662
- Aapcs {
663
- /// If this is `true`, the ABI was specified as `extern "aapcs-unwind"`.
664
- unwind : bool ,
665
- } ,
656
+ Aapcs { unwind : bool } ,
666
657
/// Can be specified as `extern "win64"`.
667
- Win64 {
668
- /// If this is `true`, the ABI was specified as `extern "win64-unwind"`.
669
- unwind : bool ,
670
- } ,
658
+ Win64 { unwind : bool } ,
671
659
/// Can be specifed as `extern "sysv64"`.
672
- SysV64 {
673
- /// If this is `true`, the ABI was specified as `extern "sysv64-unwind"`.
674
- unwind : bool ,
675
- } ,
660
+ SysV64 { unwind : bool } ,
676
661
/// Can be specified as `extern "system"`.
677
- System {
678
- /// If this is `true`, the ABI was specified as `extern "system-unwind"`.
679
- unwind : bool ,
680
- } ,
662
+ System { unwind : bool } ,
681
663
/// Any other ABI, including unstable ones.
682
664
Other ( String ) ,
683
665
}
@@ -725,7 +707,7 @@ pub struct GenericParamDef {
725
707
pub enum GenericParamDefKind {
726
708
/// Denotes a lifetime parameter.
727
709
Lifetime {
728
- /// Lifetimes that this lifetime parameter is require to outlive.
710
+ /// Lifetimes that this lifetime parameter is required to outlive.
729
711
///
730
712
/// ```rust
731
713
/// fn f<'a, 'b, 'resource: 'a + 'b>(a: &'a str, b: &'b str, res: &'resource str) {}
@@ -934,7 +916,7 @@ pub enum Type {
934
916
len : String ,
935
917
} ,
936
918
/// A pattern type, e.g. `u32 is 1..`
937
- /// See https://github.com/rust-lang/rust/issues/123646
919
+ /// See [the tracking issue]( https://github.com/rust-lang/rust/issues/123646)
938
920
Pat {
939
921
/// The base type, e.g. the `u32` in `u32 is 1..`
940
922
#[ serde( rename = "type" ) ]
@@ -974,7 +956,7 @@ pub enum Type {
974
956
/// // ^^^^
975
957
/// ```
976
958
name : String ,
977
- /// The generic parameters provided to the associated type.
959
+ /// The generic arguments provided to the associated type.
978
960
///
979
961
/// ```ignore (incomplete expression)
980
962
/// <core::slice::IterMut<'static, u32> as BetterIterator>::Item<'static>
@@ -1073,7 +1055,7 @@ pub struct Trait {
1073
1055
}
1074
1056
1075
1057
/// A trait alias declaration, e.g. `trait Int = Add + Sub + Mul + Div;`
1076
- /// See https://github.com/rust-lang/rust/issues/41517
1058
+ /// See [the tracking issue]( https://github.com/rust-lang/rust/issues/41517)
1077
1059
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1078
1060
pub struct TraitAlias {
1079
1061
/// Information about the type parameters and `where` clauses of the alias.
@@ -1082,7 +1064,7 @@ pub struct TraitAlias {
1082
1064
pub params : Vec < GenericBound > ,
1083
1065
}
1084
1066
1085
- /// An implementation .
1067
+ /// An `impl` block .
1086
1068
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1087
1069
pub struct Impl {
1088
1070
/// Whether this impl is for an unsafe trait.
@@ -1172,7 +1154,6 @@ pub struct TypeAlias {
1172
1154
pub generics : Generics ,
1173
1155
}
1174
1156
1175
- #[ allow( missing_docs) ]
1176
1157
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1177
1158
pub struct OpaqueTy {
1178
1159
pub bounds : Vec < GenericBound > ,
0 commit comments