How to get cfg(target_arch) rust-analyzer warnings to be quiet

⚓ Rust    📅 2026-03-18    👤 surdeus    👁️ 1      

surdeus

I'm very new to rust and especially rust-analyzer so apologies in advance if this is a little incomprehensible like that.

I'm trying to follow along a tutorial for wgpu and they have a lot of the #[cfg(target_arch = "wasm32")] attribute going on. And for each of them I get the note rust-analyzer: code is inactive due to #[cfg] directives: target_arch = "wasm32" is disabled. This is, to say the least, annoying. How can I get them to be quiet?

For context, I am using Neovim (specifically LazyVim, with which I have { "LazyVim/LazyVim", import = "lazyvim.plugins.extras.lang.rust" } in my plugins. And I use Nix/Home Manager as a package manager/config management if that's relevant though it should be effectively just editing a Neovim config. Also, ideally, whatever solution wouldn't be global; I imagine other projects would benefit from the warnings.

That said, I have tried a few basic things I found:

  • setting cargo.target = "wasm32-unknown-unknown"
  • setting cargo.cfgs = [ "debug_assertions", "miri", "target_arch=\"wasm32\"" ]
  • well, specifically opts.default_settings.["rust-analyzer"].<above> and appropriately formatted for a Lua-based Neovim config.

Neither of those seemed to work. (Final note: it's very late and I need sleep so sorry if I take a while to respond.)

2 posts - 2 participants

Read full topic

🏷️ Rust_feed