diff --git a/miri/bin/miri.rs b/miri/bin/miri.rs index 76a9b3d0e051..0730315504a5 100644 --- a/miri/bin/miri.rs +++ b/miri/bin/miri.rs @@ -202,7 +202,7 @@ fn main() { // for auxilary builds in unit tests args.push("-Zalways-encode-mir".to_owned()); - args.push("-Zmir-emit-validate".to_owned()); + args.push("-Zmir-emit-validate=1".to_owned()); rustc_driver::run_compiler(&args, &mut MiriCompilerCalls(RustcDefaultCalls), None, None); } diff --git a/src/librustc_mir/interpret/validation.rs b/src/librustc_mir/interpret/validation.rs index 3756fca2344f..a6c2871cf521 100644 --- a/src/librustc_mir/interpret/validation.rs +++ b/src/librustc_mir/interpret/validation.rs @@ -40,24 +40,19 @@ impl ValidationMode { impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { pub(crate) fn validation_op(&mut self, op: ValidationOp, operand: &ValidationOperand<'tcx, mir::Lvalue<'tcx>>) -> EvalResult<'tcx> { // HACK: Determine if this method is whitelisted and hence we do not perform any validation. + // We currently insta-UB on anything passing around uninitialized memory, so we have to whitelist + // the places that are allowed to do that. { // The regexp we use for filtering use regex::Regex; lazy_static! { static ref RE: Regex = Regex::new("^(\ -std::mem::swap::|\ std::mem::uninitialized::|\ -std::ptr::read::|\ -std::panicking::try::do_call::|\ -std::slice::from_raw_parts_mut::|\ +std::mem::forget::|\ ::|\ ->::new$|\ - as std::ops::DerefMut>::deref_mut$|\ -std::sync::atomic::AtomicBool::get_mut$|\ -><[a-zA-Z0-9_\\[\\]]+>::from_raw|\ -<[a-zA-Z0-9_:<>]+ as std::slice::SliceIndex<[a-zA-Z0-9_\\[\\]]+>><[a-zA-Z0-9_\\[\\]]+>::get_unchecked_mut$|\ -><[a-zA-Z0-9_\\[\\]]+>::into_box$|\ -><[a-zA-Z0-9_\\[\\]]+>::into_boxed_slice$\ +><.*>::new$|\ + as std::ops::DerefMut><.*>::deref_mut$|\ +std::ptr::read::\ )").unwrap(); } // Now test