diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2020-06-11 15:49:57 +0100 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2020-08-14 17:34:30 +0100 |
| commit | cbcef3effcf64bd0d89ea2dc8973e18d7fcf94c3 (patch) | |
| tree | cf11d5e77bdfe87b0a19d5f93ff251b256770325 /src/librustc_data_structures/transitive_relation.rs | |
| parent | 55b9adfafa11b2ced5c0477c949fd875b19b3877 (diff) | |
| download | rust-cbcef3effcf64bd0d89ea2dc8973e18d7fcf94c3.tar.gz rust-cbcef3effcf64bd0d89ea2dc8973e18d7fcf94c3.zip | |
Rework `rustc_serialize`
- Move the type parameter from `encode` and `decode` methods to the trait. - Remove `UseSpecialized(En|De)codable` traits. - Remove blanket impls for references. - Add `RefDecodable` trait to allow deserializing to arena-allocated references safely. - Remove ability to (de)serialize HIR. - Create proc-macros `(Ty)?(En|De)codable` to help implement these new traits.
Diffstat (limited to 'src/librustc_data_structures/transitive_relation.rs')
| -rw-r--r-- | src/librustc_data_structures/transitive_relation.rs | 69 |
1 files changed, 2 insertions, 67 deletions
diff --git a/src/librustc_data_structures/transitive_relation.rs b/src/librustc_data_structures/transitive_relation.rs index 7d137a55033..fe60a99dde0 100644 --- a/src/librustc_data_structures/transitive_relation.rs +++ b/src/librustc_data_structures/transitive_relation.rs @@ -1,8 +1,6 @@ use crate::fx::FxIndexSet; -use crate::stable_hasher::{HashStable, StableHasher}; use crate::sync::Lock; use rustc_index::bit_set::BitMatrix; -use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use std::fmt::Debug; use std::hash::Hash; use std::mem; @@ -42,10 +40,10 @@ impl<T: Eq + Hash> Default for TransitiveRelation<T> { } } -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, RustcEncodable, RustcDecodable, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Debug)] struct Index(usize); -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] struct Edge { source: Index, target: Index, @@ -402,66 +400,3 @@ fn pare_down(candidates: &mut Vec<usize>, closure: &BitMatrix<usize, usize>) { candidates.truncate(j - dead); } } - -impl<T> Encodable for TransitiveRelation<T> -where - T: Clone + Encodable + Debug + Eq + Hash + Clone, -{ - fn encode<E: Encoder>(&self, s: &mut E) -> Result<(), E::Error> { - s.emit_struct("TransitiveRelation", 2, |s| { - s.emit_struct_field("elements", 0, |s| self.elements.encode(s))?; - s.emit_struct_field("edges", 1, |s| self.edges.encode(s))?; - Ok(()) - }) - } -} - -impl<T> Decodable for TransitiveRelation<T> -where - T: Clone + Decodable + Debug + Eq + Hash + Clone, -{ - fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error> { - d.read_struct("TransitiveRelation", 2, |d| { - Ok(TransitiveRelation { - elements: d.read_struct_field("elements", 0, |d| Decodable::decode(d))?, - edges: d.read_struct_field("edges", 1, |d| Decodable::decode(d))?, - closure: Lock::new(None), - }) - }) - } -} - -impl<CTX, T> HashStable<CTX> for TransitiveRelation<T> -where - T: HashStable<CTX> + Eq + Debug + Clone + Hash, -{ - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - // We are assuming here that the relation graph has been built in a - // deterministic way and we can just hash it the way it is. - let TransitiveRelation { - ref elements, - ref edges, - // "closure" is just a copy of the data above - closure: _, - } = *self; - - elements.hash_stable(hcx, hasher); - edges.hash_stable(hcx, hasher); - } -} - -impl<CTX> HashStable<CTX> for Edge { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - let Edge { ref source, ref target } = *self; - - source.hash_stable(hcx, hasher); - target.hash_stable(hcx, hasher); - } -} - -impl<CTX> HashStable<CTX> for Index { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - let Index(idx) = *self; - idx.hash_stable(hcx, hasher); - } -} |
