Auto merge of #1859 - RalfJung:global-system-mixup, r=RalfJung
add test for mixing up System and Global memory
This commit is contained in:
commit
e445f78951
1 changed files with 13 additions and 0 deletions
13
tests/compile-fail/alloc/global_system_mixup.rs
Normal file
13
tests/compile-fail/alloc/global_system_mixup.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// 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
|
||||
|
||||
#![feature(allocator_api, slice_ptr_get)]
|
||||
|
||||
use std::alloc::{Allocator, Global, System, Layout};
|
||||
|
||||
fn main() {
|
||||
let l = Layout::from_size_align(1, 1).unwrap();
|
||||
let ptr = Global.allocate(l).unwrap().as_non_null_ptr();
|
||||
unsafe { System.deallocate(ptr, l); }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue