33//! These types are the public API exposed through the `--output-format json` flag. The [`Crate`]
44//! struct is the root of the JSON blob and all other items are contained within.
55
6- #![ warn( missing_docs) ]
7-
86use rustc_hash:: FxHashMap ;
97use serde:: { Deserialize , Serialize } ;
108use std:: path:: PathBuf ;
119
1210/// rustdoc format-version.
1311pub const FORMAT_VERSION : u32 = 32 ;
1412
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
1616/// about the language items in the local crate, as well as info about external items to allow
1717/// tools to find or link to them.
1818#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
@@ -44,7 +44,9 @@ pub struct ExternalCrate {
4444 pub html_root_url : Option < String > ,
4545}
4646
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
4850/// information. This struct should contain enough to generate a link/reference to the item in
4951/// question, or can be used by a tool that takes the json output of multiple crates to find
5052/// the actual item definition with all the relevant info.
@@ -65,8 +67,9 @@ pub struct ItemSummary {
6567 pub kind : ItemKind ,
6668}
6769
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,
7073/// and leaves kind-specific details (like function args or enum variants) to the `inner` field.
7174#[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
7275pub struct Item {
@@ -107,7 +110,7 @@ pub struct Span {
107110 pub end : ( usize , usize ) ,
108111}
109112
110- /// Information about the deprecation of an API entry .
113+ /// Information about the deprecation of an [`Item`] .
111114#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
112115pub struct Deprecation {
113116 /// Usually a version number when this Item first became deprecated.
@@ -116,7 +119,7 @@ pub struct Deprecation {
116119 pub note : Option < String > ,
117120}
118121
119- /// Visibility of an API entry .
122+ /// Visibility of an [`Item`] .
120123#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
121124#[ serde( rename_all = "snake_case" ) ]
122125pub enum Visibility {
@@ -162,13 +165,11 @@ pub struct PolyTrait {
162165 /// ```text
163166 /// dyn for<'a> Fn() -> &'a i32"
164167 /// ^^^^^^^
165- /// |
166- /// this part
167168 /// ```
168169 pub generic_params : Vec < GenericParamDef > ,
169170}
170171
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.
172173///
173174/// ```text
174175/// std::option::Option::<u32>::None
@@ -314,21 +315,20 @@ pub enum ItemKind {
314315 Function ,
315316 /// A type alias declaration, e.g. `type Pig = std::borrow::Cow<'static, str>;`
316317 TypeAlias ,
317- #[ allow( missing_docs) ]
318318 OpaqueTy ,
319319 /// The declaration of a constant, e.g. `const GREETING: &str = "Hi :3";`
320320 Constant ,
321321 /// A `trait` declaration.
322322 Trait ,
323323 /// 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)
325325 TraitAlias ,
326326 /// An implementation.
327327 Impl ,
328328 /// A declaration of a `static`.
329329 Static ,
330330 /// `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)
332332 ForeignType ,
333333 /// A macro declaration.
334334 /// Corresponds to either `ItemEnum::Macro(_)`
@@ -385,14 +385,13 @@ pub enum ItemEnum {
385385 /// A `trait` declaration.
386386 Trait ( Trait ) ,
387387 /// 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)
389389 TraitAlias ( TraitAlias ) ,
390390 /// An implementation.
391391 Impl ( Impl ) ,
392392
393393 /// A type alias declaration, e.g. `type Pig = std::borrow::Cow<'static, str>;`
394394 TypeAlias ( TypeAlias ) ,
395- #[ allow( missing_docs) ]
396395 OpaqueTy ( OpaqueTy ) ,
397396 /// The declaration of a constant, e.g. `const GREETING: &str = "Hi :3";`
398397 Constant {
@@ -408,7 +407,7 @@ pub enum ItemEnum {
408407 Static ( Static ) ,
409408
410409 /// `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)
412411 ForeignType ,
413412
414413 /// A macro_rules! declarative macro. Contains a single string with the source
@@ -434,7 +433,7 @@ pub enum ItemEnum {
434433 } ,
435434 /// An associated type of a trait or a type.
436435 AssocType {
437- /// The generic arguments and where clauses on ahis associated type.
436+ /// The generic parameters and where clauses on ahis associated type.
438437 generics : Generics ,
439438 /// The bounds for this associated type. e.g.
440439 /// ```rust
@@ -471,7 +470,7 @@ pub struct Module {
471470/// A `union`.
472471#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
473472pub struct Union {
474- /// The generic arguments and where clauses on this union.
473+ /// The generic parameters and where clauses on this union.
475474 pub generics : Generics ,
476475 /// Whether any fields have been removed from the result, due to being private or hidden.
477476 pub fields_stripped : bool ,
@@ -488,7 +487,7 @@ pub struct Union {
488487pub struct Struct {
489488 /// The kind of struct.
490489 pub kind : StructKind ,
491- /// The generic arguments and where clauses on this union .
490+ /// The generic parameters and where clauses on this struct .
492491 pub generics : Generics ,
493492 /// All impls (both of traits and inherent) for this struct.
494493 /// All of the corresponding [`Item`]s are of kind [`ItemEnum::Impl`].
@@ -531,7 +530,7 @@ pub enum StructKind {
531530 } ,
532531}
533532
534- /// An enumeration .
533+ /// An `enum` .
535534#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
536535pub struct Enum {
537536 /// Information about the type parameters and `where` clauses of the enum.
@@ -596,7 +595,7 @@ pub enum VariantKind {
596595 } ,
597596}
598597
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.
600599#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
601600pub struct Discriminant {
602601 /// The expression that produced the discriminant.
@@ -631,53 +630,36 @@ pub struct Header {
631630 pub abi : Abi ,
632631}
633632
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.
635641#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
636642pub enum Abi {
637643 // We only have a concrete listing here for stable ABI's because their are so many
638644 // See rustc_ast_passes::feature_gate::PostExpansionVisitor::check_abi for the list
639645 /// The default ABI, but that can also be written explicitly with `extern "Rust"`.
640646 Rust ,
641647 /// 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 } ,
646649 /// 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 } ,
651651 /// 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 } ,
656653 /// 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 } ,
661655 /// 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 } ,
666657 /// 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 } ,
671659 /// 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 } ,
676661 /// 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 } ,
681663 /// Any other ABI, including unstable ones.
682664 Other ( String ) ,
683665}
@@ -725,7 +707,7 @@ pub struct GenericParamDef {
725707pub enum GenericParamDefKind {
726708 /// Denotes a lifetime parameter.
727709 Lifetime {
728- /// Lifetimes that this lifetime parameter is require to outlive.
710+ /// Lifetimes that this lifetime parameter is required to outlive.
729711 ///
730712 /// ```rust
731713 /// fn f<'a, 'b, 'resource: 'a + 'b>(a: &'a str, b: &'b str, res: &'resource str) {}
@@ -936,7 +918,7 @@ pub enum Type {
936918 len : String ,
937919 } ,
938920 /// A pattern type, e.g. `u32 is 1..`
939- /// See https://github.com/rust-lang/rust/issues/123646
921+ /// See [the tracking issue]( https://github.com/rust-lang/rust/issues/123646)
940922 Pat {
941923 /// The base type, e.g. the `u32` in `u32 is 1..`
942924 #[ serde( rename = "type" ) ]
@@ -976,7 +958,7 @@ pub enum Type {
976958 /// // ^^^^
977959 /// ```
978960 name : String ,
979- /// The generic parameters provided to the associated type.
961+ /// The generic arguments provided to the associated type.
980962 ///
981963 /// ```ignore (incomplete expression)
982964 /// <core::slice::IterMut<'static, u32> as BetterIterator>::Item<'static>
@@ -1075,7 +1057,7 @@ pub struct Trait {
10751057}
10761058
10771059/// A trait alias declaration, e.g. `trait Int = Add + Sub + Mul + Div;`
1078- /// See https://github.com/rust-lang/rust/issues/41517
1060+ /// See [the tracking issue]( https://github.com/rust-lang/rust/issues/41517)
10791061#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
10801062pub struct TraitAlias {
10811063 /// Information about the type parameters and `where` clauses of the alias.
@@ -1084,7 +1066,7 @@ pub struct TraitAlias {
10841066 pub params : Vec < GenericBound > ,
10851067}
10861068
1087- /// An implementation .
1069+ /// An `impl` block .
10881070#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
10891071pub struct Impl {
10901072 /// Whether this impl is for an unsafe trait.
@@ -1174,7 +1156,6 @@ pub struct TypeAlias {
11741156 pub generics : Generics ,
11751157}
11761158
1177- #[ allow( missing_docs) ]
11781159#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
11791160pub struct OpaqueTy {
11801161 pub bounds : Vec < GenericBound > ,
0 commit comments