summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/const-unsafe-fn.rs
blob: 72ce73f745f4ed1c0a3433c5a3afc1855be1f874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// run-pass
#![allow(dead_code)]
// A quick test of 'unsafe const fn' functionality

const unsafe fn dummy(v: u32) -> u32 {
    !v
}

struct Type;
impl Type {
    const unsafe fn new() -> Type {
        Type
    }
}

const VAL: u32 = unsafe { dummy(0xFFFF) };
const TYPE_INST: Type = unsafe { Type::new() };

fn main() {
    assert_eq!(VAL, 0xFFFF0000);
}