Rust-analyer suddenly gaves a lot of non-sense errors

I am using rust-analyzer with VSCodium. My code is clean, passed cargo build without warnings.

Today when I was working on the code, after made some changes and save, I got a lot of errors, all on formatting kind of codes, like anyhow!("text {} {} {}", arg1, arg2, arg3) got me expected 3 arguments, found 4 and call to unsafe function is unsafe and requires an unsafe function or block. Also is epringln!, #[derive(SubCommand)].

I could not figure out what is going on. Restart everything did not help.

rust-analyzer version is 0.3.2500

Was this 'cargo build' before or after the edit that caused problems with rust-analyser?

The reason I ask is that sometimes a missing parenthesis or bracket will give crazy errors that hide the error about a missing parenthesis or bracket.

I don't use VSCode/VSCodium but I've noticed there are sometimes problems reported that are fixed by removing the Rust extension and reinstalling it.

Both. First thing I did seeing those errors, was cargo clean; cargo build. It passed.

I also meet the same problems, even simple println!("") give call to unsafe function is unsafe and requires an unsafe errors; but the project can be compiled without any problems.

env: R-A with latest nightly channel in zed editor.

Sadly, no luck for me.

I am using it on NixOS, wonder if you are the same?

already reported as bug in println! macro is unsafe · Issue #20051 · rust-lang/rust-analyzer · GitHub
root cause perhaps from Allow storing `format_args!()` in variable by m-ou-se · Pull Request #140748 · rust-lang/rust · GitHub

3 Likes

Seems like fixed in pre-release version.