Warnings/Errors not lining up with source in VSCode

I'm using VSCode under Windows 10, and I'm having a weird problem with rust-analyzer. The yellow warning underlines have stopped lining up properly with the source code. The warnings are instead showing up a variable amount of characters after the code that has the issue, sometimes right next to it, sometimes multiple entire lines down. The same is true of errors, which is making it very difficult to locate and fix syntax errors since they are no longer highlighted properly.

I've tried restarting VSCode and my computer, reinstalling rust-analyzer, running rustup update, switching to the preview build of rust-analyzer, but no luck yet.

EDIT: I've also opened a C# file and deliberately introduced a syntax error to check for alignment. VSCode underlines the error correctly there. Then I re-opened my Rust project, and it's still misaligned.

This also happened to me in one of my projects. Doesn't happen anymore. I don't know to pinpoint the reason.

1 Like

This is fixed here: Wrong error and warning underline positions on Windows · Issue #12293 · rust-lang/rust-analyzer · GitHub

1 Like

Ah, looks like google failed me when I tried to see if there were any existing reports. For now I'll try converting CRLFs to LFs.

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.