Understanding Rust Error E0660

Introduction to Rust Error E0660

Rust Error E0660 is related to the llvm_asm macro which was used to inject LLVM assembly directly into the Rust code. The error occurs when the argument to the macro is not well-formed. Note that this error code is no longer emitted by the Rust compiler, as the llvm_asm macro has been replaced by the asm macro.

Erroneous Example

Consider the following Rust code example that would trigger Error E0660:

llvm_asm!("nop" "nop");

This example erroneously joins two assembly instructions together without using a delimiter to separate them.

Using the asm Macro

As of Rust 1.45, the llvm_asm macro has been deprecated and replaced by the asm macro. The asm macro can be used to write inline assembly as follows:

asm!("nop; nop");

Here, two no-operation (NOP) instructions are included in the assembly code.

The asm! Constraint Specifiers

The asm! macro allows you to use constraint specifiers to ensure proper input, output, and clobbering. Consider the following example:

fn add(a: i32, b: i32) -> i32 {
    let c: i32;
    unsafe {
        asm!("add {0}, {1}", out(reg) c, in(reg) a, in(reg) b);

In this example, an add function adds two integers using inline assembly. The asm! macro takes an assembly template string and a set of constraint specifiers for the input and output values.


Rust Error E0660 specifically refers to an ill-formed llvm_asm macro argument. As the llvm_asm macro is deprecated, use the asm macro for inline assembly. Remember to use constraint specifiers to ensure proper input, output, and clobbering when using the asm! macro.