diff options
| author | bors <bors@rust-lang.org> | 2020-12-04 20:07:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-12-04 20:07:04 +0000 |
| commit | 3ff10e74a74ed093fcabac1de27fe1cd65bbbb4a (patch) | |
| tree | 13efed968ba1fcd1ca8a4ceeb2fdd3c5297863ae /src/test/ui/allocator | |
| parent | 2218520b8adf8b8e64b817537d9eb0a84840e2f1 (diff) | |
| parent | 9274b37d99f608e5fde569788ee79bd72fc3cf13 (diff) | |
| download | rust-3ff10e74a74ed093fcabac1de27fe1cd65bbbb4a.tar.gz rust-3ff10e74a74ed093fcabac1de27fe1cd65bbbb4a.zip | |
Auto merge of #79286 - TimDiekmann:rename-allocref, r=Lokathor,Wodann,m-ou-se
Rename `AllocRef` to `Allocator` and `(de)alloc` to `(de)allocate` Calling `Box::alloc_ref` and `Vec::alloc_ref` sounds like allocating a reference. To solve this ambiguity, this renames `AllocRef` to `Allocator` and `alloc` to `allocate`. For a more detailed explaination see https://github.com/rust-lang/wg-allocators/issues/76. closes https://github.com/rust-lang/wg-allocators/issues/76 r? `@KodrAus` `@rustbot` modify labels: +A-allocators +T-libs `@rustbot` ping wg-allocators
Diffstat (limited to 'src/test/ui/allocator')
| -rw-r--r-- | src/test/ui/allocator/custom.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/allocator/xcrate-use.rs | 10 |
2 files changed, 12 insertions, 13 deletions
diff --git a/src/test/ui/allocator/custom.rs b/src/test/ui/allocator/custom.rs index dfb5d3e9e38..10cbc23c427 100644 --- a/src/test/ui/allocator/custom.rs +++ b/src/test/ui/allocator/custom.rs @@ -8,9 +8,8 @@ extern crate helper; -use std::alloc::{self, AllocRef, Global, Layout, System}; +use std::alloc::{self, Allocator, Global, Layout, System}; use std::sync::atomic::{AtomicUsize, Ordering}; -use std::ptr::NonNull; static HITS: AtomicUsize = AtomicUsize::new(0); @@ -24,7 +23,7 @@ unsafe impl alloc::GlobalAlloc for A { unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { HITS.fetch_add(1, Ordering::SeqCst); - AllocRef::dealloc(&System, NonNull::new(ptr).unwrap(), layout) + alloc::GlobalAlloc::dealloc(&System, ptr, layout) } } @@ -39,10 +38,10 @@ fn main() { unsafe { let layout = Layout::from_size_align(4, 2).unwrap(); - let memory = Global.alloc(layout.clone()).unwrap(); + let memory = Global.allocate(layout.clone()).unwrap(); helper::work_with(&memory); assert_eq!(HITS.load(Ordering::SeqCst), n + 1); - Global.dealloc(memory.as_non_null_ptr(), layout); + Global.deallocate(memory.as_non_null_ptr(), layout); assert_eq!(HITS.load(Ordering::SeqCst), n + 2); let s = String::with_capacity(10); @@ -51,10 +50,10 @@ fn main() { drop(s); assert_eq!(HITS.load(Ordering::SeqCst), n + 4); - let memory = System.alloc(layout.clone()).unwrap(); - assert_eq!(HITS.load(Ordering::SeqCst), n + 4); + let memory = System.allocate(layout.clone()).unwrap(); helper::work_with(&memory); - System.dealloc(memory.as_non_null_ptr(), layout); + assert_eq!(HITS.load(Ordering::SeqCst), n + 4); + System.deallocate(memory.as_non_null_ptr(), layout); assert_eq!(HITS.load(Ordering::SeqCst), n + 4); } } diff --git a/src/test/ui/allocator/xcrate-use.rs b/src/test/ui/allocator/xcrate-use.rs index a1446b3664d..edd4df75e8b 100644 --- a/src/test/ui/allocator/xcrate-use.rs +++ b/src/test/ui/allocator/xcrate-use.rs @@ -10,7 +10,7 @@ extern crate custom; extern crate helper; -use std::alloc::{AllocRef, Global, Layout, System}; +use std::alloc::{Allocator, Global, Layout, System}; use std::sync::atomic::{AtomicUsize, Ordering}; #[global_allocator] @@ -21,16 +21,16 @@ fn main() { let n = GLOBAL.0.load(Ordering::SeqCst); let layout = Layout::from_size_align(4, 2).unwrap(); - let memory = Global.alloc(layout.clone()).unwrap(); + let memory = Global.allocate(layout.clone()).unwrap(); helper::work_with(&memory); assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 1); - Global.dealloc(memory.as_non_null_ptr(), layout); + Global.deallocate(memory.as_non_null_ptr(), layout); assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); - let memory = System.alloc(layout.clone()).unwrap(); + let memory = System.allocate(layout.clone()).unwrap(); assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); helper::work_with(&memory); - System.dealloc(memory.as_non_null_ptr(), layout); + System.deallocate(memory.as_non_null_ptr(), layout); assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); } } |
