@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
8
8
use std:: path:: PathBuf ;
9
9
10
10
/// rustdoc format-version.
11
- pub const FORMAT_VERSION : u32 = 29 ;
11
+ pub const FORMAT_VERSION : u32 = 30 ;
12
12
13
13
/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
14
14
/// about the language items in the local crate, as well as info about external items to allow
@@ -167,8 +167,6 @@ pub enum GenericArg {
167
167
168
168
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
169
169
pub struct Constant {
170
- #[ serde( rename = "type" ) ]
171
- pub type_ : Type ,
172
170
pub expr : String ,
173
171
pub value : Option < String > ,
174
172
pub is_literal : bool ,
@@ -188,7 +186,19 @@ pub enum TypeBindingKind {
188
186
Constraint ( Vec < GenericBound > ) ,
189
187
}
190
188
189
+ /// An opaque identifier for an item.
190
+ ///
191
+ /// It can be used to lookup in [Crate::index] or [Crate::paths] to resolve it
192
+ /// to an [Item].
193
+ ///
194
+ /// Id's are only valid within a single JSON blob. They cannot be used to
195
+ /// resolve references between the JSON output's for different crates.
196
+ ///
197
+ /// Rustdoc makes no guarantees about the inner value of Id's. Applications
198
+ /// should treat them as opaque keys to lookup items, and avoid attempting
199
+ /// to parse them, or otherwise depend on any implementation details.
191
200
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
201
+ // FIXME(aDotInTheVoid): Consider making this non-public in rustdoc-types.
192
202
pub struct Id ( pub String ) ;
193
203
194
204
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
@@ -244,7 +254,12 @@ pub enum ItemEnum {
244
254
245
255
TypeAlias ( TypeAlias ) ,
246
256
OpaqueTy ( OpaqueTy ) ,
247
- Constant ( Constant ) ,
257
+ Constant {
258
+ #[ serde( rename = "type" ) ]
259
+ type_ : Type ,
260
+ #[ serde( rename = "const" ) ]
261
+ const_ : Constant ,
262
+ } ,
248
263
249
264
Static ( Static ) ,
250
265
@@ -314,7 +329,7 @@ pub enum StructKind {
314
329
/// All [`Id`]'s will point to [`ItemEnum::StructField`]. Private and
315
330
/// `#[doc(hidden)]` fields will be given as `None`
316
331
Tuple ( Vec < Option < Id > > ) ,
317
- /// A struct with nammed fields.
332
+ /// A struct with named fields.
318
333
///
319
334
/// ```rust
320
335
/// pub struct PlainStruct { x: i32 }
0 commit comments