'How to enable real-time linting while typing with rust-analyzer in VSCode?
Solution 1:[1]
Problem is I don't see errors when I type, only after I save.
Rust-analyzer does not support real-time linting (yet?).
In short, rust-analyzer essentially runs cargo check. For small projects this can be quite fast. However, as project sizes increase, this can take significantly more time, which makes it unfeasible to check in real-time.
See also issue #4185 and "Drawbacks" on the "First Release" post.
The next best thing you can do (as you already know), is to use "check on save":
"rust-analyzer.checkOnSave.enable": true
(which is enabled by default in the VSCode extension)
Solution 2:[2]
You could:
Enable autoSave in your settings.json file within the .vscode folder.
"files.autoSave": "afterDelay", "files.autoSaveDelay": 20,Install Error Lens extension for vscode:
https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens
This way you'll get inline errors while writing rust code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | vallentin |
| Solution 2 | Macc Etzel |


