Skip to content

Commit c9decd3

Browse files
committed
Auto merge of #1408 - RalfJung:comments, r=RalfJung
fix some comments, and run_compiler return type
2 parents 4c78479 + 938fe00 commit c9decd3

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ Try deleting `~/.cache/miri`.
155155

156156
This means the sysroot you are using was not compiled with Miri in mind. This
157157
should never happen when you use `cargo miri` because that takes care of setting
158-
up the sysroot. If you are using `miri` (the Miri driver) directly, see
159-
[CONTRIBUTING.md](CONTRIBUTING.md) for how to use `./miri`.
158+
up the sysroot. If you are using `miri` (the Miri driver) directly, see the
159+
[contributors' guide](CONTRIBUTING.md) for how to use `./miri` to best do that.
160160

161161

162162
## Miri `-Z` flags and environment variables

src/bin/cargo-miri.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,6 @@ fn inside_cargo_rustc() {
479479
fn is_runnable_crate() -> bool {
480480
let is_bin = get_arg_flag_value("--crate-type").as_deref() == Some("bin");
481481
let is_test = has_arg_flag("--test");
482-
483-
// The final runnable (under Miri) crate will either be a binary crate
484-
// or a test crate. We make sure to exclude build scripts here, since
485-
// they are also build with "--crate-type bin"
486482
is_bin || is_test
487483
}
488484

@@ -494,7 +490,8 @@ fn inside_cargo_rustc() {
494490
cmd.args(std::env::args().skip(2)); // skip `cargo-miri rustc`
495491

496492
// We make sure to only specify our custom Xargo sysroot for target crates - that is,
497-
// crates which are ultimately going to get interpreted by Miri.
493+
// crates which are needed for interpretation by Miri. proc-macros and build scripts
494+
// should use the default sysroot.
498495
if target_crate {
499496
let sysroot =
500497
env::var_os("MIRI_SYSROOT").expect("The wrapper should have set MIRI_SYSROOT");
@@ -506,6 +503,7 @@ fn inside_cargo_rustc() {
506503
// otherwise we want Miri to behave like rustc and build the crate as usual.
507504
if target_crate && is_runnable_crate() {
508505
// This is the binary or test crate that we want to interpret under Miri.
506+
// (Testing `target_crate` is needed to exclude build scripts.)
509507
// We deserialize the arguments that are meant for Miri from the special environment
510508
// variable "MIRI_ARGS", and feed them to the 'miri' binary.
511509
//

src/bin/miri.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn init_early_loggers() {
6868
fn init_late_loggers(tcx: TyCtxt<'_>) {
6969
// We initialize loggers right before we start evaluation. We overwrite the `RUSTC_LOG`
7070
// env var if it is not set, control it based on `MIRI_LOG`.
71-
// (FIXE: use `var_os`, but then we need to manually concatenate instead of `format!`.)
71+
// (FIXME: use `var_os`, but then we need to manually concatenate instead of `format!`.)
7272
if let Ok(var) = env::var("MIRI_LOG") {
7373
if env::var_os("RUSTC_LOG").is_none() {
7474
// 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> {
123123
}
124124

125125
/// Execute a compiler with the given CLI arguments and callbacks.
126-
fn run_compiler(mut args: Vec<String>, callbacks: &mut (dyn rustc_driver::Callbacks + Send)) {
126+
fn run_compiler(mut args: Vec<String>, callbacks: &mut (dyn rustc_driver::Callbacks + Send)) -> ! {
127127
// Make sure we use the right default sysroot. The default sysroot is wrong,
128128
// because `get_or_default_sysroot` in `librustc_session` bases that on `current_exe`.
129129
//
@@ -152,7 +152,7 @@ fn run_compiler(mut args: Vec<String>, callbacks: &mut (dyn rustc_driver::Callba
152152
Ok(()) => rustc_driver::EXIT_SUCCESS,
153153
Err(_) => rustc_driver::EXIT_FAILURE,
154154
};
155-
std::process::exit(exit_code);
155+
std::process::exit(exit_code)
156156
}
157157

158158
fn main() {
@@ -163,7 +163,7 @@ fn main() {
163163
rustc_driver::init_rustc_env_logger();
164164
// We cannot use `rustc_driver::main` as we need to adjust the CLI arguments.
165165
let mut callbacks = rustc_driver::TimePassesCallbacks::default();
166-
return run_compiler(env::args().collect(), &mut callbacks);
166+
run_compiler(env::args().collect(), &mut callbacks)
167167
}
168168

169169
// Init loggers the Miri way.
@@ -285,5 +285,5 @@ fn main() {
285285
tracked_pointer_tag,
286286
tracked_alloc_id,
287287
};
288-
return run_compiler(rustc_args, &mut MiriCompilerCalls { miri_config });
288+
run_compiler(rustc_args, &mut MiriCompilerCalls { miri_config })
289289
}

0 commit comments

Comments
 (0)