If there are any errors when executing a proc-macro, rust-analyzer will fail on all proc macros until I restart VSCode, even when the macro should work. It gives the error "proc-macro server did not respond with data." It seems that maybe any panic while expanding a proc-macro causes the server to crash and not restart?
rust-analyzer version: Version 0.3.2078, Server Version 0.3.2078-standalone (fa0032624 2024-08-17)
Here is a minimal example using the proc macro subenum:
use subenum::subenum;
#[subenum(A)]
pub enum SomeEnum {
#[subenum(A, B)]
A,
B,
}
The code will fail because the subenum B is specified in the variant attribute, but not in the enum attribute. Rust-analyzer displays the correct error message from the proc macro.
Fix the code by removing B from the variant attribute:
use subenum::subenum;
#[subenum(A)]
pub enum SomeEnum {
#[subenum(A)]
A,
B,
}
This code should now compile. You can confirm this from the terminal with a cargo check.
However, rust-analyzer now fails on the proc-macro again, this time with the message "proc-macro server did not respond with data."
The only way to get rid of this error is to restart VSCode, after which rust-analyzer will handle the macro just fine.
If there are any errors when executing a proc-macro, rust-analyzer will fail on all proc macros until I restart VSCode, even when the macro should work. It gives the error "proc-macro server did not respond with data." It seems that maybe any panic while expanding a proc-macro causes the server to crash and not restart?
rust-analyzer version: Version 0.3.2078, Server Version 0.3.2078-standalone (fa0032624 2024-08-17)
rustc version: rustc 1.78.0 (9b00956e5 2024-04-29)
editor or extension: VSCode, extension version v0.3.2078. I primarily use MacOS, but have seen the same problem on Ubuntu.
relevant settings: I have rust-analyzer set to run on every save, here is my
.vscode/settings.json
:steps to reproduce:
Here is a minimal example using the proc macro subenum:
The code will fail because the subenum
B
is specified in the variant attribute, but not in the enum attribute. Rust-analyzer displays the correct error message from the proc macro.Fix the code by removing
B
from the variant attribute:This code should now compile. You can confirm this from the terminal with a
cargo check
.However, rust-analyzer now fails on the proc-macro again, this time with the message "proc-macro server did not respond with data."
The only way to get rid of this error is to restart VSCode, after which rust-analyzer will handle the macro just fine.