rust-analyzerで保存時にcargo checkを回すとき、10秒ほどスタックすることがある。

デフォルトだと–all-targetsオプションが設定されているので、no_stdなクレートをコンパイルしようとするとエラーが起こることが原因っぽかった。

コマンドラインだと以下のようなエラーが出るので分かりやすい。

error: language item required, but not found: `eh_personality`
  |
  = note: this can occur when a binary crate with `#![no_std]` is compiled for a target where `eh_personality` is defined in the standard library
  = help: you may be able to compile for a target that doesn't need `eh_personality`, specify a target with `--target` or in `.cargo/config`

rust-analyzerの場合は、checkOnSave時のコマンドを以下のようにオーバーライドすることでクリアできた。

    "rust-analyzer.checkOnSave.overrideCommand": [
        "cargo",
        "clippy",
        "--workspace",
        "--message-format=json",
    ],

参照
https://github.com/rust-lang/rust-analyzer/issues/2142
https://github.com/rust-lang/rust-analyzer/issues/4616

bannerAds