]> 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 03fab76d601b57cba3399e66f9aa3770ffc5d8cd..67312b0d96ddac13e670d216d89a1208afbc6a39 100644 (file)
@@ -1,16 +1,11 @@
-#![feature(allocator_api)]
+use std::alloc::{alloc, dealloc, Layout};
 
-extern crate alloc;
-
-use alloc::alloc::Global;
-use std::alloc::*;
-
-// error-pattern: tried to deallocate dangling pointer
+// error-pattern: dereferenced after this allocation got freed
 
 fn main() {
     unsafe {
-        let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
-        Global.dealloc(x, Layout::from_size_align_unchecked(1, 1));
-        Global.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));
     }
 }