2020-12-01 08:42:22 -06:00
|
|
|
#![feature(core_intrinsics)]
|
|
|
|
#![feature(const_heap)]
|
|
|
|
#![feature(const_mut_refs)]
|
|
|
|
use std::intrinsics;
|
|
|
|
|
2020-12-02 06:15:11 -06:00
|
|
|
const FOO: *const i32 = foo();
|
|
|
|
//~^ ERROR untyped pointers are not allowed in constant
|
2020-12-01 08:42:22 -06:00
|
|
|
|
|
|
|
const fn foo() -> &'static i32 {
|
|
|
|
let t = unsafe {
|
|
|
|
let i = intrinsics::const_allocate(4, 4) as * mut i32;
|
|
|
|
*i = 20;
|
|
|
|
i
|
|
|
|
};
|
|
|
|
unsafe { &*t }
|
|
|
|
}
|
|
|
|
fn main() {
|
|
|
|
}
|