mirror of https://github.com/rust-lang/rust
21 lines
402 B
Rust
21 lines
402 B
Rust
//@ run-pass
|
|
#![feature(core_intrinsics)]
|
|
#![feature(const_heap)]
|
|
use std::intrinsics;
|
|
|
|
const FOO: &i32 = foo();
|
|
const FOO_RAW: *const i32 = foo();
|
|
|
|
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() {
|
|
assert_eq!(*FOO, 20);
|
|
assert_eq!(unsafe { *FOO_RAW }, 20);
|
|
}
|