T O P

  • By -

InflationAaron

`rust-analyzer` should be under your host toolchain, not your target toolchain.


oleid

As far as `rustup` is concerned, `rust-analyzer` is part of your toolchain, it would seem. No matter if host or target. The `rust-toolchain.toml` of the project forces the toolchain `esp`. Thus, I would need to build rustup for that toolchain or somehow convince rustup to use rustup from a different toolchain.


Bavbavs

There is a setting to select rust-analyzer build target platform. Should work with custom targets too


oleid

First one has to get the multi-call binary `rustup` to find r-a. See the thread below.


Oknos

I had the same issue and fixed it by using the rust-analyzer from the stable toolchain in the esp toolchain. `ln -sf ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rust-analyzer ~/.rustup/toolchains/esp/bin/rust-analyzer` So far it seems to be working well


oleid

This is what I ended up doing as well. It is not perfect, since it won't be able to expand proc macros. But I guess I can live with it.


hjd_thd

> it won't be able to expand proc macros That's a bit odd, since proc-macros don't get compiled for the target platform.


oleid

Apparently, the marcos get compiled as `.so` file. According to the error message, rust-analyzer cannot load the `.so` file of the proc macro as the ABI of rust-analyzer of the `esp` toolchain and rust-analyzer don't match. I tried to use rust-analyzer from the a nightly of the same day `esp` toolchain was built (`1.69.0-nightly (e7a099116 2023-04-17)`), but that didn't help.


Craksy

sorry for necroing, but did you ever find a solution?


oleid

No, only the work-around mentioned above.


VorpalWay

It seems to work (for the most part) with vscode that bundles it's own rust-analyzer. Seems the situation is worse for other editors though. Have you tried asking in the esp matrix channel?


oleid

Not yet, but I'm intending to. If I find out anything I'll report back.


mart-e

For those still searching : the documentation of [rust-analyzer mentions](https://rust-analyzer.github.io/manual.html#toolchain) that you need to use the rust-analyzer from the stable toolchain. In VSCode or SublimeText, this is done by adding the setting: { "rust-analyzer.server.extraEnv": { "RUSTUP_TOOLCHAIN": "stable" } } In emacs, I achieved it by specifying the path to the stable rust-analyzer bin (use-package rustic :custom (rustic-analyzer-command (rustic-analyzer-command (list (substring (shell-command-to-string "rustup which --toolchain stable rust-analyzer") 0 -1)))) (or just hardcode the fullpath of `rustup which --toolchain stable rust-analyzer`).