diff options
Diffstat (limited to 'src/test/ui/missing/missing-alloc_error_handler.rs')
-rw-r--r-- | src/test/ui/missing/missing-alloc_error_handler.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/missing/missing-alloc_error_handler.rs b/src/test/ui/missing/missing-alloc_error_handler.rs new file mode 100644 index 000000000..4d378f010 --- /dev/null +++ b/src/test/ui/missing/missing-alloc_error_handler.rs @@ -0,0 +1,23 @@ +// compile-flags: -C panic=abort +// no-prefer-dynamic + +#![no_std] +#![crate_type = "staticlib"] +#![feature(alloc_error_handler)] + +#[panic_handler] +fn panic(_: &core::panic::PanicInfo) -> ! { + loop {} +} + +extern crate alloc; + +#[global_allocator] +static A: MyAlloc = MyAlloc; + +struct MyAlloc; + +unsafe impl core::alloc::GlobalAlloc for MyAlloc { + unsafe fn alloc(&self, _: core::alloc::Layout) -> *mut u8 { 0 as _ } + unsafe fn dealloc(&self, _: *mut u8, _: core::alloc::Layout) {} +} |