rustneovimrust-analyzer

rust-analyzer adds "rewriting static" at the top of the file if the static or const keywords are being used in code


I use neovim (kickstart) and have the rust-analyzer Lsp activated, for rust files. Whenever I write static or const in my code, the Lsp adds "rewriting static" at the top of the file. When I say LspStop it does (obviously) not happen anymore.

However, this happens only in one project, where I am currently following this tutorial: Writing an OS in Rust

I have also setup a completely new project and it does not add "rewriting static" when I include static or const in my code.


Solution

  • You're probably just running a faulty version of rustfmt. Running rustup update fixed it for me.

    Issue: https://github.com/rust-lang/rustfmt/issues/6210

    Fix: https://github.com/rust-lang/rust/pull/126888