14

I have rust-analyzer extension in VSCode.

In settings I only changed Rust-analyzer › Check On Save: Command from check to clippy (this shouldn't matter).

Problem is I don't see errors when I type, only after I save.

Typed (no error):

typing

Saved (can see error):

saved

Can it be changed?

vallentin
  • 23,478
  • 6
  • 59
  • 81
ZiiMakc
  • 31,187
  • 24
  • 65
  • 105
  • This doesn't really have anything to do with `"rust-analyzer.checkOnSave.command"`, or am I missing something? Aren't you simply asking, if it's possible to have rust-analyzer continuously run, as you type? – vallentin Jan 19 '21 at 22:39
  • @vallentin yep, i just sad all my settings if it maybe break something. – ZiiMakc Jan 19 '21 at 22:40

2 Answers2

10

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)

vallentin
  • 23,478
  • 6
  • 59
  • 81
3

You could:

This way you'll get inline errors while writing rust code.

Macc Etzel
  • 31
  • 1