Skip to content

Commit d680e4b

Browse files
committed
---
yaml --- r: 101668 b: refs/heads/master c: 07c5e5d h: refs/heads/master v: v3
1 parent efd5793 commit d680e4b

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1b7733109d7b692c2ddd404f1bb6c751c3194750
2+
refs/heads/master: 07c5e5d81363b6cdbca64637832620ab4870d258
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
55
refs/heads/try: a97642026c18a624ff6ea01075dd9550f8ed07ff

trunk/src/libstd/util.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,16 @@ pub fn id<T>(x: T) -> T { x }
2626
pub fn swap<T>(x: &mut T, y: &mut T) {
2727
unsafe {
2828
// Give ourselves some scratch space to work with
29-
let mut tmp: T = mem::uninit();
30-
let t: *mut T = &mut tmp;
29+
let mut t: T = mem::uninit();
3130

3231
// Perform the swap, `&mut` pointers never alias
33-
let x_raw: *mut T = x;
34-
let y_raw: *mut T = y;
35-
ptr::copy_nonoverlapping_memory(t, &*x_raw, 1);
36-
ptr::copy_nonoverlapping_memory(x, &*y_raw, 1);
37-
ptr::copy_nonoverlapping_memory(y, &*t, 1);
32+
ptr::copy_nonoverlapping_memory(&mut t, &*x, 1);
33+
ptr::copy_nonoverlapping_memory(x, &*y, 1);
34+
ptr::copy_nonoverlapping_memory(y, &t, 1);
3835

3936
// y and t now point to the same thing, but we need to completely forget `tmp`
4037
// because it's no longer relevant.
41-
cast::forget(tmp);
38+
cast::forget(t);
4239
}
4340
}
4441

0 commit comments

Comments
 (0)