Skip to content

Commit ffdac5d

Browse files
committed
Make SnapshotMap::{commit, rollback_to} take references
1 parent 76b69a6 commit ffdac5d

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/librustc/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
709709

710710
self.projection_cache
711711
.borrow_mut()
712-
.commit(projection_cache_snapshot);
712+
.commit(&projection_cache_snapshot);
713713
self.type_variables
714714
.borrow_mut()
715715
.commit(type_snapshot);

src/librustc/traits/project.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,15 +1668,15 @@ impl<'tcx> ProjectionCache<'tcx> {
16681668
}
16691669

16701670
pub fn rollback_to(&mut self, snapshot: ProjectionCacheSnapshot) {
1671-
self.map.rollback_to(snapshot.snapshot);
1671+
self.map.rollback_to(&snapshot.snapshot);
16721672
}
16731673

16741674
pub fn rollback_skolemized(&mut self, snapshot: &ProjectionCacheSnapshot) {
16751675
self.map.partial_rollback(&snapshot.snapshot, &|k| k.ty.has_re_skol());
16761676
}
16771677

1678-
pub fn commit(&mut self, snapshot: ProjectionCacheSnapshot) {
1679-
self.map.commit(snapshot.snapshot);
1678+
pub fn commit(&mut self, snapshot: &ProjectionCacheSnapshot) {
1679+
self.map.commit(&snapshot.snapshot);
16801680
}
16811681

16821682
/// Try to start normalize `key`; returns an error if

src/librustc_data_structures/snapshot_map/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<K, V> SnapshotMap<K, V>
9292
pub fn snapshot(&mut self) -> Snapshot {
9393
self.undo_log.push(UndoLog::OpenSnapshot);
9494
let len = self.undo_log.len() - 1;
95-
Snapshot { len: len }
95+
Snapshot { len }
9696
}
9797

9898
fn assert_open_snapshot(&self, snapshot: &Snapshot) {
@@ -103,8 +103,8 @@ impl<K, V> SnapshotMap<K, V>
103103
});
104104
}
105105

106-
pub fn commit(&mut self, snapshot: Snapshot) {
107-
self.assert_open_snapshot(&snapshot);
106+
pub fn commit(&mut self, snapshot: &Snapshot) {
107+
self.assert_open_snapshot(snapshot);
108108
if snapshot.len == 0 {
109109
// The root snapshot.
110110
self.undo_log.truncate(0);
@@ -135,8 +135,8 @@ impl<K, V> SnapshotMap<K, V>
135135
}
136136
}
137137

138-
pub fn rollback_to(&mut self, snapshot: Snapshot) {
139-
self.assert_open_snapshot(&snapshot);
138+
pub fn rollback_to(&mut self, snapshot: &Snapshot) {
139+
self.assert_open_snapshot(snapshot);
140140
while self.undo_log.len() > snapshot.len + 1 {
141141
let entry = self.undo_log.pop().unwrap();
142142
self.reverse(entry);

src/librustc_data_structures/snapshot_map/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn basic() {
2020
map.insert(44, "fourty-four");
2121
assert_eq!(map[&44], "fourty-four");
2222
assert_eq!(map.get(&33), None);
23-
map.rollback_to(snapshot);
23+
map.rollback_to(&snapshot);
2424
assert_eq!(map[&22], "twenty-two");
2525
assert_eq!(map.get(&33), None);
2626
assert_eq!(map.get(&44), None);
@@ -33,7 +33,7 @@ fn out_of_order() {
3333
map.insert(22, "twenty-two");
3434
let snapshot1 = map.snapshot();
3535
let _snapshot2 = map.snapshot();
36-
map.rollback_to(snapshot1);
36+
map.rollback_to(&snapshot1);
3737
}
3838

3939
#[test]
@@ -43,8 +43,8 @@ fn nested_commit_then_rollback() {
4343
let snapshot1 = map.snapshot();
4444
let snapshot2 = map.snapshot();
4545
map.insert(22, "thirty-three");
46-
map.commit(snapshot2);
46+
map.commit(&snapshot2);
4747
assert_eq!(map[&22], "thirty-three");
48-
map.rollback_to(snapshot1);
48+
map.rollback_to(&snapshot1);
4949
assert_eq!(map[&22], "twenty-two");
5050
}

0 commit comments

Comments
 (0)