summaryrefslogtreecommitdiffstats
path: root/src/rustdoc-json-types
diff options
context:
space:
mode:
Diffstat (limited to 'src/rustdoc-json-types')
-rw-r--r--src/rustdoc-json-types/Cargo.toml1
-rw-r--r--src/rustdoc-json-types/lib.rs12
-rw-r--r--src/rustdoc-json-types/tests.rs16
3 files changed, 19 insertions, 10 deletions
diff --git a/src/rustdoc-json-types/Cargo.toml b/src/rustdoc-json-types/Cargo.toml
index d63caa7ad..d3548036d 100644
--- a/src/rustdoc-json-types/Cargo.toml
+++ b/src/rustdoc-json-types/Cargo.toml
@@ -12,3 +12,4 @@ rustc-hash = "1.1.0"
[dev-dependencies]
serde_json = "1.0"
+bincode = "1"
diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs
index 3cf8ceed6..ba8eeaa66 100644
--- a/src/rustdoc-json-types/lib.rs
+++ b/src/rustdoc-json-types/lib.rs
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use std::path::PathBuf;
/// rustdoc format-version.
-pub const FORMAT_VERSION: u32 = 24;
+pub const FORMAT_VERSION: u32 = 26;
/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
/// about the language items in the local crate, as well as info about external items to allow
@@ -83,7 +83,6 @@ pub struct Item {
/// Stringified versions of the attributes on this item (e.g. `"#[inline]"`)
pub attrs: Vec<String>,
pub deprecation: Option<Deprecation>,
- #[serde(flatten)]
pub inner: ItemEnum,
}
@@ -222,7 +221,7 @@ pub enum ItemKind {
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
-#[serde(tag = "kind", content = "inner", rename_all = "snake_case")]
+#[serde(rename_all = "snake_case")]
pub enum ItemEnum {
Module(Module),
ExternCrate {
@@ -543,7 +542,6 @@ pub enum Term {
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
-#[serde(tag = "kind", content = "inner")]
pub enum Type {
/// Structs, enums, and unions
ResolvedPath(Path),
@@ -581,13 +579,15 @@ pub enum Type {
#[serde(rename = "type")]
type_: Box<Type>,
},
- /// `<Type as Trait>::Name` or associated types like `T::Item` where `T: Iterator`
+ /// Associated types like `<Type as Trait>::Name` and `T::Item` where
+ /// `T: Iterator` or inherent associated types like `Struct::Name`.
QualifiedPath {
name: String,
args: Box<GenericArgs>,
self_type: Box<Type>,
+ /// `None` iff this is an *inherent* associated type.
#[serde(rename = "trait")]
- trait_: Path,
+ trait_: Option<Path>,
},
}
diff --git a/src/rustdoc-json-types/tests.rs b/src/rustdoc-json-types/tests.rs
index 399ff54b2..1126d5f78 100644
--- a/src/rustdoc-json-types/tests.rs
+++ b/src/rustdoc-json-types/tests.rs
@@ -8,11 +8,15 @@ fn test_struct_info_roundtrip() {
impls: vec![],
});
+ // JSON
let struct_json = serde_json::to_string(&s).unwrap();
-
let de_s = serde_json::from_str(&struct_json).unwrap();
-
assert_eq!(s, de_s);
+
+ // Bincode
+ let encoded: Vec<u8> = bincode::serialize(&s).unwrap();
+ let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap();
+ assert_eq!(s, decoded);
}
#[test]
@@ -24,9 +28,13 @@ fn test_union_info_roundtrip() {
impls: vec![],
});
+ // JSON
let union_json = serde_json::to_string(&u).unwrap();
-
let de_u = serde_json::from_str(&union_json).unwrap();
-
assert_eq!(u, de_u);
+
+ // Bincode
+ let encoded: Vec<u8> = bincode::serialize(&u).unwrap();
+ let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap();
+ assert_eq!(u, decoded);
}