diff options
| author | woppopo <woppopo@protonmail.com> | 2022-01-29 19:13:23 +0900 |
|---|---|---|
| committer | woppopo <woppopo@protonmail.com> | 2022-01-29 19:13:23 +0900 |
| commit | 9728cc4e26c936e17a107ceeccf029bde4e7e1f0 (patch) | |
| tree | b9b298917679b3de25e9ee41a30ade8acd5e69c2 /src/test/ui | |
| parent | 7a7144f4136897605842886b1ca51515e75d654e (diff) | |
| download | rust-9728cc4e26c936e17a107ceeccf029bde4e7e1f0.tar.gz rust-9728cc4e26c936e17a107ceeccf029bde4e7e1f0.zip | |
Document about some behaviors of `const_(de)allocate` and add some tests.
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/consts/const-eval/heap/alloc_intrinsic_zero_sized.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/consts/const-eval/heap/dealloc_intrinsic_zero_sized.rs | 17 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_zero_sized.rs b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_zero_sized.rs new file mode 100644 index 00000000000..407e69d41a0 --- /dev/null +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_zero_sized.rs @@ -0,0 +1,16 @@ +// run-pass +#![feature(core_intrinsics)] +#![feature(const_heap)] +#![feature(inline_const)] + +use std::intrinsics; + +struct ZST; + +fn main() { + const { + unsafe { + let _ = intrinsics::const_allocate(0, 0) as *mut ZST; + } + } +} diff --git a/src/test/ui/consts/const-eval/heap/dealloc_intrinsic_zero_sized.rs b/src/test/ui/consts/const-eval/heap/dealloc_intrinsic_zero_sized.rs new file mode 100644 index 00000000000..84fb4d2ea87 --- /dev/null +++ b/src/test/ui/consts/const-eval/heap/dealloc_intrinsic_zero_sized.rs @@ -0,0 +1,17 @@ +// run-pass +#![feature(core_intrinsics)] +#![feature(const_heap)] +#![feature(inline_const)] + +use std::intrinsics; + +fn main() { + const { + unsafe { + let ptr1 = intrinsics::const_allocate(0, 0); + let ptr2 = intrinsics::const_allocate(0, 0); + intrinsics::const_deallocate(ptr1, 0, 0); + intrinsics::const_deallocate(ptr2, 0, 0); + } + } +} |
