Skip to content

expand_expr not being expanded. #19759

@vivax3794

Description

@vivax3794

rust-analyzer version: 1.88.0-nightly (27d6200 2025-05-06)
rustc version: rustc 1.88.0-nightly (27d6200a7 2025-05-06)

editor or extension: rustaceanvim on version 5.26.0

code snippet to reproduce:
A proc macro using the nightly expand_expr feature

#![feature(proc_macro_expand)]

extern crate proc_macro;

#[proc_macro]
pub fn expand(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
    let input = input.expand_expr().unwrap();
    panic!("expanded input: {input}");
}

when using this macro:

the_macro::expand!(concat!("Hello, ", "world!"));

cargo check (and its corresponding) diagnostic produces expanded input: "Hello, world!", but rust analyzer also produces its own error: proc-macro panicked: expanded input: concat ! ("Hello, " , "world!") [macro-error]

In addition, it seems the macro is not expanded at all in this case by RA, leading to items emitted by said macro to not be available in completions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions