`cargo check` returns stale errors sometimes

I keep hitting an issue where cargo check reports issues that are no longer there. After a switch a branch etc. I'll get errors not matching the code anymore. If I run cargo build instead, I get correct errors. Is anyone aware of existing issues like this?

I'm assuming you are referring to issues that are in your local code. There are two main possibilities:

  1. Cargo isn't detecting something needs to be rebuilt. If you can reproduce, can you run cargo check -v next time it happens to verify whether or not rustc is actually running? Keep in mind that after the first time cargo check runs, if these are just warnings, cargo will repeat the previous warnings.
  2. There is a problem with incremental. If rustc is running, but reporting old information, this is very likely the cause. If it is an open-source project, and you can reproduce through a certain sequence of commands, I would suggest opening an issue at Issues · rust-lang/rust · GitHub.

Have you tried running cargo clean? There are sometimes things left over from incremental compilation.

FYI https://users.rust-lang.org/ might be a better place to ask for help. As this is the internal forum discussing changes to Rust.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.