2021-07-25 07:33:41 -05:00
|
|
|
// Make sure we detect when the `Global` and `System` allocators are mixed
|
|
|
|
// (even when the default `Global` uses `System`).
|
|
|
|
// error-pattern: which is Rust heap memory, using
|
|
|
|
|
2022-03-17 08:49:10 -05:00
|
|
|
// normalize-stderr-test: "using [A-Za-z]+ heap deallocation operation" -> "using PLATFORM heap deallocation operation"
|
2022-05-31 18:00:14 -05:00
|
|
|
// normalize-stderr-test: "\| +\^+" -> "| ^"
|
|
|
|
// normalize-stderr-test: "libc::free\([^()]*\)|unsafe \{ HeapFree\([^()]*\) \};" -> "FREE();"
|
2022-03-17 08:49:10 -05:00
|
|
|
|
2021-07-25 07:33:41 -05:00
|
|
|
#![feature(allocator_api, slice_ptr_get)]
|
|
|
|
|
2022-06-19 22:33:59 -05:00
|
|
|
use std::alloc::{Allocator, Global, Layout, System};
|
2021-07-25 07:33:41 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let l = Layout::from_size_align(1, 1).unwrap();
|
|
|
|
let ptr = Global.allocate(l).unwrap().as_non_null_ptr();
|
2022-06-19 22:33:59 -05:00
|
|
|
unsafe {
|
|
|
|
System.deallocate(ptr, l);
|
|
|
|
}
|
2021-07-25 07:33:41 -05:00
|
|
|
}
|