VSCode fresh install no error highlighting

Hello!

I did a fresh system install and ever since I can't get error highlighting to work properly.

I tried 3 different ways of installing VSCode, I tried 2 different ways of installing the language server but nothing worked.

VSCode shows types/ variable names in gray but doesn't highlight any errors except syntax and import related.
I also tried installing older versions of the extension but that doesn't change anything.

I would appreciate any help on this since the error highlighting does work with the official extension but rust-analyzer is so much better.

Thanks!

VSCode:

Version: 1.61.2
Commit: 6cba118ac49a1b88332f312a8f67186f7f3c1643
Date: 2021-10-19T14:58:13.605Z
Electron: 13.5.1
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Linux x64 5.4.0-74-generic

rust-analyzer extension:

Released on
2/10/2020, 10:24:28
Last updated
10/25/2021, 09:12:46
Identifier
matklad.rust-analyzer

Appearently the project I was working on was broken.
I created a new project with cargo new, copied files over, added dependencies and now everything works as intended.

(post deleted by author)

rust-analyzer will not show semantic errors in Rust code if cargo check wouldn't. Thus, it needs:

  • A Cargo.toml file in the directory you opened as a VS Code workspace, that doesn't contain errors itself. You can check this by running cargo check — if it gives errors about the Cargo.toml then you need to fix them. (rust-analyzer will also indicate this in the status bar but not the Problems list.)
  • The file you're editing to be part of some target — that is, to be lib.rs, main.rs (or one of the other possible crate-root files) or declared as a mod-ule by another file that's reachable starting from the crate root source file. (If this is the problem then cargo check will be silent since it doesn't know it ought to be checking that file — but rust-analyzer should then be telling you "file not included in module tree".)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.