about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2018-11-05 10:37:23 +1100
committerNicholas Nethercote <nnethercote@mozilla.com>2018-11-25 17:54:06 +1100
commitf5624e41e819bb85408eba7b3abd550f61a2857a (patch)
tree400fe865828ee33380988c0c14527784857ba7db /src/librustc_data_structures
parent7fe09a6551b72133e68911f3125f28642ec243ac (diff)
downloadrust-f5624e41e819bb85408eba7b3abd550f61a2857a.tar.gz
rust-f5624e41e819bb85408eba7b3abd550f61a2857a.zip
Make `commit` and `rollback_to` methods take ownership of the snapshots.
Because they shouldn't be reused. This provides consistency with the
`ena` crate.
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/snapshot_map/mod.rs8
-rw-r--r--src/librustc_data_structures/snapshot_map/test.rs8
2 files changed, 8 insertions, 8 deletions
diff --git a/src/librustc_data_structures/snapshot_map/mod.rs b/src/librustc_data_structures/snapshot_map/mod.rs
index 6ad886625d8..8b761bdc8c6 100644
--- a/src/librustc_data_structures/snapshot_map/mod.rs
+++ b/src/librustc_data_structures/snapshot_map/mod.rs
@@ -102,8 +102,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.clear();
@@ -134,8 +134,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 700f9c95e3b..67be806261b 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");
 }