cargo rustc

发布时间 2023-04-18 10:49:07作者: develon

RUSTC_BOOTSTRAP=1

如果需要在稳定版编译器上执行一些夜间发布功能,可以设置该环境变量。

$ cargo rustc -- -Zunpretty=expanded
   Compiling xxx v0.1.0 (F:\xxx)
error: the option `Z` is only accepted on the nightly compiler


$ RUSTC_BOOTSTRAP=1 cargo rustc -- -Z unpretty=expanded
   Compiling xxx v0.1.0 (F:\xxx)
#![feature(prelude_import)]
#![windows_subsystem = "console"]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;

打印cfg

$ cargo rustc -- --print cfg
   Compiling xxx v0.1.0 (F:\xxx)
debug_assertions
panic="unwind"
target_arch="x86_64"
target_endian="little"
target_env="msvc"
target_family="windows"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_os="windows"
target_pointer_width="64"
target_vendor="pc"
windows