fannheyward / coc-rust-analyzer

rust-analyzer extension for coc.nvim
MIT License
1.13k stars 40 forks source link

`unresolved-proc-macro` at `tokio::main` #1016

Closed paulkre closed 2 years ago

paulkre commented 2 years ago

I'm getting this error at the #[tokio::main] macro:

Screenshot 2022-07-08 at 20 34 48

This should already be fixed (https://github.com/rust-lang/rust-analyzer/issues/12450) but I'm still getting the error even after running :CocUpdate.

fannheyward commented 2 years ago

What's your :CocCommand rust-analyzer.serverVersion output?

paulkre commented 2 years ago

rust-analyzer 0.0.0 (5342f47f4 2022-07-09)

fannheyward commented 2 years ago

Tested with code in https://github.com/rust-lang/rust-analyzer/issues/12450, can't reproduce

use std::error::Error;

fn main() {
    // do_something_async is a non-async function that blocks on the tokio runtime
    // It returns a plain Result
    // Rust Analyzer thinks do_something_async returns a Future and puts a red squiggle here
    // but it compiles without errors
    let x: Result<_,_> = do_something_async();
    println!("async result is {:?}",x);
}

#[tokio::main]
async fn do_something_async() -> Result<(), Box<dyn Error + Send + Sync>> {
    println!("async stuff goes here...");
    Ok(())
}
截屏2022-07-11 17 53 56

coc-rust-analyzer 0.65.2 and rust-analyzer 0.0.0 (5342f47f4 2022-07-09)

paulkre commented 2 years ago

Could this be a problem with the fact that I'm using an arm64 system? This is the full error message:

[rust-analyzer unresolved-proc-macro] [E] proc macro `main` not expanded:
    2  Cannot create expander for ...
    3  target/debug/deps/libtokio_macros-7a64d8cf37bb7726.dylib: Io(Custom { kind:
    4  InvalidData, error: DlOpen { desc: "dlopen(...
    5  .../target/debug/deps/libtokio_macros-7a64d8cf37bb7726.dylib, 0x000A):
    6  tried: \'.../target/debug/deps/
    7  libtokio_macros-7a64d8cf37bb7726.dylib\' (mach-o file, but is an incompatible
    8  architecture (have \'arm64\', need \'x86_64\'))" } })
fannheyward commented 2 years ago

It's rust-analyzer's issue.

paulkre commented 2 years ago

It works fine using VSCode though.