]> git.lizzy.rs Git - rust.git/blob - src/test/ui/allocator-submodule.rs
Rollup merge of #60081 - pawroman:cleanup_unicode_script, r=varkor
[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 extern crate alloc;
5
6 use std::{
7     alloc::{GlobalAlloc, Layout},
8     ptr,
9 };
10
11 struct MyAlloc;
12
13 unsafe impl GlobalAlloc for MyAlloc {
14     unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
15         ptr::null_mut()
16     }
17
18     unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {}
19 }
20
21 mod submod {
22     use super::MyAlloc;
23
24     #[global_allocator]
25     static MY_HEAP: MyAlloc = MyAlloc; //~ ERROR global_allocator
26 }
27
28 fn main() {}