]> git.lizzy.rs Git - rust.git/commitdiff
removing &mut self for other methods of AllocRef
authorblitzerr <rusty.blitzerr@gmail.com>
Tue, 22 Sep 2020 13:22:02 +0000 (06:22 -0700)
committerblitzerr <rusty.blitzerr@gmail.com>
Tue, 22 Sep 2020 13:22:02 +0000 (06:22 -0700)
library/alloc/src/alloc.rs
library/alloc/src/raw_vec.rs
library/alloc/src/raw_vec/tests.rs
library/alloc/tests/heap.rs
library/core/src/alloc/mod.rs
library/std/src/alloc.rs

index 7d872b1a66bb9a294335ea61bf748de0077b2554..462bcd15fa9415e9e20c15fa2c0bf7d188bd12ce 100644 (file)
@@ -213,12 +213,12 @@ fn alloc(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
     }
 
     #[inline]
-    fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
+    fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
         self.alloc_impl(layout, true)
     }
 
     #[inline]
-    unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
+    unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
         if layout.size() != 0 {
             // SAFETY: `layout` is non-zero in size,
             // other conditions must be upheld by the caller
index 62675665f037f39da3c680db2e7338f6fdc83071..5b4a4957f6cb1f63f8b842851864a70ee6a2ba5a 100644 (file)
@@ -169,7 +169,7 @@ pub fn with_capacity_zeroed_in(capacity: usize, alloc: A) -> Self {
         Self::allocate_in(capacity, AllocInit::Zeroed, alloc)
     }
 
-    fn allocate_in(capacity: usize, init: AllocInit, mut alloc: A) -> Self {
+    fn allocate_in(capacity: usize, init: AllocInit, alloc: A) -> Self {
         if mem::size_of::<T>() == 0 {
             Self::new_in(alloc)
         } else {
index 2ed9d3685c69ff9cb8e4037cccf909437629e060..e4c8b3709dfeeb9809d998747a40625579ba1038 100644 (file)
@@ -34,7 +34,7 @@ fn alloc(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
                 err @ Err(_) => err,
             }
         }
-        unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
+        unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
             unsafe { Global.dealloc(ptr, layout) }
         }
     }
index cbde2a7e28e8f134004678ecd8b64478c27f4943..a7239a4b14fae82bf92be0ae533f98ccc148bd79 100644 (file)
@@ -11,7 +11,7 @@ fn std_heap_overaligned_request() {
     check_overalign_requests(Global)
 }
 
-fn check_overalign_requests<T: AllocRef>(mut allocator: T) {
+fn check_overalign_requests<T: AllocRef>(allocator: T) {
     for &align in &[4, 8, 16, 32] {
         // less than and bigger than `MIN_ALIGN`
         for &size in &[align / 2, align - 1] {
index b7dd249d093610798cbfac533da152224b4458bc..5f9092fe7037e45d2a2584d75b7a963001826acb 100644 (file)
@@ -126,7 +126,7 @@ pub unsafe trait AllocRef {
     /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar.
     ///
     /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
-    fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
+    fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
         let ptr = self.alloc(layout)?;
         // SAFETY: `alloc` returns a valid memory block
         unsafe { ptr.as_non_null_ptr().as_ptr().write_bytes(0, ptr.len()) }
@@ -142,7 +142,7 @@ fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
     ///
     /// [*currently allocated*]: #currently-allocated-memory
     /// [*fit*]: #memory-fitting
-    unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout);
+    unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout);
 
     /// Attempts to extend the memory block.
     ///
@@ -353,12 +353,12 @@ fn alloc(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
     }
 
     #[inline]
-    fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
+    fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
         (**self).alloc_zeroed(layout)
     }
 
     #[inline]
-    unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
+    unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
         // SAFETY: the safety contract must be upheld by the caller
         unsafe { (**self).dealloc(ptr, layout) }
     }
index 86ae4cf4dd213109112158dd0fc5cb6697da0766..f41aa28b5ecb546927dba5c8929beff71481994b 100644 (file)
@@ -207,12 +207,12 @@ fn alloc(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
     }
 
     #[inline]
-    fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
+    fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr> {
         self.alloc_impl(layout, true)
     }
 
     #[inline]
-    unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
+    unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
         if layout.size() != 0 {
             // SAFETY: `layout` is non-zero in size,
             // other conditions must be upheld by the caller