3 #![feature(asm, global_asm, repr_simd, never_type)]
6 struct SimdNonCopy(f32, f32, f32, f32);
10 // Inputs must be initialized
13 asm!("{}", in(reg) x);
14 //~^ ERROR use of possibly-uninitialized variable: `x`
16 asm!("{}", inout(reg) y);
17 //~^ ERROR use of possibly-uninitialized variable: `y`
20 // Outputs require mutable places
22 let v: Vec<u64> = vec![0, 1, 2];
23 asm!("{}", in(reg) v[0]);
24 asm!("{}", out(reg) v[0]);
25 //~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable
26 asm!("{}", inout(reg) v[0]);
27 //~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable
29 // Const operands must be integer or floats, and must be constants.
32 asm!("{}", const 0i32);
33 asm!("{}", const 0f32);
34 asm!("{}", const 0 as *mut u8);
35 //~^ ERROR asm `const` arguments must be integer or floating-point values
37 // This currently causes an ICE: https://github.com/rust-lang/rust/issues/81857
38 // asm!("{}", const &0);
39 // ERROR asm `const` arguments must be integer or floating-point values
41 // Sym operands must point to a function or static
48 //~^ ERROR asm `sym` operand must point to a fn or static
50 //~^ ERROR asm `sym` operand must point to a fn or static
52 // Register operands must be Copy
54 asm!("{}", in(xmm_reg) SimdNonCopy(0.0, 0.0, 0.0, 0.0));
55 //~^ ERROR arguments for inline assembly must be copyable
57 // Register operands must be integers, floats, SIMD vectors, pointers or
60 asm!("{}", in(reg) 0i64);
61 asm!("{}", in(reg) 0f64);
62 asm!("{}", in(xmm_reg) std::arch::x86_64::_mm_setzero_ps());
63 asm!("{}", in(reg) 0 as *const u8);
64 asm!("{}", in(reg) 0 as *mut u8);
65 asm!("{}", in(reg) main as fn());
66 asm!("{}", in(reg) |x: i32| x);
67 //~^ ERROR cannot use value of type
68 asm!("{}", in(reg) vec![0]);
69 //~^ ERROR cannot use value of type `Vec<i32>` for inline assembly
70 asm!("{}", in(reg) (1, 2, 3));
71 //~^ ERROR cannot use value of type `(i32, i32, i32)` for inline assembly
72 asm!("{}", in(reg) [1, 2, 3]);
73 //~^ ERROR cannot use value of type `[i32; 3]` for inline assembly
75 // Register inputs (but not outputs) allow references and function types
79 asm!("{}", in(reg) f);
80 asm!("{}", inout(reg) f);
81 //~^ ERROR cannot use value of type `fn() {main}` for inline assembly
82 asm!("{}", in(reg) r);
83 asm!("{}", inout(reg) r);
84 //~^ ERROR cannot use value of type `&mut i32` for inline assembly
87 // Type checks ignore never type
89 let u: ! = unreachable!();
90 asm!("{}", in(reg) u);
94 // Const operands must be integer or floats, and must be constants.
96 global_asm!("{}", const 0);
97 global_asm!("{}", const 0i32);
98 global_asm!("{}", const 0f32);
99 global_asm!("{}", const 0 as *mut u8);
100 //~^ ERROR asm `const` arguments must be integer or floating-point values