Skip to content

Commit e445f78

Browse files
committed
Auto merge of #1859 - RalfJung:global-system-mixup, r=RalfJung
add test for mixing up System and Global memory
2 parents eb9e307 + 24fa9de commit e445f78

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Make sure we detect when the `Global` and `System` allocators are mixed
2+
// (even when the default `Global` uses `System`).
3+
// error-pattern: which is Rust heap memory, using
4+
5+
#![feature(allocator_api, slice_ptr_get)]
6+
7+
use std::alloc::{Allocator, Global, System, Layout};
8+
9+
fn main() {
10+
let l = Layout::from_size_align(1, 1).unwrap();
11+
let ptr = Global.allocate(l).unwrap().as_non_null_ptr();
12+
unsafe { System.deallocate(ptr, l); }
13+
}

0 commit comments

Comments
 (0)