Skip to content

Commit 3ffd403

Browse files
committed
removing &mut self for other methods of AllocRef
1 parent 219003b commit 3ffd403

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

library/alloc/src/alloc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ unsafe impl AllocRef for Global {
213213
}
214214

215215
#[inline]
216-
fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
216+
fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
217217
self.alloc_impl(layout, true)
218218
}
219219

220220
#[inline]
221-
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
221+
unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
222222
if layout.size() != 0 {
223223
// SAFETY: `layout` is non-zero in size,
224224
// other conditions must be upheld by the caller

library/alloc/src/raw_vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
169169
Self::allocate_in(capacity, AllocInit::Zeroed, alloc)
170170
}
171171

172-
fn allocate_in(capacity: usize, init: AllocInit, mut alloc: A) -> Self {
172+
fn allocate_in(capacity: usize, init: AllocInit, alloc: A) -> Self {
173173
if mem::size_of::<T>() == 0 {
174174
Self::new_in(alloc)
175175
} else {

library/alloc/src/raw_vec/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn allocator_param() {
3434
err @ Err(_) => err,
3535
}
3636
}
37-
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
37+
unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
3838
unsafe { Global.dealloc(ptr, layout) }
3939
}
4040
}

library/alloc/tests/heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn std_heap_overaligned_request() {
1111
check_overalign_requests(Global)
1212
}
1313

14-
fn check_overalign_requests<T: AllocRef>(mut allocator: T) {
14+
fn check_overalign_requests<T: AllocRef>(allocator: T) {
1515
for &align in &[4, 8, 16, 32] {
1616
// less than and bigger than `MIN_ALIGN`
1717
for &size in &[align / 2, align - 1] {

library/core/src/alloc/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub unsafe trait AllocRef {
126126
/// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar.
127127
///
128128
/// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
129-
fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
129+
fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
130130
let ptr = self.alloc(layout)?;
131131
// SAFETY: `alloc` returns a valid memory block
132132
unsafe { ptr.as_non_null_ptr().as_ptr().write_bytes(0, ptr.len()) }
@@ -142,7 +142,7 @@ pub unsafe trait AllocRef {
142142
///
143143
/// [*currently allocated*]: #currently-allocated-memory
144144
/// [*fit*]: #memory-fitting
145-
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout);
145+
unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout);
146146

147147
/// Attempts to extend the memory block.
148148
///
@@ -353,12 +353,12 @@ where
353353
}
354354

355355
#[inline]
356-
fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
356+
fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
357357
(**self).alloc_zeroed(layout)
358358
}
359359

360360
#[inline]
361-
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
361+
unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
362362
// SAFETY: the safety contract must be upheld by the caller
363363
unsafe { (**self).dealloc(ptr, layout) }
364364
}

library/std/src/alloc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ unsafe impl AllocRef for System {
207207
}
208208

209209
#[inline]
210-
fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
210+
fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
211211
self.alloc_impl(layout, true)
212212
}
213213

214214
#[inline]
215-
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
215+
unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
216216
if layout.size() != 0 {
217217
// SAFETY: `layout` is non-zero in size,
218218
// other conditions must be upheld by the caller

0 commit comments

Comments
 (0)