Skip to content

Commit

Permalink
Auto merge of #1859 - RalfJung:global-system-mixup, r=RalfJung
Browse files Browse the repository at this point in the history
add test for mixing up System and Global memory
  • Loading branch information
bors committed Jul 25, 2021
2 parents eb9e307 + 24fa9de commit e445f78
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/compile-fail/alloc/global_system_mixup.rs
Original file line number Diff line number Diff line change
@@ -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); }
}

0 comments on commit e445f78

Please sign in to comment.