Rust: cargo rustc 与HIR代码

我们有希望看到rust代码编译成HIR代码,可以:

cargo rustc -- -Z unpretty=hir-tree //太详细了,展开后太长了
cargo rustc -- -Z unpretty=hir // 一般够用了,推荐
fn main() {
    println!("Hello, world!");
    let flags = b"hello world\0\0";
    let news:String = flags.iter().filter(|&&c| c != 0).map(|&c| char::from(c)).collect();
    println!("news: {:?}",news);
}
(base) PS D:\rust_test\mytest> cargo rustc -- -Z unpretty=hir
输出:
```bash
(base) PS D:\rust_test\mytest> cargo rustc -- -Z unpretty=hir
   Compiling mytest v0.1.0 (D:\rust_test\mytest)
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
fn main() {
        {
                ::std::io::_print(::core::fmt::Arguments::new_v1(&["Hello, world!\n"],
                        &[]));
            };
        let flags = b"hello world\x00\x00";
        let news: String =
            flags.iter().filter(|&&c|
                            c != 0).map(|&c| char::from(c)).collect();
        {
                ::std::io::_print(::core::fmt::Arguments::new_v1(&["news: ",
                                    "\n"], &[::core::fmt::ArgumentV1::new_debug(&news)]));
            };
    }
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s

你可能感兴趣的:(rust,开发语言,后端)