@@ -12,7 +12,7 @@ use crate::ptr;
12
12
13
13
/// When dropped, copies from `src` into `dest`.
14
14
struct CopyOnDrop < T > {
15
- src : * mut T ,
15
+ src : * const T ,
16
16
dest : * mut T ,
17
17
}
18
18
54
54
// Read the first element into a stack-allocated variable. If a following comparison
55
55
// operation panics, `hole` will get dropped and automatically write the element back
56
56
// into the slice.
57
- let mut tmp = mem:: ManuallyDrop :: new ( ptr:: read ( v. get_unchecked ( 0 ) ) ) ;
57
+ let tmp = mem:: ManuallyDrop :: new ( ptr:: read ( v. get_unchecked ( 0 ) ) ) ;
58
58
let v = v. as_mut_ptr ( ) ;
59
- let mut hole = CopyOnDrop { src : & mut * tmp, dest : v. add ( 1 ) } ;
59
+ let mut hole = CopyOnDrop { src : & * tmp, dest : v. add ( 1 ) } ;
60
60
ptr:: copy_nonoverlapping ( v. add ( 1 ) , v. add ( 0 ) , 1 ) ;
61
61
62
62
for i in 2 ..len {
@@ -100,9 +100,9 @@ where
100
100
// Read the last element into a stack-allocated variable. If a following comparison
101
101
// operation panics, `hole` will get dropped and automatically write the element back
102
102
// into the slice.
103
- let mut tmp = mem:: ManuallyDrop :: new ( ptr:: read ( v. get_unchecked ( len - 1 ) ) ) ;
103
+ let tmp = mem:: ManuallyDrop :: new ( ptr:: read ( v. get_unchecked ( len - 1 ) ) ) ;
104
104
let v = v. as_mut_ptr ( ) ;
105
- let mut hole = CopyOnDrop { src : & mut * tmp, dest : v. add ( len - 2 ) } ;
105
+ let mut hole = CopyOnDrop { src : & * tmp, dest : v. add ( len - 2 ) } ;
106
106
ptr:: copy_nonoverlapping ( v. add ( len - 2 ) , v. add ( len - 1 ) , 1 ) ;
107
107
108
108
for i in ( 0 ..len - 2 ) . rev ( ) {
@@ -498,8 +498,8 @@ where
498
498
// operation panics, the pivot will be automatically written back into the slice.
499
499
500
500
// SAFETY: `pivot` is a reference to the first element of `v`, so `ptr::read` is safe.
501
- let mut tmp = mem:: ManuallyDrop :: new ( unsafe { ptr:: read ( pivot) } ) ;
502
- let _pivot_guard = CopyOnDrop { src : & mut * tmp, dest : pivot } ;
501
+ let tmp = mem:: ManuallyDrop :: new ( unsafe { ptr:: read ( pivot) } ) ;
502
+ let _pivot_guard = CopyOnDrop { src : & * tmp, dest : pivot } ;
503
503
let pivot = & * tmp;
504
504
505
505
// Find the first pair of out-of-order elements.
@@ -551,8 +551,8 @@ where
551
551
// Read the pivot into a stack-allocated variable for efficiency. If a following comparison
552
552
// operation panics, the pivot will be automatically written back into the slice.
553
553
// SAFETY: The pointer here is valid because it is obtained from a reference to a slice.
554
- let mut tmp = mem:: ManuallyDrop :: new ( unsafe { ptr:: read ( pivot) } ) ;
555
- let _pivot_guard = CopyOnDrop { src : & mut * tmp, dest : pivot } ;
554
+ let tmp = mem:: ManuallyDrop :: new ( unsafe { ptr:: read ( pivot) } ) ;
555
+ let _pivot_guard = CopyOnDrop { src : & * tmp, dest : pivot } ;
556
556
let pivot = & * tmp;
557
557
558
558
// Now partition the slice.
0 commit comments