You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 27, 2018. It is now read-only.
I think it would be awesome if Rust Playpen could display the MIR of the code - that is, the MIR generated for every single function, and (potentially) the tables that are kept around, storing information about types. (I know very little about what information is actually kept around besides the MIR code itself.)
With the MIR becoming a central piece of the compiler, and borrow checking determined to be performed on the MIR eventually, I think this will be a great tool to debug borrowck issues, and to learn more about what happens "behind the scenes", about all the desugaring that's going on. The LLVM IR is so low-level that much of this can't be seen anymore.
The text was updated successfully, but these errors were encountered:
👍 MIR now has a textual representation which could be dumped for an entire crate (needs a new --unpretty option?), so this should fit in nicely with the other formats.
This allows obtaining a textual MIR dump for individual items or all items in the crate.
I haven't added any tests since ~~I'm too lazy~~ this is an unstable debugging option, but I'll add one if required.
MIR for a single function can now be dumped using `rustc -Zunstable-options --unpretty mir=my_function` and no longer requires the use of in-source `#[rustc_mir]` attributes.
Blocks rust-lang/rust-playpen#154 (if MIR dump support from the playpen is even wanted).
Example output:
```rust
fn main() {
let x = Some(0);
x.unwrap_or_else(|| 1);
}
```
```
MIR for expr || 1 (id=16)
fn(arg0: [[email protected]:3:22: 3:26]) -> i32 {
let mut tmp0: ();
bb0: {
return = const 1;
goto -> bb1;
}
bb1: {
return;
}
}
MIR for fn main::main (id=4)
fn() -> () {
let var0: core::option::Option<i32>; // x
let mut tmp0: ();
let mut tmp1: i32;
let mut tmp2: core::option::Option<i32>;
let mut tmp3: [[email protected]:3:22: 3:26];
bb0: {
var0 = core::option::Option::Some(const 0);
tmp2 = var0;
tmp3 = [[email protected]:3:22: 3:26];
tmp1 = core::option::Option<T>::unwrap_or_else(tmp2, tmp3) -> bb2;
}
bb1: {
return;
}
bb2: {
drop(tmp1) -> bb3;
}
bb3: {
return = ();
goto -> bb1;
}
}
```
I think it would be awesome if Rust Playpen could display the MIR of the code - that is, the MIR generated for every single function, and (potentially) the tables that are kept around, storing information about types. (I know very little about what information is actually kept around besides the MIR code itself.)
With the MIR becoming a central piece of the compiler, and borrow checking determined to be performed on the MIR eventually, I think this will be a great tool to debug borrowck issues, and to learn more about what happens "behind the scenes", about all the desugaring that's going on. The LLVM IR is so low-level that much of this can't be seen anymore.
The text was updated successfully, but these errors were encountered: