
Instead of a full compilation, you can run cargo check to perform most of the checks you need. This will ensure your code would compile, without having to actually compile the code. The former chiefly involves rustc’s checking mechanisms; the latter involves the LLVM-driven build process, which is far slower.
Note that cargo check will not skip compilation of as-yet-unbuilt dependencies. If they need to be built to run the check, they will be. But after the first cargo check to get caught up on that process, future check runs will complete far faster.
Another common way to avoid rebuilding is to use a compiler caching tool. The sccache project supports caching Rust compiler artifacts, along with several other popular languages with similar coompiler behaviors (C, C++, etc.). However, you get the best results with sccache or something like it when you use it as a build cache for multiple users—e.g., a development team in an organization with a shared file system. Used on one system alone, it doesn’t yield much of an advantage, unless you’re sharing build artifacts for the same versions of crates across multiple projects.

