diff options
| author | Ralf Jung <post@ralfj.de> | 2022-06-18 07:38:28 -0700 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-06-18 07:38:28 -0700 |
| commit | b05d71f880b77b4c9202b73dd9f6127409452f19 (patch) | |
| tree | eae96ef5ffcaea47685797bd41ae6d7a6023650a | |
| parent | 7952205bc8b8c890bca12430e75cc3173d49cb52 (diff) | |
| download | rust-b05d71f880b77b4c9202b73dd9f6127409452f19.tar.gz rust-b05d71f880b77b4c9202b73dd9f6127409452f19.zip | |
make std not use &A: Allocator instance
| -rw-r--r-- | library/std/src/alloc.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index d3879273f5b..d554ec59035 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -187,7 +187,7 @@ impl System { old_size => unsafe { let new_ptr = self.alloc_impl(new_layout, zeroed)?; ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), old_size); - Allocator::deallocate(&self, ptr, old_layout); + Allocator::deallocate(self, ptr, old_layout); Ok(new_ptr) }, } @@ -254,7 +254,7 @@ unsafe impl Allocator for System { match new_layout.size() { // SAFETY: conditions must be upheld by the caller 0 => unsafe { - Allocator::deallocate(&self, ptr, old_layout); + Allocator::deallocate(self, ptr, old_layout); Ok(NonNull::slice_from_raw_parts(new_layout.dangling(), 0)) }, @@ -274,9 +274,9 @@ unsafe impl Allocator for System { // `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract // for `dealloc` must be upheld by the caller. new_size => unsafe { - let new_ptr = Allocator::allocate(&self, new_layout)?; + let new_ptr = Allocator::allocate(self, new_layout)?; ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), new_size); - Allocator::deallocate(&self, ptr, old_layout); + Allocator::deallocate(self, ptr, old_layout); Ok(new_ptr) }, } |
