]> git.lizzy.rs Git - rust.git/blobdiff - tests/compile-fail/deallocate-twice.rs
Auto merge of #1308 - RalfJung:miri, r=RalfJung
[rust.git] / tests / compile-fail / deallocate-twice.rs
index 3c4399eaa3ed63e63d15ff3443bbd958fa77a0cd..67312b0d96ddac13e670d216d89a1208afbc6a39 100644 (file)
@@ -1,17 +1,11 @@
-#![feature(alloc, allocator_api)]
+use std::alloc::{alloc, dealloc, Layout};
 
-extern crate alloc;
+// error-pattern: dereferenced after this allocation got freed
 
-use alloc::heap::Heap;
-use alloc::allocator::*;
-
-// error-pattern: tried to deallocate with a pointer not to the beginning of an existing object
-
-use alloc::heap::*;
 fn main() {
     unsafe {
-        let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
-        Heap.dealloc(x, Layout::from_size_align_unchecked(1, 1));
-        Heap.dealloc(x, Layout::from_size_align_unchecked(1, 1));
+        let x = alloc(Layout::from_size_align_unchecked(1, 1));
+        dealloc(x, Layout::from_size_align_unchecked(1, 1));
+        dealloc(x, Layout::from_size_align_unchecked(1, 1));
     }
 }