]> git.lizzy.rs Git - rust.git/blob - src/test/ui/allocator-submodule.rs
Auto merge of #57119 - jethrogb:jb/sgx-os-mod2, r=joshtriplett
[rust.git] / src / test / ui / allocator-submodule.rs
1 // Tests that it is possible to create a global allocator in a submodule, rather than in the crate
2 // root.
3
4 #![feature(alloc, allocator_api, global_allocator)]
5
6 extern crate alloc;
7
8 use std::{
9     alloc::{GlobalAlloc, Layout},
10     ptr,
11 };
12
13 struct MyAlloc;
14
15 unsafe impl GlobalAlloc for MyAlloc {
16     unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
17         ptr::null_mut()
18     }
19
20     unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {}
21 }
22
23 mod submod {
24     use super::MyAlloc;
25
26     #[global_allocator]
27     static MY_HEAP: MyAlloc = MyAlloc; //~ ERROR global_allocator
28 }
29
30 fn main() {}