Stream: t-compiler/rust-analyzer

Topic: rust-analyzer and rustc


nikomatsakis (Mar 30 2020 at 20:42, on Zulip):

Hey, so, when I open rustc in rust-analyzer, I get a bunch of entries in the "problem" section that I think come from running cargo check and not x.py check -- is there a way to customize the command rust-analyzer uses? Also, is this written up? Should I RTFM?

std::Veetaha (Mar 30 2020 at 21:11, on Zulip):

@nikomatsakis eh, unfortunately, I guess we lack the docs for this one in the repo itself.
Actually, the best way to inspect what's available in the configs is by hitting Ctrl+Space in settings.json file:
command.gif

or (the non-cool) method is using the vscode settings UI
image.png

std::Veetaha (Mar 30 2020 at 21:13, on Zulip):

Idk what x.py check means, I doubt that we will be able to watch that command, we are hardcoding the cargo executable right now. Maybe we should generalize this more. The main concern is that the command that is watched has to produce stdout output compatible with cargo metadata protocol.
P.S.
I know you are new vscode, just as a reminder, there is a global settings.json file that you can assess via Ctrl+Shift+P (command palette) and Preferences: Open Settings (JSON).
But if you need project-specific overrides, just create .vscode/settings.json in the root of the folder opened in vscode.

std::Veetaha (Mar 30 2020 at 21:21, on Zulip):

Right now I think the _workaround_ would be to create a cargo alias that runs this x.py under the hood and then passing the alias name as rust-analyzer.cargo-watch.command

nikomatsakis (Mar 30 2020 at 21:39, on Zulip):

hmm, I see, I could make like cargo build-rustc or something

nikomatsakis (Mar 30 2020 at 21:39, on Zulip):

and set rust-analyzer.cargo-watch command

nikomatsakis (Mar 30 2020 at 21:51, on Zulip):

that doesn't quite seem to work for me but .. not sure why

nikomatsakis (Mar 30 2020 at 21:51, on Zulip):

could be related to the errors I am getting around "watching" having problems because of needing more file descriptors or something

nikomatsakis (Mar 30 2020 at 21:52, on Zulip):

(specifically, I just get "no output" from the Problems section)

nikomatsakis (Mar 30 2020 at 21:52, on Zulip):

is there some way to see the "cargo watch" output?

std::Veetaha (Mar 30 2020 at 21:55, on Zulip):

Unfortunately, we don't log the output itself (due to the compexity around reading both stdout and stderr simultaneously (i.e. this bit of your code)), but we log the command that is run if it ends with an error in Rust Analyzer Language Server output.
image.png.

nikomatsakis (Mar 30 2020 at 21:58, on Zulip):

that helps, thanks

nikomatsakis (Mar 30 2020 at 21:59, on Zulip):
[ERROR ra_cargo_watch] Cargo watcher failed CargoError("the command produced no valid metadata (exit code: ExitStatus(ExitStatus(256))): cargo build-rustc --workspace --message-format=json --manifest-path /home/nmatsakis/versioned/rust-3/Cargo.toml --all-targets")
nikomatsakis (Mar 30 2020 at 21:59, on Zulip):

I'll have to see if I can get the metadata output correct

matklad (Mar 31 2020 at 17:27, on Zulip):

is there a way to customize the command rust-analyzer uses?

Not, yet, we unfortunatelly at the moment only allow to override the name of the cargo command. I've wanted to add a hook to override everything for ages, started working on this today.

Last update: Jul 24 2021 at 20:45UTC