6 #![feature(asm_const, asm_sym)]
8 use std::arch::{asm, global_asm};
12 // Outputs must be place expressions
14 asm!("{}", in(reg) 1 + 2);
15 asm!("{}", out(reg) 1 + 2);
16 //~^ ERROR invalid asm output
17 asm!("{}", inout(reg) 1 + 2);
18 //~^ ERROR invalid asm output
20 // Operands must be sized
22 let v: [u64; 3] = [0, 1, 2];
23 asm!("{}", in(reg) v[..]);
24 //~^ ERROR the size for values of type `[u64]` cannot be known at compilation time
25 //~| ERROR cannot use value of type `[u64]` for inline assembly
26 asm!("{}", out(reg) v[..]);
27 //~^ ERROR the size for values of type `[u64]` cannot be known at compilation time
28 //~| ERROR cannot use value of type `[u64]` for inline assembly
29 asm!("{}", inout(reg) v[..]);
30 //~^ ERROR the size for values of type `[u64]` cannot be known at compilation time
31 //~| ERROR cannot use value of type `[u64]` for inline assembly
33 // Constants must be... constant
36 const fn const_foo(x: i32) -> i32 {
39 const fn const_bar<T>(x: T) -> T {
43 //~^ ERROR attempt to use a non-constant value in a constant
44 asm!("{}", const const_foo(0));
45 asm!("{}", const const_foo(x));
46 //~^ ERROR attempt to use a non-constant value in a constant
47 asm!("{}", const const_bar(0));
48 asm!("{}", const const_bar(x));
49 //~^ ERROR attempt to use a non-constant value in a constant
51 //~^ ERROR invalid `sym` operand
53 // Const operands must be integers and must be constants.
56 asm!("{}", const 0i32);
57 asm!("{}", const 0i128);
58 asm!("{}", const 0f32);
59 //~^ ERROR mismatched types
60 asm!("{}", const 0 as *mut u8);
61 //~^ ERROR mismatched types
63 //~^ ERROR mismatched types
67 unsafe fn generic<T>() {
68 asm!("{}", sym generic::<T>);
71 // Const operands must be integers and must be constants.
73 global_asm!("{}", const 0);
74 global_asm!("{}", const 0i32);
75 global_asm!("{}", const 0i128);
76 global_asm!("{}", const 0f32);
77 //~^ ERROR mismatched types
78 global_asm!("{}", const 0 as *mut u8);
79 //~^ ERROR mismatched types