about summary refs log tree commit diff
path: root/tests/run-make/no-alloc-shim/foo.rs
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-05-11 14:47:56 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-05-11 14:47:56 +0000
commit3082865e6c65e16fbb892ef74ff3a67a0bfc243b (patch)
treee314e8a89d5bbbb7d16f7766bb579fa5ffd6cec2 /tests/run-make/no-alloc-shim/foo.rs
parent8ace03e152957b8ce8ccbc8d0f9cbd19db4937a8 (diff)
downloadrust-3082865e6c65e16fbb892ef74ff3a67a0bfc243b.tar.gz
rust-3082865e6c65e16fbb892ef74ff3a67a0bfc243b.zip
Ignore test on MSVC for now
I can't figure out how to link with the MSVC toolchain
Diffstat (limited to 'tests/run-make/no-alloc-shim/foo.rs')
-rw-r--r--tests/run-make/no-alloc-shim/foo.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/run-make/no-alloc-shim/foo.rs b/tests/run-make/no-alloc-shim/foo.rs
new file mode 100644
index 00000000000..a3daec3db39
--- /dev/null
+++ b/tests/run-make/no-alloc-shim/foo.rs
@@ -0,0 +1,44 @@
+#![feature(default_alloc_error_handler)]
+#![no_std]
+#![no_main]
+
+extern crate alloc;
+
+use alloc::alloc::{GlobalAlloc, Layout};
+
+#[panic_handler]
+fn panic_handler(_: &core::panic::PanicInfo) -> ! {
+    loop {}
+}
+
+#[no_mangle]
+extern "C" fn rust_eh_personality() {
+    loop {}
+}
+
+#[global_allocator]
+static ALLOC: Alloc = Alloc;
+
+struct Alloc;
+
+unsafe impl GlobalAlloc for Alloc {
+    unsafe fn alloc(&self, _: Layout) -> *mut u8 {
+        core::ptr::null_mut()
+    }
+    unsafe fn dealloc(&self, _: *mut u8, _: Layout) {
+        todo!()
+    }
+}
+
+#[cfg(not(check_feature_gate))]
+#[no_mangle]
+static __rust_no_alloc_shim_is_unstable: u8 = 0;
+
+#[no_mangle]
+extern "C" fn main(_argc: usize, _argv: *const *const i8) -> i32 {
+    unsafe {
+        assert_eq!(alloc::alloc::alloc(Layout::new::<()>()), core::ptr::null_mut());
+    }
+
+    0
+}