rustc_mir_build::build

Module custom

source
Expand description

Provides the implementation of the custom_mir attribute.

Up until MIR building, this attribute has absolutely no effect. The mir! macro is a normal decl macro that expands like any other, and the code goes through parsing, name resolution and type checking like all other code. In MIR building we finally detect whether this attribute is present, and if so we branch off into this module, which implements the attribute by implementing a custom lowering from THIR to MIR.

The result of this lowering is returned “normally” from the build_mir hook, with the only notable difference being that the injected field in the body is set. Various components of the MIR pipeline, like borrowck and the pass manager will then consult this field (via body.should_skip()) to skip the parts of the MIR pipeline that precede the MIR phase the user specified.

This file defines the general framework for the custom parsing. The parsing for all the “top-level” constructs can be found in the parse submodule, while the parsing for statements, terminators, and everything below can be found in the parse::instruction submodule.

Modules§

Structs§

Functions§

Type Aliases§