rust-analyzer: False positive syntax errors

I just updated rust-analyzer this morning, and it’s no long working for me. If I first open VS Code, rust-analyzer doesn’t give any errors on my codebase (nor does cargo check). However, as soon as I begin typing (or even saving), I get persistent false positive syntax errors that completely break syntax highlighting and suggestions. cargo clean doesn’t resolve the problem.

Please let me know if there is any additional information that might clear this up. I can try re-installing rust-analyzer fresh, but figured I would post an issue in case this isn’t affecting just me.

For instance: top image is right after I have opened VS code, and bottom is as soon as I have started typing. Deleting the line that I was typing does not make the errors go away, nor does saving. The only way to refresh the syntax errors is to restart VS Code.

https://i.imgur.com/jcMAIrr.png

Version numbers of relevant software:

rustc: 1.45.0 5c1f21c3b 2020-07-13) [stable]
rust-analyzer: 0.2.264
VS Code: 1.47.3 (system setup)
Commit: 91899dcef7b8110878ea59626991a18c8a6a1b3e
Date: 2020-07-23T13:12:49.994Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18362

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 8
  • Comments: 20 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Guys I’m very sorry I check-out the @lazear repo but didnt changed branches to the “false_positive_fix” branch 🙄 I re-build it and can confirm that the issue IS GONE

all problems have stopped, specifically:

  1. after some keystrokes highlights bug
  2. deleting single line comments with “delete line” action
  3. deleting multi line comments

thank you for the fix ♥ and sorry again to panic you guys

@lazear I downloaded your PR branch from https://github.com/lazear/rust-analyzer/tree/false_positive_fix build it and setup the “rust-analyzer.serverPath” variable in vs code. ( Please correct me if I made any mistake trying to setup your version) I could not get the errror anymore in the language server pane, but my syntax highlight is still messed up after some keystrokes the hightlight error happens 100% of the time if I delete large multi line comments in any file image

I’m authoring a PR right now, the Cow::Owned is the issue

Can you try adding line_index = Cow::Owned(LineIndex::new(old_text)); around https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/rust-analyzer/src/lsp_utils.rs#L89 and see if it makes a difference wrt. the apply_document_changes panic?

@Emilgardis can you clarify what you mean by workspace packages? Is that crates in the current workspace? If so, then I have 4.

I can try a bisect