0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

VSCodeのrust-analyzerで#[tokio::main]がエラーになる(proc macro `main` not expanded: no proc macro dylib present)

Posted at

はじめに

以下の書籍をやっていたところVSCode上でエラーが表示されたので解決方法についてまとめていきます

問題

以下のコードを書いたところ

main.rs
use axum::{routing::get, Router};
use std::net::SocketAddr;

#[tokio::main]
async fn main() {
    let app = Router::new().route("/", get(root));
    let addr = SocketAddr::from(([0, 0, 0, 0], 3000));

    axum::Server::bind(&addr)
        .serve(app.into_make_service())
        .await
        .unwrap();
}

async fn root() -> &'static str {
    "Hello, World!"
}

image.png

#[tokio::main]

rust-analyzerのVSCodeの拡張でエラーが表示されました

解決方法

以下の記事を読みました

これは、rust-analyzer で導入されたバグです。修正はすでにマスターにマージされています。修正プログラムはまだリリースされていません。それが本当にあなたを悩ませているなら、今のところプレリリース版に切り替えることができます

これはバグが原因であり、実行自体は問題なくできるとのことでした
プレリリース版に変えることで治るようですが、あまり気にせず実行したところ問題なく実行できました

おわりに

早く正式リリースしていただけたらとは思っています

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?