Skip to content

Invisible delimiters after asm sym operand causes parsing errors #21582

@oxalica

Description

@oxalica

rust-analyzer version: 0.3.2711-standalone [/home/oxa/.config/VSCodium/User/globalStorage/rust-lang.rust-analyzer/rust-analyzer]

rustc version: rustc 1.93.0 (254b59607 2026-01-19)

editor or extension: VSCode

repository link (if public, optional): https://github.com/oxalica/sjlj2/blob/8c9bfbb566f7e2b72250e0d007756715056d4da2/src/lib.rs#L360

code snippet to reproduce:

The following minimized code compiles fine with rustc, but rust-analyzer emits an error.

macro_rules! m {
    ($e:expr) => {
        core::arch::asm!("/*{f}*/", f = sym $e, out("ax") _)
    };
}

fn generic<T>() {}

fn main() {
    unsafe {
        m!(generic::<i32>); 
     // ^^ invalid `_` expression, expected type `()` [rust-analyzer(typed-hole)]
    }
}

The issue occurs when the next TT after sym is a invisible-delimited group captured by macro expr specifier. I have to admit that it is technically more correct to use path specifier in this case (and then rust-analyzer will parse everything fine), but expr should work since it is also accepted by rustc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions