about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFabian Drinck <fabian.drinck@rwth-aachen.de>2019-05-25 11:40:06 +0200
committerFabian Drinck <fabian.drinck@rwth-aachen.de>2019-05-25 11:40:06 +0200
commita5e9d8240ece4a1a14178b7de15d2a874aef6d10 (patch)
treefc6f9c2e12bea9abf62e9975d32acab099402c61
parent315ab95a9c13cbb69ae8538fcd69b9f7b0c30f89 (diff)
downloadrust-a5e9d8240ece4a1a14178b7de15d2a874aef6d10.tar.gz
rust-a5e9d8240ece4a1a14178b7de15d2a874aef6d10.zip
Auto-derive Encode and Decode implementations
-rw-r--r--src/librustc/hir/map/definitions.rs26
1 files changed, 1 insertions, 25 deletions
diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs
index 1cc9a2c0e8a..2324c3f0428 100644
--- a/src/librustc/hir/map/definitions.rs
+++ b/src/librustc/hir/map/definitions.rs
@@ -10,7 +10,6 @@ use crate::ich::Fingerprint;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::indexed_vec::{IndexVec};
 use rustc_data_structures::stable_hasher::StableHasher;
-use serialize::{Encodable, Decodable, Encoder, Decoder};
 use crate::session::CrateDisambiguator;
 use std::borrow::Borrow;
 use std::fmt::Write;
@@ -25,14 +24,13 @@ use crate::util::nodemap::NodeMap;
 /// Internally the DefPathTable holds a tree of DefKeys, where each DefKey
 /// stores the DefIndex of its parent.
 /// There is one DefPathTable for each crate.
-#[derive(Clone, Default)]
+#[derive(Clone, Default, RustcDecodable, RustcEncodable)]
 pub struct DefPathTable {
     index_to_key: Vec<DefKey>,
     def_path_hashes: Vec<DefPathHash>,
 }
 
 impl DefPathTable {
-
     fn allocate(&mut self,
                 key: DefKey,
                 def_path_hash: DefPathHash)
@@ -86,28 +84,6 @@ impl DefPathTable {
     }
 }
 
-
-impl Encodable for DefPathTable {
-    fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
-        // Index to key
-        self.index_to_key.encode(s)?;
-
-        // DefPath hashes
-        self.def_path_hashes.encode(s)?;
-
-        Ok(())
-    }
-}
-
-impl Decodable for DefPathTable {
-    fn decode<D: Decoder>(d: &mut D) -> Result<DefPathTable, D::Error> {
-        Ok(DefPathTable {
-            index_to_key: Decodable::decode(d)?,
-            def_path_hashes : Decodable::decode(d)?,
-        })
-    }
-}
-
 /// The definition table containing node definitions.
 /// It holds the `DefPathTable` for local `DefId`s/`DefPath`s and it also stores a
 /// mapping from `NodeId`s to local `DefId`s.