@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
88use std:: path:: PathBuf ;
99
1010/// rustdoc format-version.
11- pub const FORMAT_VERSION : u32 = 29 ;
11+ pub const FORMAT_VERSION : u32 = 30 ;
1212
1313/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
1414/// about the language items in the local crate, as well as info about external items to allow
@@ -167,8 +167,6 @@ pub enum GenericArg {
167167
168168#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
169169pub struct Constant {
170- #[ serde( rename = "type" ) ]
171- pub type_ : Type ,
172170 pub expr : String ,
173171 pub value : Option < String > ,
174172 pub is_literal : bool ,
@@ -188,7 +186,19 @@ pub enum TypeBindingKind {
188186 Constraint ( Vec < GenericBound > ) ,
189187}
190188
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.
191200#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
201+ // FIXME(aDotInTheVoid): Consider making this non-public in rustdoc-types.
192202pub struct Id ( pub String ) ;
193203
194204#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
@@ -244,7 +254,12 @@ pub enum ItemEnum {
244254
245255 TypeAlias ( TypeAlias ) ,
246256 OpaqueTy ( OpaqueTy ) ,
247- Constant ( Constant ) ,
257+ Constant {
258+ #[ serde( rename = "type" ) ]
259+ type_ : Type ,
260+ #[ serde( rename = "const" ) ]
261+ const_ : Constant ,
262+ } ,
248263
249264 Static ( Static ) ,
250265
@@ -314,7 +329,7 @@ pub enum StructKind {
314329 /// All [`Id`]'s will point to [`ItemEnum::StructField`]. Private and
315330 /// `#[doc(hidden)]` fields will be given as `None`
316331 Tuple ( Vec < Option < Id > > ) ,
317- /// A struct with nammed fields.
332+ /// A struct with named fields.
318333 ///
319334 /// ```rust
320335 /// pub struct PlainStruct { x: i32 }
0 commit comments