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();
|
2023-05-17 05:30:14 -05:00
|
|
|
//~^ ERROR unsupported untyped pointer in constant
|
2020-12-01 08:42:22 -06:00
|
|
|
|
|
|
|
const fn foo() -> &'static i32 {
|
|
|
|
let t = unsafe {
|
2023-05-17 05:30:14 -05:00
|
|
|
let i = intrinsics::const_allocate(4, 4) as *mut i32;
|
2020-12-01 08:42:22 -06:00
|
|
|
*i = 20;
|
|
|
|
i
|
|
|
|
};
|
|
|
|
unsafe { &*t }
|
|
|
|
}
|
|
|
|
fn main() {
|
|
|
|
}
|