MIR (Mid-Level Intermediate Representation) is an internal, platform-independent representation of Rust code used by the compiler for optimization and analysis, not a user-facing tool or syntax. It sits between the high-level HIR and the low-level LLVM IR, allowing the compiler to perform complex transformations like monomorphization and borrow checking before generating machine code. You interact with MIR indirectly through compiler flags like -Z unpretty=expanded or tools like cargo miri for unsafe code analysis, but you do not write or edit MIR directly.
What Is MIR (Mid-Level IR) in Rust?
MIR is the Rust compiler's internal intermediate representation used for optimization and safety analysis before generating machine code.