Rust-for-Linux / linux

Adding support for the Rust language to the Linux kernel.
https://rust-for-linux.com
Other
3.95k stars 420 forks source link

No errors are shown in the VSCode "problems" tab #951

Open dwlsalmeida opened 1 year ago

dwlsalmeida commented 1 year ago

Hi all,

First off, I was going to send this to the rust-for-linux mailing list, but I see that it is mainly used for patches, so in the interest of not polluting it I've decided to open an issue here instead.

Here's for the actual issue: no errors are shown in the VSCode "problems" tab here, even after setting the path to rust-project.json in "rust-analyzer.linkedProjects".

This is slightly incovenient because it means that no errors are shown in the UI while writing Rust code.

Some brief research [0] indicates that this is to be expected, i.e.:

Note that calls to cargo check are disabled when using rust-project.json by default, so compilation errors and warnings will no longer be sent to your LSP client. To enable these compilation errors you will need to specify explicitly what command rust-analyzer should run to perform the checks using the checkOnSave.overrideCommand configuration. As an example, the following configuration explicitly sets cargo check as the checkOnSave command.

1

{ "rust-analyzer.checkOnSave.overrideCommand": ["cargo", "check", "--message-format=json"] }

The checkOnSave.overrideCommand requires the command specified to output json error messages for rust-analyzer to consume. The --message-format=json flag does this for cargo check so whichever command you use must also output errors in this format. See the Configuration section for more information.

I expect that there is no infrastructure in place to output the errors in JSON format.

This brings me to the topic of problem matchers. Are they - in conjunction with a separate build task - the recommended way to get the errors to show? If so, is there a problem matcher in use by all of the community?

Lastly, can I get an invite to the Zulip chat, please?

-- Daniel

[0] https://rust-analyzer.github.io/manual.html#non-cargo-based-projects

bjorn3 commented 1 year ago

You can create a vscode task to run make. I think you an set the problemMatcher for this task to the literal string $rustc to make the results appear inline with the source code.

dwlsalmeida commented 1 year ago

thanks @bjorn3 I was trying to make sure the problem matcher approach was the right thing to do

I will try that!

ojeda commented 1 year ago

Lastly, can I get an invite to the Zulip chat, please?

I think nowadays the "Sign up" button should work when you try to access it -- but I am happy to send it too (to the email in your profile?).

dwlsalmeida commented 1 year ago

@ojeda Could you please send to daniel.almeida@collabora.com if you have the time? :)

ojeda commented 1 year ago

Done -- welcome! (Did you have a problem with that "Sign up" page? I am asking in case others may have too)

dwlsalmeida commented 1 year ago

To be honest, I was under the impression that you could only log in through Google/Github/Gitlab. I just saw that you can register using a regular email too, which I just confirmed as working as well.

Thanks, all is working fine! :)

ojeda commented 1 year ago

Ah, makes sense. Thanks for letting me know! Yeah, I think the option is a bit hidden... Would a small note in the README.md help?

ojeda commented 3 days ago

I think we can close this (?).

We also discussed how well rust-analyzer was working in Kangrejos 2024.