rust/tests/ui/consts/const-unsafe-fn.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
356 B
Rust
Raw Normal View History

// run-pass
#![allow(dead_code)]
2015-10-03 10:42:22 -05:00
// A quick test of 'unsafe const fn' functionality
const unsafe fn dummy(v: u32) -> u32 {
2015-10-03 10:42:22 -05:00
!v
}
struct Type;
impl Type {
const unsafe fn new() -> Type {
2015-10-03 10:42:22 -05:00
Type
}
}
const VAL: u32 = unsafe { dummy(0xFFFF) };
const TYPE_INST: Type = unsafe { Type::new() };
fn main() {
assert_eq!(VAL, 0xFFFF0000);
}