summaryrefslogtreecommitdiffstats
path: root/src/test/ui/asm/generic-const.rs
blob: 55c5587804b322059b20f95c1d562059c7a61f2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// needs-asm-support
// build-pass

#![feature(asm_const, asm_sym)]

use std::arch::asm;

fn foofoo<const N: usize>() {}

unsafe fn foo<const N: usize>() {
    asm!("/* {0} */", const N);
    asm!("/* {0} */", const N + 1);
    asm!("/* {0} */", sym foofoo::<N>);
}

fn barbar<T>() {}

unsafe fn bar<T>() {
    asm!("/* {0} */", const std::mem::size_of::<T>());
    asm!("/* {0} */", const std::mem::size_of::<(T, T)>());
    asm!("/* {0} */", sym barbar::<T>);
    asm!("/* {0} */", sym barbar::<(T, T)>);
}

fn main() {
    unsafe {
        foo::<0>();
        bar::<usize>();
    }
}