From 9835e2ae736235810b4ea1c162ca5e65c547e770 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 18 May 2024 04:49:50 +0200 Subject: Merging upstream version 1.71.1+dfsg1. Signed-off-by: Daniel Baumann --- src/rustdoc-json-types/Cargo.toml | 1 + src/rustdoc-json-types/lib.rs | 12 ++++++------ src/rustdoc-json-types/tests.rs | 16 ++++++++++++---- 3 files changed, 19 insertions(+), 10 deletions(-) (limited to 'src/rustdoc-json-types') 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, pub deprecation: Option, - #[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, }, - /// `::Name` or associated types like `T::Item` where `T: Iterator` + /// Associated types like `::Name` and `T::Item` where + /// `T: Iterator` or inherent associated types like `Struct::Name`. QualifiedPath { name: String, args: Box, self_type: Box, + /// `None` iff this is an *inherent* associated type. #[serde(rename = "trait")] - trait_: Path, + trait_: Option, }, } 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 = 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 = bincode::serialize(&u).unwrap(); + let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap(); + assert_eq!(u, decoded); } -- cgit v1.2.3