Skip to content

Commit 678c7f2

Browse files
Rollup merge of #158077 - Turbo87:bincode-replacement, r=GuillaumeGomez
rustdoc-json-types: Replace bincode dev-dependency with postcard bincode is flagged as unmaintained by [RUSTSEC-2025-0141](https://rustsec.org/advisories/RUSTSEC-2025-0141), and the advisory covers the entire crate with no patched version available. The only use in `rustdoc-json-types` was the binary serde roundtrip in the type tests. [postcard](https://crates.io/crates/postcard) is a maintained serde-based binary serialization format that covers the same roundtrip testing need. bincode is still pulled in transitively by the miri subtree (via `ipc-channel`), which needs to be [addressed upstream](rust-lang/miri#5115). ### Related - rust-lang/miri#5115
2 parents e0b878a + fee82a3 commit 678c7f2

3 files changed

Lines changed: 42 additions & 9 deletions

File tree

Cargo.lock

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,15 @@ dependencies = [
784784
"cc",
785785
]
786786

787+
[[package]]
788+
name = "cobs"
789+
version = "0.3.0"
790+
source = "registry+https://github.com/rust-lang/crates.io-index"
791+
checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1"
792+
dependencies = [
793+
"thiserror 2.0.17",
794+
]
795+
787796
[[package]]
788797
name = "codespan-reporting"
789798
version = "0.13.1"
@@ -1330,6 +1339,18 @@ dependencies = [
13301339
"stable_deref_trait",
13311340
]
13321341

1342+
[[package]]
1343+
name = "embedded-io"
1344+
version = "0.4.0"
1345+
source = "registry+https://github.com/rust-lang/crates.io-index"
1346+
checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced"
1347+
1348+
[[package]]
1349+
name = "embedded-io"
1350+
version = "0.6.1"
1351+
source = "registry+https://github.com/rust-lang/crates.io-index"
1352+
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
1353+
13331354
[[package]]
13341355
name = "ena"
13351356
version = "0.14.3"
@@ -3055,6 +3076,18 @@ dependencies = [
30553076
"portable-atomic",
30563077
]
30573078

3079+
[[package]]
3080+
name = "postcard"
3081+
version = "1.1.3"
3082+
source = "registry+https://github.com/rust-lang/crates.io-index"
3083+
checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24"
3084+
dependencies = [
3085+
"cobs",
3086+
"embedded-io 0.4.0",
3087+
"embedded-io 0.6.1",
3088+
"serde",
3089+
]
3090+
30583091
[[package]]
30593092
name = "potential_utf"
30603093
version = "0.1.4"
@@ -4978,7 +5011,7 @@ dependencies = [
49785011
name = "rustdoc-json-types"
49795012
version = "0.1.0"
49805013
dependencies = [
4981-
"bincode",
5014+
"postcard",
49825015
"rkyv",
49835016
"rustc-hash 2.1.1",
49845017
"serde",

src/rustdoc-json-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ rkyv = { version = "0.8", optional = true }
1818

1919
[dev-dependencies]
2020
serde_json = "1.0"
21-
bincode = "1"
21+
postcard = { version = "1", default-features = false, features = ["alloc"] }

src/rustdoc-json-types/tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ fn test_struct_info_roundtrip() {
1313
let de_s = serde_json::from_str(&struct_json).unwrap();
1414
assert_eq!(s, de_s);
1515

16-
// Bincode
17-
let encoded: Vec<u8> = bincode::serialize(&s).unwrap();
18-
let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap();
16+
// Postcard
17+
let encoded: Vec<u8> = postcard::to_allocvec(&s).unwrap();
18+
let decoded: ItemEnum = postcard::from_bytes(&encoded).unwrap();
1919
assert_eq!(s, decoded);
2020
}
2121

@@ -33,9 +33,9 @@ fn test_union_info_roundtrip() {
3333
let de_u = serde_json::from_str(&union_json).unwrap();
3434
assert_eq!(u, de_u);
3535

36-
// Bincode
37-
let encoded: Vec<u8> = bincode::serialize(&u).unwrap();
38-
let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap();
36+
// Postcard
37+
let encoded: Vec<u8> = postcard::to_allocvec(&u).unwrap();
38+
let decoded: ItemEnum = postcard::from_bytes(&encoded).unwrap();
3939
assert_eq!(u, decoded);
4040
}
4141

@@ -59,7 +59,7 @@ mod rkyv {
5959
/// A test to exercise the (de)serialization roundtrip for a representative selection of types,
6060
/// covering most of the rkyv-specific attributes we had to had.
6161
fn test_rkyv_roundtrip() {
62-
// Standard derives: a plain struct and union, mirroring the existing serde/bincode tests.
62+
// Standard derives: a plain struct and union, mirroring the existing serde/postcard tests.
6363
let s = ItemEnum::Struct(Struct {
6464
generics: Generics { params: vec![], where_predicates: vec![] },
6565
kind: StructKind::Plain { fields: vec![Id(1), Id(2)], has_stripped_fields: false },

0 commit comments

Comments
 (0)