Rust intermediate files


#1

Here is standard main.rs:

fn main() {
    println!("Hello, world!");
}

Intermediate: hello_world-mir
I wonder why is four variables _0, _1, _2,_3 in static main and eight in fn main()


#2

As a starting-point println! is a macro and thus your code expands to this:

#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
fn main() {
    ::io::_print(
        ::std::fmt::Arguments::new_v1(
            {
                static __STATIC_FMTSTR: &'static [&'static str] = &["Hello, world!\n"];
                __STATIC_FMTSTR
            },
            &match () {
                () => [],
            }
        )
    );
}

Not a direct answer to your question but a bit closer to the actual code that ends up being turned into MIR.