Skip to content

Commit

Permalink
Rollup merge of rust-lang#61173 - fabric-and-ink:minor-cleanup, r=varkor
Browse files Browse the repository at this point in the history
Auto-derive Encode and Decode implementations of DefPathTable

See rust-lang#60647 (comment)
  • Loading branch information
Centril authored May 26, 2019
2 parents 7b8b23c + a5e9d82 commit f530f90
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit f530f90

Please sign in to comment.