about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/alloc/no_global_allocator.rs
blob: f76aebaa3e37ebfcd1fcf37282c18ddeb519fc92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//@compile-flags: -Cpanic=abort
//@normalize-stderr-test: "OS `.*`" -> "$$OS"
// Make sure we pretend the allocation symbols don't exist when there is no allocator

#![no_std]
#![no_main]

extern "Rust" {
    fn __rust_alloc(size: usize, align: usize) -> *mut u8;
}

#[no_mangle]
fn miri_start(_argc: isize, _argv: *const *const u8) -> isize {
    unsafe {
        __rust_alloc(1, 1); //~ERROR: unsupported operation: can't call foreign function `__rust_alloc`
    }

    0
}

#[panic_handler]
fn panic_handler(_: &core::panic::PanicInfo) -> ! {
    loop {}
}