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()
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()
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 () {
() => [],
}
)
);
}
https://github.com/dtolnay/cargo-expand
Not a direct answer to your question but a bit closer to the actual code that ends up being turned into MIR.