about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/infer/mod.rs2
-rw-r--r--src/librustc/traits/project.rs6
-rw-r--r--src/librustc_data_structures/base_n.rs5
-rw-r--r--src/librustc_data_structures/bitslice.rs5
-rw-r--r--src/librustc_data_structures/bitvec.rs5
-rw-r--r--src/librustc_data_structures/flock.rs4
-rw-r--r--src/librustc_data_structures/graph/dominators/mod.rs3
-rw-r--r--src/librustc_data_structures/graph/implementation/mod.rs8
-rw-r--r--src/librustc_data_structures/indexed_set.rs9
-rw-r--r--src/librustc_data_structures/obligation_forest/mod.rs2
-rw-r--r--src/librustc_data_structures/snapshot_map/mod.rs10
-rw-r--r--src/librustc_data_structures/snapshot_map/test.rs8
-rw-r--r--src/librustc_data_structures/tiny_list.rs3
-rw-r--r--src/librustc_data_structures/transitive_relation.rs15
14 files changed, 42 insertions, 43 deletions
diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs
index 0b84c6a0aa7..eed6215150f 100644
--- a/src/librustc/infer/mod.rs
+++ b/src/librustc/infer/mod.rs
@@ -709,7 +709,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
 
         self.projection_cache
             .borrow_mut()
-            .commit(projection_cache_snapshot);
+            .commit(&projection_cache_snapshot);
         self.type_variables
             .borrow_mut()
             .commit(type_snapshot);
diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs
index 8d03f532660..1224cdd76d8 100644
--- a/src/librustc/traits/project.rs
+++ b/src/librustc/traits/project.rs
@@ -1668,15 +1668,15 @@ impl<'tcx> ProjectionCache<'tcx> {
     }
 
     pub fn rollback_to(&mut self, snapshot: ProjectionCacheSnapshot) {
-        self.map.rollback_to(snapshot.snapshot);
+        self.map.rollback_to(&snapshot.snapshot);
     }
 
     pub fn rollback_skolemized(&mut self, snapshot: &ProjectionCacheSnapshot) {
         self.map.partial_rollback(&snapshot.snapshot, &|k| k.ty.has_re_skol());
     }
 
-    pub fn commit(&mut self, snapshot: ProjectionCacheSnapshot) {
-        self.map.commit(snapshot.snapshot);
+    pub fn commit(&mut self, snapshot: &ProjectionCacheSnapshot) {
+        self.map.commit(&snapshot.snapshot);
     }
 
     /// Try to start normalize `key`; returns an error if
diff --git a/src/librustc_data_structures/base_n.rs b/src/librustc_data_structures/base_n.rs
index d333b6393b9..d3b47daa5b4 100644
--- a/src/librustc_data_structures/base_n.rs
+++ b/src/librustc_data_structures/base_n.rs
@@ -17,7 +17,7 @@ pub const MAX_BASE: usize = 64;
 pub const ALPHANUMERIC_ONLY: usize = 62;
 pub const CASE_INSENSITIVE: usize = 36;
 
-const BASE_64: &'static [u8; MAX_BASE as usize] =
+const BASE_64: &[u8; MAX_BASE as usize] =
     b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@$";
 
 #[inline]
@@ -37,7 +37,8 @@ pub fn push_str(mut n: u128, base: usize, output: &mut String) {
             break;
         }
     }
-    &mut s[0..index].reverse();
+    s[0..index].reverse();
+
     output.push_str(str::from_utf8(&s[0..index]).unwrap());
 }
 
diff --git a/src/librustc_data_structures/bitslice.rs b/src/librustc_data_structures/bitslice.rs
index b8f191c2f57..a63033c4365 100644
--- a/src/librustc_data_structures/bitslice.rs
+++ b/src/librustc_data_structures/bitslice.rs
@@ -75,7 +75,7 @@ fn bit_lookup(bit: usize) -> BitLookup {
     let word = bit / word_bits;
     let bit_in_word = bit % word_bits;
     let bit_mask = 1 << bit_in_word;
-    BitLookup { word: word, bit_in_word: bit_in_word, bit_mask: bit_mask }
+    BitLookup { word, bit_in_word, bit_mask }
 }
 
 pub fn bits_to_string(words: &[Word], bits: usize) -> String {
@@ -105,7 +105,8 @@ pub fn bits_to_string(words: &[Word], bits: usize) -> String {
         sep = '|';
     }
     result.push(']');
-    return result
+
+    result
 }
 
 #[inline]
diff --git a/src/librustc_data_structures/bitvec.rs b/src/librustc_data_structures/bitvec.rs
index 6e8a45d0342..49ab3e58812 100644
--- a/src/librustc_data_structures/bitvec.rs
+++ b/src/librustc_data_structures/bitvec.rs
@@ -196,7 +196,8 @@ impl<'a, C: Idx> Iterator for BitIter<'a, C> {
         self.current >>= offset;
         self.current >>= 1; // shift otherwise overflows for 0b1000_0000_…_0000
         self.idx += offset + 1;
-        return Some(C::new(self.idx - 1));
+
+        Some(C::new(self.idx - 1))
     }
 
     fn size_hint(&self) -> (usize, Option<usize>) {
@@ -299,7 +300,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
             let v1 = vector[write_index];
             let v2 = v1 | vector[read_index];
             vector[write_index] = v2;
-            changed = changed | (v1 != v2);
+            changed |= v1 != v2;
         }
         changed
     }
diff --git a/src/librustc_data_structures/flock.rs b/src/librustc_data_structures/flock.rs
index ff1ebb11b72..3f248dadb66 100644
--- a/src/librustc_data_structures/flock.rs
+++ b/src/librustc_data_structures/flock.rs
@@ -254,8 +254,8 @@ mod imp {
     type ULONG_PTR = usize;
 
     type LPOVERLAPPED = *mut OVERLAPPED;
-    const LOCKFILE_EXCLUSIVE_LOCK: DWORD = 0x00000002;
-    const LOCKFILE_FAIL_IMMEDIATELY: DWORD = 0x00000001;
+    const LOCKFILE_EXCLUSIVE_LOCK: DWORD = 0x0000_0002;
+    const LOCKFILE_FAIL_IMMEDIATELY: DWORD = 0x0000_0001;
 
     const FILE_SHARE_DELETE: DWORD = 0x4;
     const FILE_SHARE_READ: DWORD = 0x1;
diff --git a/src/librustc_data_structures/graph/dominators/mod.rs b/src/librustc_data_structures/graph/dominators/mod.rs
index d134fad2855..e54147cbe7c 100644
--- a/src/librustc_data_structures/graph/dominators/mod.rs
+++ b/src/librustc_data_structures/graph/dominators/mod.rs
@@ -107,7 +107,8 @@ fn intersect<Node: Idx>(
             node2 = immediate_dominators[node2].unwrap();
         }
     }
-    return node1;
+
+    node1
 }
 
 #[derive(Clone, Debug)]
diff --git a/src/librustc_data_structures/graph/implementation/mod.rs b/src/librustc_data_structures/graph/implementation/mod.rs
index cf9403db658..baac7565868 100644
--- a/src/librustc_data_structures/graph/implementation/mod.rs
+++ b/src/librustc_data_structures/graph/implementation/mod.rs
@@ -90,7 +90,7 @@ pub const INCOMING: Direction = Direction { repr: 1 };
 
 impl NodeIndex {
     /// Returns unique id (unique with respect to the graph holding associated node).
-    pub fn node_id(&self) -> usize {
+    pub fn node_id(self) -> usize {
         self.0
     }
 }
@@ -187,7 +187,7 @@ impl<N: Debug, E: Debug> Graph<N, E> {
         self.nodes[source.0].first_edge[OUTGOING.repr] = idx;
         self.nodes[target.0].first_edge[INCOMING.repr] = idx;
 
-        return idx;
+        idx
     }
 
     pub fn edge(&self, idx: EdgeIndex) -> &Edge<E> {
@@ -261,8 +261,8 @@ impl<N: Debug, E: Debug> Graph<N, E> {
         DepthFirstTraversal::with_start_node(self, start, direction)
     }
 
-    pub fn nodes_in_postorder<'a>(
-        &'a self,
+    pub fn nodes_in_postorder(
+        &self,
         direction: Direction,
         entry_node: NodeIndex,
     ) -> Vec<NodeIndex> {
diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs
index 2e95a45479c..340fe057096 100644
--- a/src/librustc_data_structures/indexed_set.rs
+++ b/src/librustc_data_structures/indexed_set.rs
@@ -59,16 +59,13 @@ impl<T: Idx> rustc_serialize::Decodable for IdxSetBuf<T> {
 
 // pnkfelix wants to have this be `IdxSet<T>([Word]) and then pass
 // around `&mut IdxSet<T>` or `&IdxSet<T>`.
-//
-// WARNING: Mapping a `&IdxSetBuf<T>` to `&IdxSet<T>` (at least today)
-// requires a transmute relying on representation guarantees that may
-// not hold in the future.
 
 /// Represents a set (or packed family of sets), of some element type
 /// E, where each E is identified by some unique index type `T`.
 ///
 /// In other words, `T` is the type used to index into the bitslice
 /// this type uses to represent the set of object it holds.
+#[repr(transparent)]
 pub struct IdxSet<T: Idx> {
     _pd: PhantomData<fn(&T)>,
     bits: [Word],
@@ -134,11 +131,11 @@ impl<T: Idx> IdxSetBuf<T> {
 
 impl<T: Idx> IdxSet<T> {
     unsafe fn from_slice(s: &[Word]) -> &Self {
-        mem::transmute(s) // (see above WARNING)
+        &*(s as *const [Word] as *const Self)
     }
 
     unsafe fn from_slice_mut(s: &mut [Word]) -> &mut Self {
-        mem::transmute(s) // (see above WARNING)
+        &mut *(s as *mut [Word] as *mut Self)
     }
 }
 
diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs
index 0d6cf260dcd..7ef88852685 100644
--- a/src/librustc_data_structures/obligation_forest/mod.rs
+++ b/src/librustc_data_structures/obligation_forest/mod.rs
@@ -573,7 +573,7 @@ impl<O: ForestObligation> ObligationForest<O> {
         }
 
         let mut kill_list = vec![];
-        for (predicate, index) in self.waiting_cache.iter_mut() {
+        for (predicate, index) in &mut self.waiting_cache {
             let new_index = node_rewrites[index.get()];
             if new_index >= nodes_len {
                 kill_list.push(predicate.clone());
diff --git a/src/librustc_data_structures/snapshot_map/mod.rs b/src/librustc_data_structures/snapshot_map/mod.rs
index 6ee8c3579f5..5030bf98dff 100644
--- a/src/librustc_data_structures/snapshot_map/mod.rs
+++ b/src/librustc_data_structures/snapshot_map/mod.rs
@@ -92,7 +92,7 @@ impl<K, V> SnapshotMap<K, V>
     pub fn snapshot(&mut self) -> Snapshot {
         self.undo_log.push(UndoLog::OpenSnapshot);
         let len = self.undo_log.len() - 1;
-        Snapshot { len: len }
+        Snapshot { len }
     }
 
     fn assert_open_snapshot(&self, snapshot: &Snapshot) {
@@ -103,8 +103,8 @@ impl<K, V> SnapshotMap<K, V>
         });
     }
 
-    pub fn commit(&mut self, snapshot: Snapshot) {
-        self.assert_open_snapshot(&snapshot);
+    pub fn commit(&mut self, snapshot: &Snapshot) {
+        self.assert_open_snapshot(snapshot);
         if snapshot.len == 0 {
             // The root snapshot.
             self.undo_log.truncate(0);
@@ -135,8 +135,8 @@ impl<K, V> SnapshotMap<K, V>
         }
     }
 
-    pub fn rollback_to(&mut self, snapshot: Snapshot) {
-        self.assert_open_snapshot(&snapshot);
+    pub fn rollback_to(&mut self, snapshot: &Snapshot) {
+        self.assert_open_snapshot(snapshot);
         while self.undo_log.len() > snapshot.len + 1 {
             let entry = self.undo_log.pop().unwrap();
             self.reverse(entry);
diff --git a/src/librustc_data_structures/snapshot_map/test.rs b/src/librustc_data_structures/snapshot_map/test.rs
index 4114082839b..b163e0fe420 100644
--- a/src/librustc_data_structures/snapshot_map/test.rs
+++ b/src/librustc_data_structures/snapshot_map/test.rs
@@ -20,7 +20,7 @@ fn basic() {
     map.insert(44, "fourty-four");
     assert_eq!(map[&44], "fourty-four");
     assert_eq!(map.get(&33), None);
-    map.rollback_to(snapshot);
+    map.rollback_to(&snapshot);
     assert_eq!(map[&22], "twenty-two");
     assert_eq!(map.get(&33), None);
     assert_eq!(map.get(&44), None);
@@ -33,7 +33,7 @@ fn out_of_order() {
     map.insert(22, "twenty-two");
     let snapshot1 = map.snapshot();
     let _snapshot2 = map.snapshot();
-    map.rollback_to(snapshot1);
+    map.rollback_to(&snapshot1);
 }
 
 #[test]
@@ -43,8 +43,8 @@ fn nested_commit_then_rollback() {
     let snapshot1 = map.snapshot();
     let snapshot2 = map.snapshot();
     map.insert(22, "thirty-three");
-    map.commit(snapshot2);
+    map.commit(&snapshot2);
     assert_eq!(map[&22], "thirty-three");
-    map.rollback_to(snapshot1);
+    map.rollback_to(&snapshot1);
     assert_eq!(map[&22], "twenty-two");
 }
diff --git a/src/librustc_data_structures/tiny_list.rs b/src/librustc_data_structures/tiny_list.rs
index c12fc22baf0..e1bfdf35b27 100644
--- a/src/librustc_data_structures/tiny_list.rs
+++ b/src/librustc_data_structures/tiny_list.rs
@@ -107,7 +107,8 @@ impl<T: PartialEq> Element<T> {
         };
 
         self.next = new_next;
-        return true
+
+        true
     }
 
     fn len(&self) -> usize {
diff --git a/src/librustc_data_structures/transitive_relation.rs b/src/librustc_data_structures/transitive_relation.rs
index a8124fb7c5b..18a1e9129b3 100644
--- a/src/librustc_data_structures/transitive_relation.rs
+++ b/src/librustc_data_structures/transitive_relation.rs
@@ -77,7 +77,7 @@ impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
             ..
         } = self;
 
-        map.entry(a.clone())
+        *map.entry(a.clone())
            .or_insert_with(|| {
                elements.push(a);
 
@@ -86,7 +86,6 @@ impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
 
                Index(elements.len() - 1)
            })
-           .clone()
     }
 
     /// Applies the (partial) function to each edge and returns a new
@@ -98,14 +97,12 @@ impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
     {
         let mut result = TransitiveRelation::new();
         for edge in &self.edges {
-            let r = f(&self.elements[edge.source.0]).and_then(|source| {
+            f(&self.elements[edge.source.0]).and_then(|source| {
                 f(&self.elements[edge.target.0]).and_then(|target| {
-                    Some(result.add(source, target))
+                    result.add(source, target);
+                    Some(())
                 })
-            });
-            if r.is_none() {
-                return None;
-            }
+            })?;
         }
         Some(result)
     }
@@ -372,7 +369,7 @@ impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
         let mut changed = true;
         while changed {
             changed = false;
-            for edge in self.edges.iter() {
+            for edge in &self.edges {
                 // add an edge from S -> T
                 changed |= matrix.add(edge.source.0, edge.target.0);