Rust Analyzer in VSCode: "Cannot create expander" for macros error Unsupported metadata version 10

I'm using a couple of Rust macros in a relatively simple Rust CLI application. First, the tokio::main macro, and secondly, the strum::Display and strum::EnumIter macros. The former allows my main function to be async, and the latter two allow me to convert enum variants to/from string values, to provide user interaction.

  • Windows 11
  • Rust beta toolchain 1.88.0-beta.6 (873a06493 2025-05-10)
  • VSCode 1.101.1
  • Rust Analyzer extension for VSCode 0.3.2500

I'm getting an error on the code blocks that are utilizing macros, the main function definition, and the enum definition.

I can build and run the application perfectly fine, using cargo run.

I used the Rust-Analyzer: Restart Server option in VSCode, and that seems to have cleared up the issue for now. Is this a common issue that other people have come across, and shouldn't the extension be able to resolve this error without manually restarting it?

Does anyone know why I would get these errors in the first place?

NOTE: I am NOT doing any cross-compilation. I am either building natively on Windows 11 or using Docker Desktop to build a Linux (WSL2) container image, but that's it. There's no cross-compilation with the Rust toolchain.

tokio::main: Cannot create expander for ...\target\debug\deps\tokio_macros-cf9cdf6be2c8bed0.dll: unsupported metadata version 10
Cannot create expander for ...\target\debug\deps\strum_macros-509b7d3669cad3f0.dll: unsupported metadata version 10

#[tokio::main]
async fn main() {
    loop {
        let _ = select_function().await;
    }
} 

#[derive(strum::Display, EnumIter)]
enum UserOperation {
    #[strum(to_string = "Category 1: Operation 01")]
    Cat1Op1,
    #[strum(to_string = "Category 1: Operation 02")]
    Cat1Op2,
}

Is it possible that you were using 1.87 stable (or older) when you started rust-analyzer and then switched to 1.88 beta without restarting rust-analyzer? Each rustc version has an associated rust-analyzer-proc-macro-server which rust-analyzer likely didn't restart when you switched the rustc version. Normally the error message would indicate both the version with which the proc macro was compiled and the version of rust-analyzer-proc-macro-server itself. As it turns out 1.88 bumped the version of the crate metadata header [1], making the 1.87 rust-analyzer-proc-macro-server unable to read the rustc version from the proc macro, hence giving a worse error.


  1. This was done in Introduce `-Zembed-metadata` to allow omitting full metadata from rlibs and dylibs by Kobzol · Pull Request #137535 · rust-lang/rust · GitHub ↩︎

1 Like

Yes, that is quite possible. I can't exactly recall the steps I performed, but I think I switched Rust toolchains in a separate terminal window outside of VSCode. Perhaps that "confused" Rust Analyzer, for lack of better term.

Thanks for the pointer about rust-analyzer-proc-macro-server. I am not sure what that is at the moment, but at least it gives me something to research a bit more deeply.

The ABI of proc-macros is unstable, but rust-analyzer needs to work across multiple rustc versions. To get this to work, rust-analyzer-proc-macro-server is a binary bundled with rustc which loads proc-macros with the exact same ABI as the associated rustc version produces. This binary then exposes a versioned json interface. Rust-analyzer supports multiple versions of this json interface at the same time. And changes to the proc-macro ABI often don't need changes to the json interface.