2 #![feature(allocator_api)]
3 #![allow(unused_must_use)]
5 use std::alloc::Allocator;
7 struct BigAllocator([usize; 2]);
9 unsafe impl Allocator for BigAllocator {
12 _: std::alloc::Layout,
13 ) -> Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError> {
16 unsafe fn deallocate(&self, _: std::ptr::NonNull<u8>, _: std::alloc::Layout) {
22 Box::new_in((), &std::alloc::Global);
23 Box::new_in((), BigAllocator([0; 2]));
27 fn generic_function<T>(val: T) {
28 *Box::new_in(val, &std::alloc::Global);