summaryrefslogtreecommitdiffstats
path: root/tests/ui/allocator
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/allocator
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/ui/allocator/allocator-args.rs (renamed from src/test/ui/allocator/allocator-args.rs)0
-rw-r--r--tests/ui/allocator/allocator-args.stderr (renamed from src/test/ui/allocator/allocator-args.stderr)0
-rw-r--r--tests/ui/allocator/auxiliary/custom-as-global.rs (renamed from src/test/ui/allocator/auxiliary/custom-as-global.rs)0
-rw-r--r--tests/ui/allocator/auxiliary/custom.rs (renamed from src/test/ui/allocator/auxiliary/custom.rs)0
-rw-r--r--tests/ui/allocator/auxiliary/helper.rs (renamed from src/test/ui/allocator/auxiliary/helper.rs)0
-rw-r--r--tests/ui/allocator/auxiliary/system-allocator.rs (renamed from src/test/ui/allocator/auxiliary/system-allocator.rs)0
-rw-r--r--tests/ui/allocator/auxiliary/system-allocator2.rs (renamed from src/test/ui/allocator/auxiliary/system-allocator2.rs)0
-rw-r--r--tests/ui/allocator/custom-in-block.rs (renamed from src/test/ui/allocator/custom-in-block.rs)0
-rw-r--r--tests/ui/allocator/custom-in-submodule.rs (renamed from src/test/ui/allocator/custom-in-submodule.rs)0
-rw-r--r--tests/ui/allocator/custom.rs (renamed from src/test/ui/allocator/custom.rs)0
-rw-r--r--tests/ui/allocator/function-allocator.rs (renamed from src/test/ui/allocator/function-allocator.rs)0
-rw-r--r--tests/ui/allocator/function-allocator.stderr (renamed from src/test/ui/allocator/function-allocator.stderr)0
-rw-r--r--tests/ui/allocator/hygiene.rs (renamed from src/test/ui/allocator/hygiene.rs)0
-rw-r--r--tests/ui/allocator/no_std-alloc-error-handler-custom.rs84
-rw-r--r--tests/ui/allocator/no_std-alloc-error-handler-default.rs71
-rw-r--r--tests/ui/allocator/not-an-allocator.rs (renamed from src/test/ui/allocator/not-an-allocator.rs)0
-rw-r--r--tests/ui/allocator/not-an-allocator.stderr (renamed from src/test/ui/allocator/not-an-allocator.stderr)0
-rw-r--r--tests/ui/allocator/object-safe.rs (renamed from src/test/ui/allocator/object-safe.rs)0
-rw-r--r--tests/ui/allocator/two-allocators.rs (renamed from src/test/ui/allocator/two-allocators.rs)0
-rw-r--r--tests/ui/allocator/two-allocators.stderr (renamed from src/test/ui/allocator/two-allocators.stderr)0
-rw-r--r--tests/ui/allocator/two-allocators2.rs (renamed from src/test/ui/allocator/two-allocators2.rs)0
-rw-r--r--tests/ui/allocator/two-allocators2.stderr (renamed from src/test/ui/allocator/two-allocators2.stderr)0
-rw-r--r--tests/ui/allocator/two-allocators3.rs (renamed from src/test/ui/allocator/two-allocators3.rs)0
-rw-r--r--tests/ui/allocator/two-allocators3.stderr (renamed from src/test/ui/allocator/two-allocators3.stderr)0
-rw-r--r--tests/ui/allocator/xcrate-use.rs (renamed from src/test/ui/allocator/xcrate-use.rs)0
-rw-r--r--tests/ui/allocator/xcrate-use2.rs (renamed from src/test/ui/allocator/xcrate-use2.rs)0
26 files changed, 155 insertions, 0 deletions
diff --git a/src/test/ui/allocator/allocator-args.rs b/tests/ui/allocator/allocator-args.rs
index 1033f947c..1033f947c 100644
--- a/src/test/ui/allocator/allocator-args.rs
+++ b/tests/ui/allocator/allocator-args.rs
diff --git a/src/test/ui/allocator/allocator-args.stderr b/tests/ui/allocator/allocator-args.stderr
index dfff2a7e7..dfff2a7e7 100644
--- a/src/test/ui/allocator/allocator-args.stderr
+++ b/tests/ui/allocator/allocator-args.stderr
diff --git a/src/test/ui/allocator/auxiliary/custom-as-global.rs b/tests/ui/allocator/auxiliary/custom-as-global.rs
index a5e96e775..a5e96e775 100644
--- a/src/test/ui/allocator/auxiliary/custom-as-global.rs
+++ b/tests/ui/allocator/auxiliary/custom-as-global.rs
diff --git a/src/test/ui/allocator/auxiliary/custom.rs b/tests/ui/allocator/auxiliary/custom.rs
index b0ec9ab09..b0ec9ab09 100644
--- a/src/test/ui/allocator/auxiliary/custom.rs
+++ b/tests/ui/allocator/auxiliary/custom.rs
diff --git a/src/test/ui/allocator/auxiliary/helper.rs b/tests/ui/allocator/auxiliary/helper.rs
index 008fb3501..008fb3501 100644
--- a/src/test/ui/allocator/auxiliary/helper.rs
+++ b/tests/ui/allocator/auxiliary/helper.rs
diff --git a/src/test/ui/allocator/auxiliary/system-allocator.rs b/tests/ui/allocator/auxiliary/system-allocator.rs
index 97b86bbc9..97b86bbc9 100644
--- a/src/test/ui/allocator/auxiliary/system-allocator.rs
+++ b/tests/ui/allocator/auxiliary/system-allocator.rs
diff --git a/src/test/ui/allocator/auxiliary/system-allocator2.rs b/tests/ui/allocator/auxiliary/system-allocator2.rs
index 97b86bbc9..97b86bbc9 100644
--- a/src/test/ui/allocator/auxiliary/system-allocator2.rs
+++ b/tests/ui/allocator/auxiliary/system-allocator2.rs
diff --git a/src/test/ui/allocator/custom-in-block.rs b/tests/ui/allocator/custom-in-block.rs
index 12813a1fc..12813a1fc 100644
--- a/src/test/ui/allocator/custom-in-block.rs
+++ b/tests/ui/allocator/custom-in-block.rs
diff --git a/src/test/ui/allocator/custom-in-submodule.rs b/tests/ui/allocator/custom-in-submodule.rs
index ea341b1ac..ea341b1ac 100644
--- a/src/test/ui/allocator/custom-in-submodule.rs
+++ b/tests/ui/allocator/custom-in-submodule.rs
diff --git a/src/test/ui/allocator/custom.rs b/tests/ui/allocator/custom.rs
index 10cbc23c4..10cbc23c4 100644
--- a/src/test/ui/allocator/custom.rs
+++ b/tests/ui/allocator/custom.rs
diff --git a/src/test/ui/allocator/function-allocator.rs b/tests/ui/allocator/function-allocator.rs
index d53f6e9b7..d53f6e9b7 100644
--- a/src/test/ui/allocator/function-allocator.rs
+++ b/tests/ui/allocator/function-allocator.rs
diff --git a/src/test/ui/allocator/function-allocator.stderr b/tests/ui/allocator/function-allocator.stderr
index 5e47b0f0c..5e47b0f0c 100644
--- a/src/test/ui/allocator/function-allocator.stderr
+++ b/tests/ui/allocator/function-allocator.stderr
diff --git a/src/test/ui/allocator/hygiene.rs b/tests/ui/allocator/hygiene.rs
index 9bd8406a2..9bd8406a2 100644
--- a/src/test/ui/allocator/hygiene.rs
+++ b/tests/ui/allocator/hygiene.rs
diff --git a/tests/ui/allocator/no_std-alloc-error-handler-custom.rs b/tests/ui/allocator/no_std-alloc-error-handler-custom.rs
new file mode 100644
index 000000000..289262433
--- /dev/null
+++ b/tests/ui/allocator/no_std-alloc-error-handler-custom.rs
@@ -0,0 +1,84 @@
+// run-pass
+// ignore-android no libc
+// ignore-emscripten no libc
+// ignore-sgx no libc
+// ignore-wasm32 no libc
+// only-linux
+// compile-flags:-C panic=abort
+// aux-build:helper.rs
+
+#![feature(rustc_private, lang_items)]
+#![feature(alloc_error_handler)]
+#![no_std]
+#![no_main]
+
+extern crate alloc;
+extern crate libc;
+
+// ARM targets need these symbols
+#[no_mangle]
+pub fn __aeabi_unwind_cpp_pr0() {}
+
+#[no_mangle]
+pub fn __aeabi_unwind_cpp_pr1() {}
+
+use alloc::boxed::Box;
+use alloc::string::ToString;
+use core::alloc::{GlobalAlloc, Layout};
+use core::ptr::null_mut;
+
+extern crate helper;
+
+struct MyAllocator;
+
+#[alloc_error_handler]
+fn my_oom(layout: Layout) -> ! {
+ use alloc::fmt::write;
+ unsafe {
+ let size = layout.size();
+ let mut s = alloc::string::String::new();
+ write(&mut s, format_args!("My OOM: failed to allocate {} bytes!\n", size)).unwrap();
+ libc::write(libc::STDERR_FILENO, s.as_ptr() as *const _, s.len());
+ libc::exit(0)
+ }
+}
+
+unsafe impl GlobalAlloc for MyAllocator {
+ unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
+ if layout.size() < 4096 { libc::malloc(layout.size()) as _ } else { null_mut() }
+ }
+ unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
+}
+
+#[global_allocator]
+static A: MyAllocator = MyAllocator;
+
+#[panic_handler]
+fn panic(panic_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ let s = panic_info.to_string();
+ const PSTR: &str = "panic occurred: ";
+ const CR: &str = "\n";
+ libc::write(libc::STDERR_FILENO, PSTR.as_ptr() as *const _, PSTR.len());
+ libc::write(libc::STDERR_FILENO, s.as_ptr() as *const _, s.len());
+ libc::write(libc::STDERR_FILENO, CR.as_ptr() as *const _, CR.len());
+ libc::exit(1)
+ }
+}
+
+// Because we are compiling this code with `-C panic=abort`, this wouldn't normally be needed.
+// However, `core` and `alloc` are both compiled with `-C panic=unwind`, which means that functions
+// in these libraries will refer to `rust_eh_personality` if LLVM can not *prove* the contents won't
+// unwind. So, for this test case we will define the symbol.
+#[lang = "eh_personality"]
+extern "C" fn rust_eh_personality() {}
+
+#[derive(Default, Debug)]
+struct Page(#[allow(unused_tuple_struct_fields)] [[u64; 32]; 16]);
+
+#[no_mangle]
+fn main(_argc: i32, _argv: *const *const u8) -> isize {
+ let zero = Box::<Page>::new(Default::default());
+ helper::work_with(&zero);
+ 1
+}
diff --git a/tests/ui/allocator/no_std-alloc-error-handler-default.rs b/tests/ui/allocator/no_std-alloc-error-handler-default.rs
new file mode 100644
index 000000000..56409e713
--- /dev/null
+++ b/tests/ui/allocator/no_std-alloc-error-handler-default.rs
@@ -0,0 +1,71 @@
+// run-pass
+// ignore-android no libc
+// ignore-emscripten no libc
+// ignore-sgx no libc
+// ignore-wasm32 no libc
+// only-linux
+// compile-flags:-C panic=abort
+// aux-build:helper.rs
+
+#![feature(rustc_private, lang_items)]
+#![no_std]
+#![no_main]
+
+extern crate alloc;
+extern crate libc;
+
+// ARM targets need these symbols
+#[no_mangle]
+pub fn __aeabi_unwind_cpp_pr0() {}
+
+#[no_mangle]
+pub fn __aeabi_unwind_cpp_pr1() {}
+
+use alloc::boxed::Box;
+use alloc::string::ToString;
+use core::alloc::{GlobalAlloc, Layout};
+use core::ptr::null_mut;
+
+extern crate helper;
+
+struct MyAllocator;
+
+unsafe impl GlobalAlloc for MyAllocator {
+ unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
+ if layout.size() < 4096 { libc::malloc(layout.size()) as _ } else { null_mut() }
+ }
+ unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
+}
+
+#[global_allocator]
+static A: MyAllocator = MyAllocator;
+
+#[panic_handler]
+fn panic(panic_info: &core::panic::PanicInfo) -> ! {
+ unsafe {
+ let s = panic_info.to_string();
+ const PSTR: &str = "panic occurred: ";
+ const CR: &str = "\n";
+ libc::write(libc::STDERR_FILENO, PSTR.as_ptr() as *const _, PSTR.len());
+ libc::write(libc::STDERR_FILENO, s.as_ptr() as *const _, s.len());
+ libc::write(libc::STDERR_FILENO, CR.as_ptr() as *const _, CR.len());
+ libc::exit(0)
+ }
+}
+
+// Because we are compiling this code with `-C panic=abort`, this wouldn't normally be needed.
+// However, `core` and `alloc` are both compiled with `-C panic=unwind`, which means that functions
+// in these libraries will refer to `rust_eh_personality` if LLVM can not *prove* the contents won't
+// unwind. So, for this test case we will define the symbol.
+#[lang = "eh_personality"]
+extern "C" fn rust_eh_personality() {}
+
+#[derive(Default, Debug)]
+struct Page(#[allow(unused_tuple_struct_fields)] [[u64; 32]; 16]);
+
+#[no_mangle]
+fn main(_argc: i32, _argv: *const *const u8) -> isize {
+ let zero = Box::<Page>::new(Default::default());
+ helper::work_with(&zero);
+ 1
+}
diff --git a/src/test/ui/allocator/not-an-allocator.rs b/tests/ui/allocator/not-an-allocator.rs
index 4a538d4d0..4a538d4d0 100644
--- a/src/test/ui/allocator/not-an-allocator.rs
+++ b/tests/ui/allocator/not-an-allocator.rs
diff --git a/src/test/ui/allocator/not-an-allocator.stderr b/tests/ui/allocator/not-an-allocator.stderr
index 62bb0679f..62bb0679f 100644
--- a/src/test/ui/allocator/not-an-allocator.stderr
+++ b/tests/ui/allocator/not-an-allocator.stderr
diff --git a/src/test/ui/allocator/object-safe.rs b/tests/ui/allocator/object-safe.rs
index fae7ab7fe..fae7ab7fe 100644
--- a/src/test/ui/allocator/object-safe.rs
+++ b/tests/ui/allocator/object-safe.rs
diff --git a/src/test/ui/allocator/two-allocators.rs b/tests/ui/allocator/two-allocators.rs
index aa1291e77..aa1291e77 100644
--- a/src/test/ui/allocator/two-allocators.rs
+++ b/tests/ui/allocator/two-allocators.rs
diff --git a/src/test/ui/allocator/two-allocators.stderr b/tests/ui/allocator/two-allocators.stderr
index 7a914c2a3..7a914c2a3 100644
--- a/src/test/ui/allocator/two-allocators.stderr
+++ b/tests/ui/allocator/two-allocators.stderr
diff --git a/src/test/ui/allocator/two-allocators2.rs b/tests/ui/allocator/two-allocators2.rs
index 6dfefe19c..6dfefe19c 100644
--- a/src/test/ui/allocator/two-allocators2.rs
+++ b/tests/ui/allocator/two-allocators2.rs
diff --git a/src/test/ui/allocator/two-allocators2.stderr b/tests/ui/allocator/two-allocators2.stderr
index b1fb4421e..b1fb4421e 100644
--- a/src/test/ui/allocator/two-allocators2.stderr
+++ b/tests/ui/allocator/two-allocators2.stderr
diff --git a/src/test/ui/allocator/two-allocators3.rs b/tests/ui/allocator/two-allocators3.rs
index 31dea2d44..31dea2d44 100644
--- a/src/test/ui/allocator/two-allocators3.rs
+++ b/tests/ui/allocator/two-allocators3.rs
diff --git a/src/test/ui/allocator/two-allocators3.stderr b/tests/ui/allocator/two-allocators3.stderr
index a3079113d..a3079113d 100644
--- a/src/test/ui/allocator/two-allocators3.stderr
+++ b/tests/ui/allocator/two-allocators3.stderr
diff --git a/src/test/ui/allocator/xcrate-use.rs b/tests/ui/allocator/xcrate-use.rs
index edd4df75e..edd4df75e 100644
--- a/src/test/ui/allocator/xcrate-use.rs
+++ b/tests/ui/allocator/xcrate-use.rs
diff --git a/src/test/ui/allocator/xcrate-use2.rs b/tests/ui/allocator/xcrate-use2.rs
index d8478fb5e..d8478fb5e 100644
--- a/src/test/ui/allocator/xcrate-use2.rs
+++ b/tests/ui/allocator/xcrate-use2.rs