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.
OS: Linux x64 5.4.0-74-generic
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.
rust-analyzer will not show semantic errors in Rust code if
cargo check wouldn't. Thus, it needs:
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
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.