Open
Description
When writing tests for custom allocators, I ran into the problem that an allocation-induced panic is not captured properly by should_panic. This is in my opinion a bug, as the behaviour the test shows is still very much like a panic.
Example code to trigger the issue:
use core::alloc::Layout;
use alloc::alloc::handle_alloc_error
#[test]
#[should_panic]
fn sample_test() {
let layout = Layout::new::<u64>();
handle_alloc_error(layout);
}
this uses an explicit call to handle_alloc_error, but the actual test cases I am writing create Vectors with a custom allocator that limits the amount of memory that can be allocated, which is a more realistic use case.
Meta
rustc --version --verbose
:
rustc 1.83.0-nightly (9c01301c5 2024-09-05)
binary: rustc
commit-hash: 9c01301c52df5d2d7b6fe337707a74e011d68d6f
commit-date: 2024-09-05
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status