MIR borrow check

The borrow check is Rust’s “secret sauce” – it is tasked with enforcing a number of properties:

The borrow checker operates on the MIR. An older implementation operated on the HIR. Doing borrow checking on MIR has several advantages:

Major phases of the borrow checker

The borrow checker source is found in the rustc_borrowck crate. The main entry point is the mir_borrowck query.

Debugging the borrow checker

See Debugging the borrow checker and MIR Debugging.