]> 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 e11df0eb4147d842a69617bf74405b4331b4fd77..67312b0d96ddac13e670d216d89a1208afbc6a39 100644 (file)
@@ -1,16 +1,11 @@
-#![feature(alloc, allocator_api)]
+use std::alloc::{alloc, dealloc, Layout};
 
-extern crate alloc;
-
-use alloc::heap::Heap;
-use alloc::allocator::*;
-
-// error-pattern: tried to deallocate dangling pointer
+// error-pattern: dereferenced after this allocation got freed
 
 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));
     }
 }