rust-analyzer: `expand_expr` not being expanded.

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.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

That would undermine most of salsa given we introduce an untracked input, I’d rather not we go through hacks to support this. We should instead ask for removing this feature entirely as I absolutely hate it, or the more reasonable ask, have proc-macros require marking themselves as being eager.