]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_data_structures/transitive_relation.rs
Various minor/cosmetic improvements to code
[rust.git] / src / librustc_data_structures / transitive_relation.rs
index e1318eb54d581df20643b9cd4d2d4bc486a738a6..250dad8136e1434530bded1693115018a26be72b 100644 (file)
@@ -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()
@@ -303,7 +304,7 @@ pub fn minimal_upper_bounds(&self, a: &T, b: &T) -> Vec<&T> {
     ///
     /// The intuition is that this moves "one step up" through a lattice
     /// (where the relation is encoding the `<=` relation for the lattice).
-    /// So e.g. if the relation is `->` and we have
+    /// So e.g., if the relation is `->` and we have
     ///
     /// ```
     /// a -> b -> d -> f