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)
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 Item
unresolved-proc-macro
and press OK.Source for this solution was found here .
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.