Skip to content

Commit fdd6d0d

Browse files
authored
Rollup merge of rust-lang#61173 - fabric-and-ink:minor-cleanup, r=varkor
Auto-derive Encode and Decode implementations of DefPathTable See rust-lang#60647 (comment)
2 parents 1756efe + a5e9d82 commit fdd6d0d

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

src/librustc/hir/map/definitions.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::ich::Fingerprint;
1010
use rustc_data_structures::fx::FxHashMap;
1111
use rustc_data_structures::indexed_vec::{IndexVec};
1212
use rustc_data_structures::stable_hasher::StableHasher;
13-
use serialize::{Encodable, Decodable, Encoder, Decoder};
1413
use crate::session::CrateDisambiguator;
1514
use std::borrow::Borrow;
1615
use std::fmt::Write;
@@ -25,14 +24,13 @@ use crate::util::nodemap::NodeMap;
2524
/// Internally the DefPathTable holds a tree of DefKeys, where each DefKey
2625
/// stores the DefIndex of its parent.
2726
/// There is one DefPathTable for each crate.
28-
#[derive(Clone, Default)]
27+
#[derive(Clone, Default, RustcDecodable, RustcEncodable)]
2928
pub struct DefPathTable {
3029
index_to_key: Vec<DefKey>,
3130
def_path_hashes: Vec<DefPathHash>,
3231
}
3332

3433
impl DefPathTable {
35-
3634
fn allocate(&mut self,
3735
key: DefKey,
3836
def_path_hash: DefPathHash)
@@ -86,28 +84,6 @@ impl DefPathTable {
8684
}
8785
}
8886

89-
90-
impl Encodable for DefPathTable {
91-
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
92-
// Index to key
93-
self.index_to_key.encode(s)?;
94-
95-
// DefPath hashes
96-
self.def_path_hashes.encode(s)?;
97-
98-
Ok(())
99-
}
100-
}
101-
102-
impl Decodable for DefPathTable {
103-
fn decode<D: Decoder>(d: &mut D) -> Result<DefPathTable, D::Error> {
104-
Ok(DefPathTable {
105-
index_to_key: Decodable::decode(d)?,
106-
def_path_hashes : Decodable::decode(d)?,
107-
})
108-
}
109-
}
110-
11187
/// The definition table containing node definitions.
11288
/// It holds the `DefPathTable` for local `DefId`s/`DefPath`s and it also stores a
11389
/// mapping from `NodeId`s to local `DefId`s.

0 commit comments

Comments
 (0)