Search code examples
rustrust-proc-macrosrust-analyzer

Proc macro "main" not expanded + Rust-analyzer not spawning server


I join these two questions in one, as they maybe are related. A few days ago, I started having this error in the [#actix_rt::main] line, before the main function:

proc macro `main` not expanded: cannot find proc-macro server in sysroot `C:\Users\zerok\.rustup\toolchains\stable-x86_64-pc-windows-gnu`

At the same time, in VSCode my rust-analyzer extension started failing. I uninstalled it, restarted VSCode, and reinstalled. It keeps giving the same error over and over:

Failed to spawn one or more proc-macro servers.

How can I fix this problem?


Solution

  • Soon after posting the question, I finally found out how to install the toolchain, which seems to have fixed both errors:

    rustup toolchain install stable-x86_64-pc-windows-gnu
    

    After that, I clicked on the rust-analyzer box on the bottom of VSCode, clicked in "Restart Server", and everything worked after the command completion.