Search code examples
rusttypechecking

Does Rust have a way to perform syntax and semantic analysis without generating code?


Compilers such as gcc, clang and gccgo all have the switch -fsyntax-only used in single-buffer syntax checkers such as Flycheck. These only perform syntactic and, I assume, semantic analysis, thereby skipping code generation. Does Rust have something similar?


Solution

  • The cargo check command instructs cargo to do just that.

    It will check the syntax, types and borrows without generating any code.