My main
function is decorated with two proc macros like this:
#[paw::main]
#[tokio::main]
pub async fn main(args: Args) -> Result<()>
This compiles and runs as I expect it but VS code's rust-analyzer
gives me this error on both lines of attribute macros #[paw::main]
and #[tokio::main]
. The error message is:
proc macro `main` not expanded: proc macro not found rust-analyzer (unresolved-proc-macro)
Judging by this GitHub issue, and in particular this comment, it seems that proc macro expansion is quite dependent on the version of the Rust compiler. The suggested fix is to keep your rust-analyzer updated. Switching to the pre-release version of rust-analyzer fixed this for me on rustc 1.61, which is the latest stable in time of writing. Presumably the pre-release version of rust-analyzer is always most likely to be ABI-compatible with the latest stable version of rustc.