Rust Unsafe Information in MIR Code

Hi all, Now in the process of analyzing the compilation step of RUST, I wonder that the MIR code phase. In the MIR stage, Unsafe information is checked as follows. Based on the analysis, I want to find the part that outputs information about Unsafe in the MIR stage in the rustc source code(GitHub - rust-lang/rust: Empowering everyone to build reliable and efficient software.). May I know which directory or source file outputs the unsafe information in the MIR stage?

Hi, welcome!

In case you haven't done so already, be sure to check Guide to Rustc Development, which documents rustc internals. For example, MIR is documented in a chapter titled The MIR (Mid-level IR).

As the chapter explains, MIR is defined in rustc_middle::mir module. In particular, there is an enum rustc_middle::mir::Safety. The link leads to its documentation and it also links to its source location.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.