@@ -29,7 +29,7 @@ use serde::{Deserialize, Serialize};
29
29
/// This integer is incremented with every breaking change to the API,
30
30
/// and is returned along with the JSON blob as [`Crate::format_version`].
31
31
/// Consuming code should assert that this value matches the format version(s) that it supports.
32
- pub const FORMAT_VERSION : u32 = 43 ;
32
+ pub const FORMAT_VERSION : u32 = 44 ;
33
33
34
34
/// The root of the emitted JSON blob.
35
35
///
@@ -51,11 +51,67 @@ pub struct Crate {
51
51
pub paths : HashMap < Id , ItemSummary > ,
52
52
/// Maps `crate_id` of items to a crate name and html_root_url if it exists.
53
53
pub external_crates : HashMap < u32 , ExternalCrate > ,
54
+ /// Information about the target for which this documentation was generated
55
+ pub target : Target ,
54
56
/// A single version number to be used in the future when making backwards incompatible changes
55
57
/// to the JSON output.
56
58
pub format_version : u32 ,
57
59
}
58
60
61
+ /// Information about a target
62
+ #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
63
+ pub struct Target {
64
+ /// The target triple for which this documentation was generated
65
+ pub triple : String ,
66
+ /// A list of features valid for use in `#[target_feature]` attributes
67
+ /// for the target where this rustdoc JSON was generated.
68
+ pub target_features : Vec < TargetFeature > ,
69
+ }
70
+
71
+ /// Information about a target feature.
72
+ ///
73
+ /// Rust target features are used to influence code generation, especially around selecting
74
+ /// instructions which are not universally supported by the target architecture.
75
+ ///
76
+ /// Target features are commonly enabled by the [`#[target_feature]` attribute][1] to influence code
77
+ /// generation for a particular function, and less commonly enabled by compiler options like
78
+ /// `-Ctarget-feature` or `-Ctarget-cpu`. Targets themselves automatically enable certain target
79
+ /// features by default, for example because the target's ABI specification requires saving specific
80
+ /// registers which only exist in an architectural extension.
81
+ ///
82
+ /// Target features can imply other target features: for example, x86-64 `avx2` implies `avx`, and
83
+ /// aarch64 `sve2` implies `sve`, since both of these architectural extensions depend on their
84
+ /// predecessors.
85
+ ///
86
+ /// Target features can be probed at compile time by [`#[cfg(target_feature)]`][2] or `cfg!(…)`
87
+ /// conditional compilation to determine whether a target feature is enabled in a particular
88
+ /// context.
89
+ ///
90
+ /// [1]: https://doc.rust-lang.org/stable/reference/attributes/codegen.html#the-target_feature-attribute
91
+ /// [2]: https://doc.rust-lang.org/reference/conditional-compilation.html#target_feature
92
+ #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
93
+ pub struct TargetFeature {
94
+ /// The name of this target feature.
95
+ pub name : String ,
96
+ /// Other target features which are implied by this target feature, if any.
97
+ pub implies_features : Vec < String > ,
98
+ /// If this target feature is unstable, the name of the associated language feature gate.
99
+ pub unstable_feature_gate : Option < String > ,
100
+ /// Whether this feature is globally enabled for this compilation session.
101
+ ///
102
+ /// Target features can be globally enabled implicitly as a result of the target's definition.
103
+ /// For example, x86-64 hardware floating point ABIs require saving x87 and SSE2 registers,
104
+ /// which in turn requires globally enabling the `x87` and `sse2` target features so that the
105
+ /// generated machine code conforms to the target's ABI.
106
+ ///
107
+ /// Target features can also be globally enabled explicitly as a result of compiler flags like
108
+ /// [`-Ctarget-feature`][1] or [`-Ctarget-cpu`][2].
109
+ ///
110
+ /// [1]: https://doc.rust-lang.org/beta/rustc/codegen-options/index.html#target-feature
111
+ /// [2]: https://doc.rust-lang.org/beta/rustc/codegen-options/index.html#target-cpu
112
+ pub globally_enabled : bool ,
113
+ }
114
+
59
115
/// Metadata of a crate, either the same crate on which `rustdoc` was invoked, or its dependency.
60
116
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
61
117
pub struct ExternalCrate {
0 commit comments