diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-06-09 00:49:05 +0500 | 
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-06-28 17:04:16 +0500 | 
| commit | f4502b8f0eeb0e2f078745cfbbe41b5763be9449 (patch) | |
| tree | 07aa7d884f51285b618bfd1b3f7a13159a903899 /tests/ui/allocator/empty-alloc-nonnull-guarantee.rs | |
| parent | 8072811356a178dbdf8ca09b1635cfafd4661971 (diff) | |
| download | rust-f4502b8f0eeb0e2f078745cfbbe41b5763be9449.tar.gz rust-f4502b8f0eeb0e2f078745cfbbe41b5763be9449.zip | |
cleaned up some tests
Diffstat (limited to 'tests/ui/allocator/empty-alloc-nonnull-guarantee.rs')
| -rw-r--r-- | tests/ui/allocator/empty-alloc-nonnull-guarantee.rs | 18 | 
1 files changed, 18 insertions, 0 deletions
| diff --git a/tests/ui/allocator/empty-alloc-nonnull-guarantee.rs b/tests/ui/allocator/empty-alloc-nonnull-guarantee.rs new file mode 100644 index 00000000000..f4081306c77 --- /dev/null +++ b/tests/ui/allocator/empty-alloc-nonnull-guarantee.rs @@ -0,0 +1,18 @@ +//! Check that the default global Rust allocator produces non-null Box allocations for ZSTs. +//! +//! See https://github.com/rust-lang/rust/issues/11998 + +//@ run-pass + +pub fn main() { + assert!(Some(Box::new(())).is_some()); + + let xs: Box<[()]> = Box::<[(); 0]>::new([]); + assert!(Some(xs).is_some()); + + struct Foo; + assert!(Some(Box::new(Foo)).is_some()); + + let ys: Box<[Foo]> = Box::<[Foo; 0]>::new([]); + assert!(Some(ys).is_some()); +} | 
