diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-07-25 15:44:06 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-11-21 08:11:50 +0200 |
| commit | 7683180be5b51bb626e0cf372a3dee31cab8b61c (patch) | |
| tree | 396a19da6a63f8549da45238f134c3433dde7b44 /src/librustc_data_structures | |
| parent | da622a3796f5488d89daaf3b32ceb509ce4d669b (diff) | |
rustc: implement and use Default on more types.
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/librustc_data_structures/snapshot_map/mod.rs | 23 | ||||
| -rw-r--r-- | src/librustc_data_structures/transitive_relation.rs | 23 |
3 files changed, 25 insertions, 23 deletions
diff --git a/src/librustc_data_structures/Cargo.toml b/src/librustc_data_structures/Cargo.toml index 79f073d643d..5b3dd38adf2 100644 --- a/src/librustc_data_structures/Cargo.toml +++ b/src/librustc_data_structures/Cargo.toml @@ -9,7 +9,7 @@ path = "lib.rs" crate-type = ["dylib"] [dependencies] -ena = "0.9.3" +ena = "0.10.1" log = "0.4" rustc_cratesio_shim = { path = "../librustc_cratesio_shim" } serialize = { path = "../libserialize" } diff --git a/src/librustc_data_structures/snapshot_map/mod.rs b/src/librustc_data_structures/snapshot_map/mod.rs index f8663cd4fd4..0b42cb1eddd 100644 --- a/src/librustc_data_structures/snapshot_map/mod.rs +++ b/src/librustc_data_structures/snapshot_map/mod.rs @@ -23,6 +23,18 @@ pub struct SnapshotMap<K, V> undo_log: Vec<UndoLog<K, V>>, } +// HACK(eddyb) manual impl avoids `Default` bounds on `K` and `V`. +impl<K, V> Default for SnapshotMap<K, V> + where K: Hash + Clone + Eq +{ + fn default() -> Self { + SnapshotMap { + map: Default::default(), + undo_log: Default::default(), + } + } +} + pub struct Snapshot { len: usize, } @@ -35,17 +47,6 @@ enum UndoLog<K, V> { Noop, } -impl<K, V> Default for SnapshotMap<K, V> - where K: Hash + Clone + Eq -{ - fn default() -> Self { - SnapshotMap { - map: FxHashMap::default(), - undo_log: vec![], - } - } -} - impl<K, V> SnapshotMap<K, V> where K: Hash + Clone + Eq { diff --git a/src/librustc_data_structures/transitive_relation.rs b/src/librustc_data_structures/transitive_relation.rs index e1318eb54d5..fd5dfab9e61 100644 --- a/src/librustc_data_structures/transitive_relation.rs +++ b/src/librustc_data_structures/transitive_relation.rs @@ -42,6 +42,18 @@ pub struct TransitiveRelation<T: Clone + Debug + Eq + Hash> { closure: Lock<Option<BitMatrix<usize, usize>>>, } +// HACK(eddyb) manual impl avoids `Default` bound on `T`. +impl<T: Clone + Debug + Eq + Hash> Default for TransitiveRelation<T> { + fn default() -> Self { + TransitiveRelation { + elements: Default::default(), + map: Default::default(), + edges: Default::default(), + closure: Default::default(), + } + } +} + #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)] struct Index(usize); @@ -51,17 +63,6 @@ struct Edge { target: Index, } -impl<T: Clone + Debug + Eq + Hash> Default for TransitiveRelation<T> { - fn default() -> TransitiveRelation<T> { - TransitiveRelation { - elements: vec![], - map: FxHashMap::default(), - edges: vec![], - closure: Lock::new(None), - } - } -} - impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> { pub fn is_empty(&self) -> bool { self.edges.is_empty() |
