]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/alloc/global_system_mixup.rs
Auto merge of #100865 - compiler-errors:parent-substs-still, r=cjgillot
[rust.git] / src / tools / miri / tests / fail / alloc / global_system_mixup.rs
1 // Make sure we detect when the `Global` and `System` allocators are mixed
2 // (even when the default `Global` uses `System`).
3 //@error-pattern: /deallocating .*, which is Rust heap memory, using .* heap deallocation operation/
4
5 //@normalize-stderr-test: "using [A-Za-z]+ heap deallocation operation" -> "using PLATFORM heap deallocation operation"
6 //@normalize-stderr-test: "\| +\^+" -> "| ^"
7 //@normalize-stderr-test: "libc::free\([^()]*\)|unsafe \{ HeapFree\([^()]*\) \};" -> "FREE();"
8
9 #![feature(allocator_api, slice_ptr_get)]
10
11 use std::alloc::{Allocator, Global, Layout, System};
12
13 fn main() {
14     let l = Layout::from_size_align(1, 1).unwrap();
15     let ptr = Global.allocate(l).unwrap().as_non_null_ptr();
16     unsafe {
17         System.deallocate(ptr, l);
18     }
19 }