about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-08-26 10:44:28 +0000
committerbors <bors@rust-lang.org>2020-08-26 10:44:28 +0000
commitffd59bf9c62125813abae8ca52f0ac3a67459e8f (patch)
treed1a8f37e58737dbbb54db765ae03a1b2af79d984 /src
parent2fe9a33659641d062c1fe3577327147b4d9943a2 (diff)
parent46b547cb5861febd3e0401acb0af6f65be775948 (diff)
downloadrust-ffd59bf9c62125813abae8ca52f0ac3a67459e8f.tar.gz
rust-ffd59bf9c62125813abae8ca52f0ac3a67459e8f.zip
Auto merge of #75687 - TimDiekmann:realloc-align, r=Amanieu
Allow reallocation to different alignment in `AllocRef`

The allocator-wg [has decided](https://github.com/rust-lang/wg-allocators/issues/5#issuecomment-672591112) to support reallocating to a different alignment in `AllocRef`. For more details please see the linked issue.

r? @Amanieu

closes https://github.com/rust-lang/wg-allocators/issues/5
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/realloc-16687.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/test/ui/realloc-16687.rs b/src/test/ui/realloc-16687.rs
index bdcd47a7260..2e07fdcbe83 100644
--- a/src/test/ui/realloc-16687.rs
+++ b/src/test/ui/realloc-16687.rs
@@ -48,7 +48,7 @@ unsafe fn test_triangle() -> bool {
             println!("allocate({:?}) = {:?}", layout, ptr);
         }
 
-        ptr.as_non_null_ptr().as_ptr()
+        ptr.as_mut_ptr()
     }
 
     unsafe fn deallocate(ptr: *mut u8, layout: Layout) {
@@ -65,23 +65,17 @@ unsafe fn test_triangle() -> bool {
         }
 
         let memory = if new.size() > old.size() {
-            Global.grow(
-                NonNull::new_unchecked(ptr),
-                old,
-                new.size(),
-            )
+            Global.grow(NonNull::new_unchecked(ptr), old, new)
         } else {
-            Global.shrink(NonNull::new_unchecked(ptr), old, new.size())
+            Global.shrink(NonNull::new_unchecked(ptr), old, new)
         };
 
-        let ptr = memory.unwrap_or_else(|_| {
-            handle_alloc_error(Layout::from_size_align_unchecked(new.size(), old.align()))
-        });
+        let ptr = memory.unwrap_or_else(|_| handle_alloc_error(new));
 
         if PRINT {
             println!("reallocate({:?}, old={:?}, new={:?}) = {:?}", ptr, old, new, ptr);
         }
-        ptr.as_non_null_ptr().as_ptr()
+        ptr.as_mut_ptr()
     }
 
     fn idx_to_size(i: usize) -> usize {