-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document about some behaviors of
const_(de)allocate
and add some te…
…sts.
- Loading branch information
Showing
3 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/test/ui/consts/const-eval/heap/alloc_intrinsic_zero_sized.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/test/ui/consts/const-eval/heap/dealloc_intrinsic_zero_sized.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |