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