4 ms·
> It’d be helpful if rustc had a mode where it could emit some sort of “core Rust” IR, that was all unsafe{} and had only the barest types, in the vein of early
by roblabla 7y ago
> It’d be helpful if rustc had a mode where it could emit some sort of “core Rust” IR, that was all unsafe{} and had only the barest types, in the vein of early C++ compilers that emit C, or how the Erlang compiler works. Sadly, I don’t think rustc is architected in a way that’d allow this. (Though, paging steveklabnik to correct me.)
MIR seems to be the closest thing to a "Core Rust". You still have access to all the types, but everything is desugared down to the barest possible syntax. While and for loops are desuggared to loop+break, complex field accesses are split into temporary to ease borrow analysis, etc...
I'm not sure what happens to unsafe block, but I suspect those gets stripped as well, and MIR is assumed to be valid. There's a tool called miri that can be used to find UB by running the MIR - if you manage to trigger UB, miri will error out telling you what went wrong.
Might be worth looking into it :D