Skip to content

Commit 9406b6d

Browse files
committed
fmt
1 parent 0b1d5a4 commit 9406b6d

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

cargo-miri/bin.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -761,17 +761,19 @@ fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
761761
"WARNING: Ignoring `RUSTC` environment variable; set `MIRI` if you want to control the binary used as the driver."
762762
);
763763
}
764-
// Build scripts (and also cargo: https://github.com/rust-lang/cargo/issues/10885) will invoke `rustc` even when `RUSTC_WRAPPER` is set.
765-
// To make sure everything is coherent, we want that to be the Miri driver, but acting as rustc, on the target level.
766-
// (Target, rather than host, is needed for cross-interpretation situations.) This is not a
767-
// perfect emulation of real rustc (it might be unable to produce binaries since the sysroot is
768-
// check-only), but it's as close as we can get, and it's good enough for autocfg.
764+
// Build scripts (and also cargo: https://github.com/rust-lang/cargo/issues/10885) will invoke
765+
// `rustc` even when `RUSTC_WRAPPER` is set. To make sure everything is coherent, we want that
766+
// to be the Miri driver, but acting as rustc, on the target level. (Target, rather than host,
767+
// is needed for cross-interpretation situations.) This is not a perfect emulation of real rustc
768+
// (it might be unable to produce binaries since the sysroot is check-only), but it's as close
769+
// as we can get, and it's good enough for autocfg.
769770
//
770771
// In `main`, we need the value of `RUSTC` to distinguish RUSTC_WRAPPER invocations from rustdoc
771772
// or TARGET_RUNNER invocations, so we canonicalize it here to make it exceedingly unlikely that
772-
// there would be a collision with other invocations of cargo-miri (as rustdoc or as runner).
773-
// We explicitly do this even if RUSTC_STAGE is set, since for these builds we do *not* want the
774-
// bootstrap `rustc` thing in our way! Instead, we have MIRI_HOST_SYSROOT to use for host builds.
773+
// there would be a collision with other invocations of cargo-miri (as rustdoc or as runner). We
774+
// explicitly do this even if RUSTC_STAGE is set, since for these builds we do *not* want the
775+
// bootstrap `rustc` thing in our way! Instead, we have MIRI_HOST_SYSROOT to use for host
776+
// builds.
775777
cmd.env("RUSTC", &fs::canonicalize(find_miri()).unwrap());
776778
cmd.env("MIRI_BE_RUSTC", "target"); // we better remember to *unset* this in the other phases!
777779

@@ -850,7 +852,8 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
850852
let verbose = std::env::var("MIRI_VERBOSE")
851853
.map_or(0, |verbose| verbose.parse().expect("verbosity flag must be an integer"));
852854
let target_crate = is_target_crate();
853-
let print = get_arg_flag_value("--print").is_some() || has_arg_flag("-vV"); // whether this is cargo/xargo invoking rustc to get some infos
855+
// Determine whether this is cargo/xargo invoking rustc to get some infos.
856+
let info_query = get_arg_flag_value("--print").is_some() || has_arg_flag("-vV");
854857

855858
let store_json = |info: CrateRunInfo| {
856859
// Create a stub .d file to stop Cargo from "rebuilding" the crate:
@@ -872,7 +875,7 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
872875
info.store(&out_filename("", ".exe"));
873876
};
874877

875-
let runnable_crate = !print && is_runnable_crate();
878+
let runnable_crate = !info_query && is_runnable_crate();
876879

877880
if runnable_crate && target_crate {
878881
assert!(
@@ -934,7 +937,7 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
934937
let mut emit_link_hack = false;
935938
// Arguments are treated very differently depending on whether this crate is
936939
// for interpretation by Miri, or for use by a build script / proc macro.
937-
if !print && target_crate {
940+
if !info_query && target_crate {
938941
// Forward arguments, but remove "link" from "--emit" to make this a check-only build.
939942
let emit_flag = "--emit";
940943
while let Some(arg) = args.next() {
@@ -968,8 +971,9 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
968971
cmd.arg("-C").arg("panic=abort");
969972
}
970973
} else {
971-
// For host crates (but not when we are printing), we might still have to set the sysroot.
972-
if !print {
974+
// For host crates (but not when we are just printing some info),
975+
// we might still have to set the sysroot.
976+
if !info_query {
973977
// When we're running `cargo-miri` from `x.py` we need to pass the sysroot explicitly
974978
// due to bootstrap complications.
975979
if let Some(sysroot) = std::env::var_os("MIRI_HOST_SYSROOT") {
@@ -990,7 +994,7 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
990994
// Run it.
991995
if verbose > 0 {
992996
eprintln!(
993-
"[cargo-miri rustc] target_crate={target_crate} runnable_crate={runnable_crate} print={print}"
997+
"[cargo-miri rustc] target_crate={target_crate} runnable_crate={runnable_crate} info_query={info_query}"
994998
);
995999
}
9961000
debug_cmd("[cargo-miri rustc]", verbose, &cmd);
@@ -1030,7 +1034,9 @@ fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: RunnerPhas
10301034

10311035
let binary = binary_args.next().unwrap();
10321036
let file = File::open(&binary)
1033-
.unwrap_or_else(|_| show_error(format!("file {:?} not found or `cargo-miri` invoked incorrectly; please only invoke this binary through `cargo miri`", binary)));
1037+
.unwrap_or_else(|_| show_error(format!(
1038+
"file {:?} not found or `cargo-miri` invoked incorrectly; please only invoke this binary through `cargo miri`", binary
1039+
)));
10341040
let file = BufReader::new(file);
10351041

10361042
let info = serde_json::from_reader(file).unwrap_or_else(|_| {

0 commit comments

Comments
 (0)