Does cargo cache the result of typechecking?

My IDE runs cargo check automatically after I make some changes. Assuming it checks, does it do the typechecking again after I cargo run?

Asking this as a game dev where incremental compile time is very important.

It does.

Cargo has an incremental cache, but last time I checked it wasn't reused between check and run. rust-analyzer has its own separate type checking too.

Try

cargo build --timings

it will generate a report of everything that took time during compilation.

There's also a way to check more detailed time:

RUSTFLAGS=-Ztime-passes cargo +nightly build

and this contains separate passes for type checking, so you can verify if your project has a degenerate case where type checking takes disproportionally long time (usually it's tiny, and LLVM and linker take the most time in incremental rebuild).

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.