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.
There might be a better way, but this will make the error go away:
rust-analyzer > Diagnostics: Disabled. You can search for "rust analyzer diagnostics" to find this option.Add Itemunresolved-proc-macro and press OK.Source for this solution was found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With