]> git.lizzy.rs Git - rust.git/commitdiff
fix some comments, and run_compiler return type
authorRalf Jung <post@ralfj.de>
Sun, 10 May 2020 22:07:59 +0000 (00:07 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 10 May 2020 22:09:46 +0000 (00:09 +0200)
README.md
src/bin/cargo-miri.rs
src/bin/miri.rs

index 26d9b39fdd8e948e43ce438ce84013552d7eb12d..02fbd6cdfacfa4d5987fe10cad9ac7eaf6423f6c 100644 (file)
--- 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
index ca7fafd3d9c2ddf1da116d0f0e3fe75060bb0f81..b2e5238489f2f0d9587d636d43b055f0c5ba2d92 100644 (file)
@@ -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.
         //
index ff3872f2fd02cd91f82122453e6f19410ac9d80b..96de81b62430748193c05d0e8fa772b68a39bfbb 100644 (file)
@@ -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<String> {
 }
 
 /// Execute a compiler with the given CLI arguments and callbacks.
-fn run_compiler(mut args: Vec<String>, callbacks: &mut (dyn rustc_driver::Callbacks + Send)) {
+fn run_compiler(mut args: Vec<String>, 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<String>, 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 })
 }