-#![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));
}
}