From 938fe00f0246afe007850a362aa2050151772baa Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 11 May 2020 00:07:59 +0200 Subject: [PATCH] fix some comments, and run_compiler return type --- README.md | 4 ++-- src/bin/cargo-miri.rs | 8 +++----- src/bin/miri.rs | 10 +++++----- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 26d9b39fdd8..02fbd6cdfac 100644 --- a/README.md +++ b/README.md @@ -155,8 +155,8 @@ Try deleting `~/.cache/miri`. This means the sysroot you are using was not compiled with Miri in mind. This should never happen when you use `cargo miri` because that takes care of setting -up the sysroot. If you are using `miri` (the Miri driver) directly, see -[CONTRIBUTING.md](CONTRIBUTING.md) for how to use `./miri`. +up the sysroot. If you are using `miri` (the Miri driver) directly, see the +[contributors' guide](CONTRIBUTING.md) for how to use `./miri` to best do that. ## Miri `-Z` flags and environment variables diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index ca7fafd3d9c..b2e5238489f 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -479,10 +479,6 @@ fn is_target_crate() -> bool { fn is_runnable_crate() -> bool { let is_bin = get_arg_flag_value("--crate-type").as_deref() == Some("bin"); let is_test = has_arg_flag("--test"); - - // The final runnable (under Miri) crate will either be a binary crate - // or a test crate. We make sure to exclude build scripts here, since - // they are also build with "--crate-type bin" is_bin || is_test } @@ -494,7 +490,8 @@ fn is_runnable_crate() -> bool { cmd.args(std::env::args().skip(2)); // skip `cargo-miri rustc` // We make sure to only specify our custom Xargo sysroot for target crates - that is, - // crates which are ultimately going to get interpreted by Miri. + // crates which are needed for interpretation by Miri. proc-macros and build scripts + // should use the default sysroot. if target_crate { let sysroot = env::var_os("MIRI_SYSROOT").expect("The wrapper should have set MIRI_SYSROOT"); @@ -506,6 +503,7 @@ fn is_runnable_crate() -> bool { // otherwise we want Miri to behave like rustc and build the crate as usual. if target_crate && is_runnable_crate() { // This is the binary or test crate that we want to interpret under Miri. + // (Testing `target_crate` is needed to exclude build scripts.) // We deserialize the arguments that are meant for Miri from the special environment // variable "MIRI_ARGS", and feed them to the 'miri' binary. // diff --git a/src/bin/miri.rs b/src/bin/miri.rs index ff3872f2fd0..96de81b6243 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -68,7 +68,7 @@ fn init_early_loggers() { fn init_late_loggers(tcx: TyCtxt<'_>) { // We initialize loggers right before we start evaluation. We overwrite the `RUSTC_LOG` // env var if it is not set, control it based on `MIRI_LOG`. - // (FIXE: use `var_os`, but then we need to manually concatenate instead of `format!`.) + // (FIXME: use `var_os`, but then we need to manually concatenate instead of `format!`.) if let Ok(var) = env::var("MIRI_LOG") { if env::var_os("RUSTC_LOG").is_none() { // We try to be a bit clever here: if `MIRI_LOG` is just a single level @@ -123,7 +123,7 @@ fn compile_time_sysroot() -> Option { } /// Execute a compiler with the given CLI arguments and callbacks. -fn run_compiler(mut args: Vec, callbacks: &mut (dyn rustc_driver::Callbacks + Send)) { +fn run_compiler(mut args: Vec, callbacks: &mut (dyn rustc_driver::Callbacks + Send)) -> ! { // Make sure we use the right default sysroot. The default sysroot is wrong, // because `get_or_default_sysroot` in `librustc_session` bases that on `current_exe`. // @@ -152,7 +152,7 @@ fn run_compiler(mut args: Vec, callbacks: &mut (dyn rustc_driver::Callba Ok(()) => rustc_driver::EXIT_SUCCESS, Err(_) => rustc_driver::EXIT_FAILURE, }; - std::process::exit(exit_code); + std::process::exit(exit_code) } fn main() { @@ -163,7 +163,7 @@ fn main() { rustc_driver::init_rustc_env_logger(); // We cannot use `rustc_driver::main` as we need to adjust the CLI arguments. let mut callbacks = rustc_driver::TimePassesCallbacks::default(); - return run_compiler(env::args().collect(), &mut callbacks); + run_compiler(env::args().collect(), &mut callbacks) } // Init loggers the Miri way. @@ -285,5 +285,5 @@ fn main() { tracked_pointer_tag, tracked_alloc_id, }; - return run_compiler(rustc_args, &mut MiriCompilerCalls { miri_config }); + run_compiler(rustc_args, &mut MiriCompilerCalls { miri_config }) } -- 2.44.0