]> git.lizzy.rs Git - rust.git/blob - tests/ui/box/large-allocator-ice.rs
Rollup merge of #107306 - compiler-errors:correct-sugg-for-closure-arg-needs-borrow...
[rust.git] / tests / ui / box / large-allocator-ice.rs
1 // build-pass
2 #![feature(allocator_api)]
3 #![allow(unused_must_use)]
4
5 use std::alloc::Allocator;
6
7 struct BigAllocator([usize; 2]);
8
9 unsafe impl Allocator for BigAllocator {
10     fn allocate(
11         &self,
12         _: std::alloc::Layout,
13     ) -> Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError> {
14         todo!()
15     }
16     unsafe fn deallocate(&self, _: std::ptr::NonNull<u8>, _: std::alloc::Layout) {
17         todo!()
18     }
19 }
20
21 fn main() {
22     Box::new_in((), &std::alloc::Global);
23     Box::new_in((), BigAllocator([0; 2]));
24     generic_function(0);
25 }
26
27 fn generic_function<T>(val: T) {
28     *Box::new_in(val, &std::alloc::Global);
29 }