rust/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs
2023-01-11 09:32:08 +00:00

19 lines
377 B
Rust

#![feature(core_intrinsics)]
#![feature(const_heap)]
#![feature(const_mut_refs)]
use std::intrinsics;
const FOO: *const i32 = foo();
//~^ ERROR untyped pointers are not allowed in constant
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() {
}