Auto merge of #1408 - RalfJung:comments, r=RalfJung

fix some comments, and run_compiler return type
This commit is contained in:
bors
2020-05-10 22:12:00 +00:00
3 changed files with 10 additions and 12 deletions
+2 -2
View File
@@ -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
+3 -5
View 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.
//
+5 -5
View 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 })
}