about summary refs log tree commit diff
path: root/tests/ui/lto/lto-global-allocator.rs
blob: 03f11709c901add20fd4bc385822f3f6816deee2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//@ compile-flags: --crate-type cdylib -C lto
//@ build-pass
//@ no-prefer-dynamic
//@ needs-crate-type: cdylib

use std::alloc::{GlobalAlloc, Layout};

struct MyAllocator;

unsafe impl GlobalAlloc for MyAllocator {
    unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
        todo!()
    }

    unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
}

#[global_allocator]
static GLOBAL: MyAllocator = MyAllocator;