From 3ee67475b29b8baa288043f2153365efca5f56e9 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 5 Oct 2023 20:54:54 +1100 Subject: [PATCH 1/6] rustc_serialize: Remove unneeded feature decls. I.e. `maybe_uninit_slice` and `new_uninit`. Also sort the remaining features and remove an ugly, low-value comment. --- compiler/rustc_serialize/src/lib.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_serialize/src/lib.rs b/compiler/rustc_serialize/src/lib.rs index dd40b3cf028..bd306eed85a 100644 --- a/compiler/rustc_serialize/src/lib.rs +++ b/compiler/rustc_serialize/src/lib.rs @@ -1,25 +1,19 @@ //! Support code for encoding and decoding types. -/* -Core encoding and decoding interfaces. -*/ - #![doc( html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/", html_playground_url = "https://play.rust-lang.org/", test(attr(allow(unused_variables), deny(warnings))) )] -#![feature(never_type)] -#![feature(associated_type_bounds)] -#![feature(min_specialization)] -#![feature(core_intrinsics)] -#![feature(maybe_uninit_slice)] -#![feature(new_uninit)] #![feature(allocator_api)] +#![feature(associated_type_bounds)] +#![feature(const_option)] +#![feature(core_intrinsics)] +#![feature(inline_const)] +#![feature(min_specialization)] +#![feature(never_type)] #![feature(ptr_sub_ptr)] #![feature(slice_first_last_chunk)] -#![feature(inline_const)] -#![feature(const_option)] #![cfg_attr(test, feature(test))] #![allow(rustc::internal)] #![deny(rustc::untranslatable_diagnostic)] From f703475b4eaef5c65a0891a9e27d3945aec4ced6 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 5 Oct 2023 20:59:15 +1100 Subject: [PATCH 2/6] Remove unused serialization support for `LinkedList`. --- .../rustc_serialize/src/collection_impls.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/compiler/rustc_serialize/src/collection_impls.rs b/compiler/rustc_serialize/src/collection_impls.rs index 8f8c504117c..b7512593c14 100644 --- a/compiler/rustc_serialize/src/collection_impls.rs +++ b/compiler/rustc_serialize/src/collection_impls.rs @@ -2,7 +2,7 @@ use crate::{Decodable, Decoder, Encodable, Encoder}; use smallvec::{Array, SmallVec}; -use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, LinkedList, VecDeque}; +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque}; use std::hash::{BuildHasher, Hash}; use std::rc::Rc; use std::sync::Arc; @@ -35,22 +35,6 @@ impl> Decodable for ThinVec { } } -impl> Encodable for LinkedList { - fn encode(&self, s: &mut S) { - s.emit_usize(self.len()); - for e in self.iter() { - e.encode(s); - } - } -} - -impl> Decodable for LinkedList { - fn decode(d: &mut D) -> LinkedList { - let len = d.read_usize(); - (0..len).map(|_| Decodable::decode(d)).collect() - } -} - impl> Encodable for VecDeque { fn encode(&self, s: &mut S) { s.emit_usize(self.len()); From 5f69ca62f2ceb9fab475c05e6df426fcc26cb77d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 6 Oct 2023 09:50:23 +1100 Subject: [PATCH 3/6] rustc_serialize: merge `collection_impls.rs` into `serialize.rs`. `serialize.rs` has the `Encodable`/`Decodable` impls for lots of basic types, including `Vec`. `collection_impls` has it for lots of collection types. The distinction isn't really meaningful, and it's simpler to have them all in a single file. --- .../rustc_serialize/src/collection_impls.rs | 263 ------------------ compiler/rustc_serialize/src/lib.rs | 1 - compiler/rustc_serialize/src/serialize.rs | 258 +++++++++++++++++ 3 files changed, 258 insertions(+), 264 deletions(-) delete mode 100644 compiler/rustc_serialize/src/collection_impls.rs diff --git a/compiler/rustc_serialize/src/collection_impls.rs b/compiler/rustc_serialize/src/collection_impls.rs deleted file mode 100644 index b7512593c14..00000000000 --- a/compiler/rustc_serialize/src/collection_impls.rs +++ /dev/null @@ -1,263 +0,0 @@ -//! Implementations of serialization for structures found in liballoc - -use crate::{Decodable, Decoder, Encodable, Encoder}; -use smallvec::{Array, SmallVec}; -use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque}; -use std::hash::{BuildHasher, Hash}; -use std::rc::Rc; -use std::sync::Arc; -use thin_vec::ThinVec; - -impl>> Encodable for SmallVec { - fn encode(&self, s: &mut S) { - let slice: &[A::Item] = self; - slice.encode(s); - } -} - -impl>> Decodable for SmallVec { - fn decode(d: &mut D) -> SmallVec { - let len = d.read_usize(); - (0..len).map(|_| Decodable::decode(d)).collect() - } -} - -impl> Encodable for ThinVec { - fn encode(&self, s: &mut S) { - self.as_slice().encode(s); - } -} - -impl> Decodable for ThinVec { - fn decode(d: &mut D) -> ThinVec { - let len = d.read_usize(); - (0..len).map(|_| Decodable::decode(d)).collect() - } -} - -impl> Encodable for VecDeque { - fn encode(&self, s: &mut S) { - s.emit_usize(self.len()); - for e in self.iter() { - e.encode(s); - } - } -} - -impl> Decodable for VecDeque { - fn decode(d: &mut D) -> VecDeque { - let len = d.read_usize(); - (0..len).map(|_| Decodable::decode(d)).collect() - } -} - -impl Encodable for BTreeMap -where - K: Encodable + PartialEq + Ord, - V: Encodable, -{ - fn encode(&self, e: &mut S) { - e.emit_usize(self.len()); - for (key, val) in self.iter() { - key.encode(e); - val.encode(e); - } - } -} - -impl Decodable for BTreeMap -where - K: Decodable + PartialEq + Ord, - V: Decodable, -{ - fn decode(d: &mut D) -> BTreeMap { - let len = d.read_usize(); - let mut map = BTreeMap::new(); - for _ in 0..len { - let key = Decodable::decode(d); - let val = Decodable::decode(d); - map.insert(key, val); - } - map - } -} - -impl Encodable for BTreeSet -where - T: Encodable + PartialEq + Ord, -{ - fn encode(&self, s: &mut S) { - s.emit_usize(self.len()); - for e in self.iter() { - e.encode(s); - } - } -} - -impl Decodable for BTreeSet -where - T: Decodable + PartialEq + Ord, -{ - fn decode(d: &mut D) -> BTreeSet { - let len = d.read_usize(); - let mut set = BTreeSet::new(); - for _ in 0..len { - set.insert(Decodable::decode(d)); - } - set - } -} - -impl Encodable for HashMap -where - K: Encodable + Eq, - V: Encodable, - S: BuildHasher, -{ - fn encode(&self, e: &mut E) { - e.emit_usize(self.len()); - for (key, val) in self.iter() { - key.encode(e); - val.encode(e); - } - } -} - -impl Decodable for HashMap -where - K: Decodable + Hash + Eq, - V: Decodable, - S: BuildHasher + Default, -{ - fn decode(d: &mut D) -> HashMap { - let len = d.read_usize(); - let state = Default::default(); - let mut map = HashMap::with_capacity_and_hasher(len, state); - for _ in 0..len { - let key = Decodable::decode(d); - let val = Decodable::decode(d); - map.insert(key, val); - } - map - } -} - -impl Encodable for HashSet -where - T: Encodable + Eq, - S: BuildHasher, -{ - fn encode(&self, s: &mut E) { - s.emit_usize(self.len()); - for e in self.iter() { - e.encode(s); - } - } -} - -impl Decodable for HashSet -where - T: Decodable + Hash + Eq, - S: BuildHasher + Default, -{ - fn decode(d: &mut D) -> HashSet { - let len = d.read_usize(); - let state = Default::default(); - let mut set = HashSet::with_capacity_and_hasher(len, state); - for _ in 0..len { - set.insert(Decodable::decode(d)); - } - set - } -} - -impl Encodable for indexmap::IndexMap -where - K: Encodable + Hash + Eq, - V: Encodable, - S: BuildHasher, -{ - fn encode(&self, e: &mut E) { - e.emit_usize(self.len()); - for (key, val) in self.iter() { - key.encode(e); - val.encode(e); - } - } -} - -impl Decodable for indexmap::IndexMap -where - K: Decodable + Hash + Eq, - V: Decodable, - S: BuildHasher + Default, -{ - fn decode(d: &mut D) -> indexmap::IndexMap { - let len = d.read_usize(); - let state = Default::default(); - let mut map = indexmap::IndexMap::with_capacity_and_hasher(len, state); - for _ in 0..len { - let key = Decodable::decode(d); - let val = Decodable::decode(d); - map.insert(key, val); - } - map - } -} - -impl Encodable for indexmap::IndexSet -where - T: Encodable + Hash + Eq, - S: BuildHasher, -{ - fn encode(&self, s: &mut E) { - s.emit_usize(self.len()); - for e in self.iter() { - e.encode(s); - } - } -} - -impl Decodable for indexmap::IndexSet -where - T: Decodable + Hash + Eq, - S: BuildHasher + Default, -{ - fn decode(d: &mut D) -> indexmap::IndexSet { - let len = d.read_usize(); - let state = Default::default(); - let mut set = indexmap::IndexSet::with_capacity_and_hasher(len, state); - for _ in 0..len { - set.insert(Decodable::decode(d)); - } - set - } -} - -impl> Encodable for Rc<[T]> { - fn encode(&self, s: &mut E) { - let slice: &[T] = self; - slice.encode(s); - } -} - -impl> Decodable for Rc<[T]> { - fn decode(d: &mut D) -> Rc<[T]> { - let vec: Vec = Decodable::decode(d); - vec.into() - } -} - -impl> Encodable for Arc<[T]> { - fn encode(&self, s: &mut E) { - let slice: &[T] = self; - slice.encode(s); - } -} - -impl> Decodable for Arc<[T]> { - fn decode(d: &mut D) -> Arc<[T]> { - let vec: Vec = Decodable::decode(d); - vec.into() - } -} diff --git a/compiler/rustc_serialize/src/lib.rs b/compiler/rustc_serialize/src/lib.rs index bd306eed85a..5360aa9ea6a 100644 --- a/compiler/rustc_serialize/src/lib.rs +++ b/compiler/rustc_serialize/src/lib.rs @@ -21,7 +21,6 @@ pub use self::serialize::{Decodable, Decoder, Encodable, Encoder}; -mod collection_impls; mod serialize; pub mod leb128; diff --git a/compiler/rustc_serialize/src/serialize.rs b/compiler/rustc_serialize/src/serialize.rs index 06166cabc18..704de14dd46 100644 --- a/compiler/rustc_serialize/src/serialize.rs +++ b/compiler/rustc_serialize/src/serialize.rs @@ -1,12 +1,16 @@ //! Support code for encoding and decoding types. +use smallvec::{Array, SmallVec}; use std::alloc::Allocator; use std::borrow::Cow; use std::cell::{Cell, RefCell}; +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque}; +use std::hash::{BuildHasher, Hash}; use std::marker::PhantomData; use std::path; use std::rc::Rc; use std::sync::Arc; +use thin_vec::ThinVec; /// A byte that [cannot occur in UTF8 sequences][utf8]. Used to mark the end of a string. /// This way we can skip validation and still be relatively sure that deserialization @@ -509,3 +513,257 @@ impl> Decodable for Box>> Encodable for SmallVec { + fn encode(&self, s: &mut S) { + let slice: &[A::Item] = self; + slice.encode(s); + } +} + +impl>> Decodable for SmallVec { + fn decode(d: &mut D) -> SmallVec { + let len = d.read_usize(); + (0..len).map(|_| Decodable::decode(d)).collect() + } +} + +impl> Encodable for ThinVec { + fn encode(&self, s: &mut S) { + self.as_slice().encode(s); + } +} + +impl> Decodable for ThinVec { + fn decode(d: &mut D) -> ThinVec { + let len = d.read_usize(); + (0..len).map(|_| Decodable::decode(d)).collect() + } +} + +impl> Encodable for VecDeque { + fn encode(&self, s: &mut S) { + s.emit_usize(self.len()); + for e in self.iter() { + e.encode(s); + } + } +} + +impl> Decodable for VecDeque { + fn decode(d: &mut D) -> VecDeque { + let len = d.read_usize(); + (0..len).map(|_| Decodable::decode(d)).collect() + } +} + +impl Encodable for BTreeMap +where + K: Encodable + PartialEq + Ord, + V: Encodable, +{ + fn encode(&self, e: &mut S) { + e.emit_usize(self.len()); + for (key, val) in self.iter() { + key.encode(e); + val.encode(e); + } + } +} + +impl Decodable for BTreeMap +where + K: Decodable + PartialEq + Ord, + V: Decodable, +{ + fn decode(d: &mut D) -> BTreeMap { + let len = d.read_usize(); + let mut map = BTreeMap::new(); + for _ in 0..len { + let key = Decodable::decode(d); + let val = Decodable::decode(d); + map.insert(key, val); + } + map + } +} + +impl Encodable for BTreeSet +where + T: Encodable + PartialEq + Ord, +{ + fn encode(&self, s: &mut S) { + s.emit_usize(self.len()); + for e in self.iter() { + e.encode(s); + } + } +} + +impl Decodable for BTreeSet +where + T: Decodable + PartialEq + Ord, +{ + fn decode(d: &mut D) -> BTreeSet { + let len = d.read_usize(); + let mut set = BTreeSet::new(); + for _ in 0..len { + set.insert(Decodable::decode(d)); + } + set + } +} + +impl Encodable for HashMap +where + K: Encodable + Eq, + V: Encodable, + S: BuildHasher, +{ + fn encode(&self, e: &mut E) { + e.emit_usize(self.len()); + for (key, val) in self.iter() { + key.encode(e); + val.encode(e); + } + } +} + +impl Decodable for HashMap +where + K: Decodable + Hash + Eq, + V: Decodable, + S: BuildHasher + Default, +{ + fn decode(d: &mut D) -> HashMap { + let len = d.read_usize(); + let state = Default::default(); + let mut map = HashMap::with_capacity_and_hasher(len, state); + for _ in 0..len { + let key = Decodable::decode(d); + let val = Decodable::decode(d); + map.insert(key, val); + } + map + } +} + +impl Encodable for HashSet +where + T: Encodable + Eq, + S: BuildHasher, +{ + fn encode(&self, s: &mut E) { + s.emit_usize(self.len()); + for e in self.iter() { + e.encode(s); + } + } +} + +impl Decodable for HashSet +where + T: Decodable + Hash + Eq, + S: BuildHasher + Default, +{ + fn decode(d: &mut D) -> HashSet { + let len = d.read_usize(); + let state = Default::default(); + let mut set = HashSet::with_capacity_and_hasher(len, state); + for _ in 0..len { + set.insert(Decodable::decode(d)); + } + set + } +} + +impl Encodable for indexmap::IndexMap +where + K: Encodable + Hash + Eq, + V: Encodable, + S: BuildHasher, +{ + fn encode(&self, e: &mut E) { + e.emit_usize(self.len()); + for (key, val) in self.iter() { + key.encode(e); + val.encode(e); + } + } +} + +impl Decodable for indexmap::IndexMap +where + K: Decodable + Hash + Eq, + V: Decodable, + S: BuildHasher + Default, +{ + fn decode(d: &mut D) -> indexmap::IndexMap { + let len = d.read_usize(); + let state = Default::default(); + let mut map = indexmap::IndexMap::with_capacity_and_hasher(len, state); + for _ in 0..len { + let key = Decodable::decode(d); + let val = Decodable::decode(d); + map.insert(key, val); + } + map + } +} + +impl Encodable for indexmap::IndexSet +where + T: Encodable + Hash + Eq, + S: BuildHasher, +{ + fn encode(&self, s: &mut E) { + s.emit_usize(self.len()); + for e in self.iter() { + e.encode(s); + } + } +} + +impl Decodable for indexmap::IndexSet +where + T: Decodable + Hash + Eq, + S: BuildHasher + Default, +{ + fn decode(d: &mut D) -> indexmap::IndexSet { + let len = d.read_usize(); + let state = Default::default(); + let mut set = indexmap::IndexSet::with_capacity_and_hasher(len, state); + for _ in 0..len { + set.insert(Decodable::decode(d)); + } + set + } +} + +impl> Encodable for Rc<[T]> { + fn encode(&self, s: &mut E) { + let slice: &[T] = self; + slice.encode(s); + } +} + +impl> Decodable for Rc<[T]> { + fn decode(d: &mut D) -> Rc<[T]> { + let vec: Vec = Decodable::decode(d); + vec.into() + } +} + +impl> Encodable for Arc<[T]> { + fn encode(&self, s: &mut E) { + let slice: &[T] = self; + slice.encode(s); + } +} + +impl> Decodable for Arc<[T]> { + fn decode(d: &mut D) -> Arc<[T]> { + let vec: Vec = Decodable::decode(d); + vec.into() + } +} From 2db1d5983032b3f3f80646310c3b39f417a6af2d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 6 Oct 2023 10:05:07 +1100 Subject: [PATCH 4/6] Use `collect` for decoding more collection types. --- compiler/rustc_serialize/src/serialize.rs | 46 +++-------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/compiler/rustc_serialize/src/serialize.rs b/compiler/rustc_serialize/src/serialize.rs index 704de14dd46..fa7e4d59fcc 100644 --- a/compiler/rustc_serialize/src/serialize.rs +++ b/compiler/rustc_serialize/src/serialize.rs @@ -578,13 +578,7 @@ where { fn decode(d: &mut D) -> BTreeMap { let len = d.read_usize(); - let mut map = BTreeMap::new(); - for _ in 0..len { - let key = Decodable::decode(d); - let val = Decodable::decode(d); - map.insert(key, val); - } - map + (0..len).map(|_| (Decodable::decode(d), Decodable::decode(d))).collect() } } @@ -606,11 +600,7 @@ where { fn decode(d: &mut D) -> BTreeSet { let len = d.read_usize(); - let mut set = BTreeSet::new(); - for _ in 0..len { - set.insert(Decodable::decode(d)); - } - set + (0..len).map(|_| Decodable::decode(d)).collect() } } @@ -637,14 +627,7 @@ where { fn decode(d: &mut D) -> HashMap { let len = d.read_usize(); - let state = Default::default(); - let mut map = HashMap::with_capacity_and_hasher(len, state); - for _ in 0..len { - let key = Decodable::decode(d); - let val = Decodable::decode(d); - map.insert(key, val); - } - map + (0..len).map(|_| (Decodable::decode(d), Decodable::decode(d))).collect() } } @@ -668,12 +651,7 @@ where { fn decode(d: &mut D) -> HashSet { let len = d.read_usize(); - let state = Default::default(); - let mut set = HashSet::with_capacity_and_hasher(len, state); - for _ in 0..len { - set.insert(Decodable::decode(d)); - } - set + (0..len).map(|_| Decodable::decode(d)).collect() } } @@ -700,14 +678,7 @@ where { fn decode(d: &mut D) -> indexmap::IndexMap { let len = d.read_usize(); - let state = Default::default(); - let mut map = indexmap::IndexMap::with_capacity_and_hasher(len, state); - for _ in 0..len { - let key = Decodable::decode(d); - let val = Decodable::decode(d); - map.insert(key, val); - } - map + (0..len).map(|_| (Decodable::decode(d), Decodable::decode(d))).collect() } } @@ -731,12 +702,7 @@ where { fn decode(d: &mut D) -> indexmap::IndexSet { let len = d.read_usize(); - let state = Default::default(); - let mut set = indexmap::IndexSet::with_capacity_and_hasher(len, state); - for _ in 0..len { - set.insert(Decodable::decode(d)); - } - set + (0..len).map(|_| Decodable::decode(d)).collect() } } From 1d71971973cd7429e9cf61c27bfb95daaac86486 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 6 Oct 2023 10:10:16 +1100 Subject: [PATCH 5/6] Streamline some `Encodable` impls. Making them consistent with similar impls. --- compiler/rustc_serialize/src/serialize.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_serialize/src/serialize.rs b/compiler/rustc_serialize/src/serialize.rs index fa7e4d59fcc..0a340ac09fb 100644 --- a/compiler/rustc_serialize/src/serialize.rs +++ b/compiler/rustc_serialize/src/serialize.rs @@ -307,8 +307,7 @@ impl> Encodable for [T] { impl> Encodable for Vec { fn encode(&self, s: &mut S) { - let slice: &[T] = self; - slice.encode(s); + self.as_slice().encode(s); } } @@ -332,8 +331,7 @@ impl, A: Allocator + Default> Decodable for Vec, const N: usize> Encodable for [T; N] { fn encode(&self, s: &mut S) { - let slice: &[T] = self; - slice.encode(s); + self.as_slice().encode(s); } } @@ -516,8 +514,7 @@ impl> Decodable for Box>> Encodable for SmallVec { fn encode(&self, s: &mut S) { - let slice: &[A::Item] = self; - slice.encode(s); + self.as_slice().encode(s); } } From ad8271dd56bc3a0ef4a1a28af1ef321608d950b2 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 6 Oct 2023 10:16:20 +1100 Subject: [PATCH 6/6] Use `collect` to decode `Vec`. It's hyper-optimized, we don't need our own unsafe code here. This requires getting rid of all the `Allocator` stuff, which isn't needed anyway. --- compiler/rustc_serialize/src/serialize.rs | 33 +++++++---------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/compiler/rustc_serialize/src/serialize.rs b/compiler/rustc_serialize/src/serialize.rs index 0a340ac09fb..63bd3457eb9 100644 --- a/compiler/rustc_serialize/src/serialize.rs +++ b/compiler/rustc_serialize/src/serialize.rs @@ -1,7 +1,6 @@ //! Support code for encoding and decoding types. use smallvec::{Array, SmallVec}; -use std::alloc::Allocator; use std::borrow::Cow; use std::cell::{Cell, RefCell}; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque}; @@ -277,9 +276,9 @@ impl Decodable for PhantomData { } } -impl> Decodable for Box<[T], A> { - fn decode(d: &mut D) -> Box<[T], A> { - let v: Vec = Decodable::decode(d); +impl> Decodable for Box<[T]> { + fn decode(d: &mut D) -> Box<[T]> { + let v: Vec = Decodable::decode(d); v.into_boxed_slice() } } @@ -311,21 +310,10 @@ impl> Encodable for Vec { } } -impl, A: Allocator + Default> Decodable for Vec { - default fn decode(d: &mut D) -> Vec { +impl> Decodable for Vec { + default fn decode(d: &mut D) -> Vec { let len = d.read_usize(); - let allocator = A::default(); - // SAFETY: we set the capacity in advance, only write elements, and - // only set the length at the end once the writing has succeeded. - let mut vec = Vec::with_capacity_in(len, allocator); - unsafe { - let ptr: *mut T = vec.as_mut_ptr(); - for i in 0..len { - std::ptr::write(ptr.add(i), Decodable::decode(d)); - } - vec.set_len(len); - } - vec + (0..len).map(|_| Decodable::decode(d)).collect() } } @@ -499,16 +487,15 @@ impl> Decodable for Arc { } } -impl, A: Allocator + Default> Encodable for Box { +impl> Encodable for Box { fn encode(&self, s: &mut S) { (**self).encode(s) } } -impl> Decodable for Box { - fn decode(d: &mut D) -> Box { - let allocator = A::default(); - Box::new_in(Decodable::decode(d), allocator) +impl> Decodable for Box { + fn decode(d: &mut D) -> Box { + Box::new(Decodable::decode(d)) } }