zed icon indicating copy to clipboard operation
zed copied to clipboard

Linting errors for implementation of panic handling with `no_std`

Open shot-codes opened this issue 2 years ago • 3 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

I am trying to implement panic handling with no_std, targeting wasm. I have the following implementation:

#![no_std]

#[panic_handler]
fn handle_panic(_: &core::panic::PanicInfo) -> ! {
    loop {}
}

I receive the following error in zed for the handle_panic function:

E0152
found duplicate lang item panic_impl
the lang item is first defined in crate std (which test depends on)...

I don't have any crate called test. My build .cargo/config.toml look like the following:

[build]
target = "wasm32-unknown-unknown"

[profile.dev]
opt-level = 0
debug = true

[profile.release]
opt-level = 3
debug = false

I have tried setting rust-analyzer properties in my zed settings (cargo.target = "wasm32-unknwon-unknown, and checkOnSave.targets = false, to no avail.)

Environment

Zed 0.66.1 – /Applications/Zed.app macOS 12.6 architecture x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue

No response

shot-codes avatar Dec 31 '22 18:12 shot-codes

Same issue here. Any solution found yet ?

SyntheticBird45 avatar May 04 '24 17:05 SyntheticBird45

Not from my side. On Linux now and not using zed until there is a release.

shot-codes avatar May 04 '24 21:05 shot-codes

Found the solution! Add the following to settings.json:

"lsp": {
    "rust-analyzer": {
      "initialization_options": {
        "check": {
          "allTargets": false
        }
      }
    }
  }

SyntheticBird45 avatar May 05 '24 10:05 SyntheticBird45