diff options
| author | Oliver Schneider <git-no-reply-9879165716479413131@oli-obk.de> | 2017-12-11 22:27:32 +0100 |
|---|---|---|
| committer | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2017-12-12 08:59:25 +0100 |
| commit | 8c2ec689c159e7f021d5913efb991aff875be967 (patch) | |
| tree | 2de32ebabc3113d00860a8862f3114ff354a1a72 | |
| parent | 7e5583b7f88c609492bf4f7b3a08313bc501b0ad (diff) | |
| download | rust-8c2ec689c159e7f021d5913efb991aff875be967.tar.gz rust-8c2ec689c159e7f021d5913efb991aff875be967.zip | |
Put miri const eval checking behind -Zmiri
| -rw-r--r-- | src/bootstrap/bin/rustc.rs | 3 | ||||
| -rw-r--r-- | src/bootstrap/check.rs | 1 | ||||
| -rw-r--r-- | src/librustc/session/config.rs | 2 | ||||
| -rw-r--r-- | src/librustc_const_eval/eval.rs | 44 |
4 files changed, 30 insertions, 20 deletions
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 631c9f72f35..30afd52f448 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -246,6 +246,9 @@ fn main() { // When running miri tests, we need to generate MIR for all libraries if env::var("TEST_MIRI").ok().map_or(false, |val| val == "true") { cmd.arg("-Zalways-encode-mir"); + if stage != "0" { + cmd.arg("-Zmiri"); + } cmd.arg("-Zmir-emit-validate=1"); } diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index ee780d1245e..eee403dcbe3 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -769,6 +769,7 @@ impl Step for Compiletest { if build.config.rust_debuginfo_tests { flags.push("-g".to_string()); } + flags.push("-Zmiri -Zunstable-options".to_string()); if let Some(linker) = build.linker(target) { cmd.arg("--linker").arg(linker); diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 0dcd3e80810..e6138b34c80 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1141,6 +1141,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "print some statistics about MIR"), always_encode_mir: bool = (false, parse_bool, [TRACKED], "encode MIR of all functions into the crate metadata"), + miri: bool = (false, parse_bool, [TRACKED], + "check the miri const evaluator against the old ctfe"), osx_rpath_install_name: bool = (false, parse_bool, [TRACKED], "pass `-install_name @rpath/...` to the macOS linker"), sanitizer: Option<Sanitizer> = (None, parse_sanitizer, [TRACKED], diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index f400380536e..95b6dc80b14 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -729,27 +729,31 @@ pub(crate) fn const_eval<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trace!("running old const eval"); let old_result = ConstContext::new(tcx, key.param_env.and(substs), tables).eval(&body.value); trace!("old const eval produced {:?}", old_result); - let instance = ty::Instance::new(def_id, substs); - trace!("const eval instance: {:?}, {:?}", instance, key.param_env); - let miri_result = ::rustc::mir::interpret::eval_body(tcx, instance, key.param_env); - match (miri_result, old_result) { - ((Err(err), ecx), Ok(ok)) => { - trace!("miri failed, ctfe returned {:?}", ok); - tcx.sess.span_warn( - tcx.def_span(key.value.0), - "miri failed to eval, while ctfe succeeded", - ); - let () = unwrap_miri(&ecx, Err(err)); - Ok(ok) - }, - ((Ok(_), _), Err(err)) => { - Err(err) - }, - ((Err(_), _), Err(err)) => Err(err), - ((Ok((miri_val, miri_ty)), mut ecx), Ok(ctfe)) => { - check_ctfe_against_miri(&mut ecx, miri_val, miri_ty, ctfe.val); - Ok(ctfe) + if tcx.sess.opts.debugging_opts.miri { + let instance = ty::Instance::new(def_id, substs); + trace!("const eval instance: {:?}, {:?}", instance, key.param_env); + let miri_result = ::rustc::mir::interpret::eval_body(tcx, instance, key.param_env); + match (miri_result, old_result) { + ((Err(err), ecx), Ok(ok)) => { + trace!("miri failed, ctfe returned {:?}", ok); + tcx.sess.span_warn( + tcx.def_span(key.value.0), + "miri failed to eval, while ctfe succeeded", + ); + let () = unwrap_miri(&ecx, Err(err)); + Ok(ok) + }, + ((Ok(_), _), Err(err)) => { + Err(err) + }, + ((Err(_), _), Err(err)) => Err(err), + ((Ok((miri_val, miri_ty)), mut ecx), Ok(ctfe)) => { + check_ctfe_against_miri(&mut ecx, miri_val, miri_ty, ctfe.val); + Ok(ctfe) + } } + } else { + old_result } } |
