diff --git a/.travis.yml b/.travis.yml index 9b4f75ab29c..d2315c7e953 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,9 +50,9 @@ script: # test `cargo miri` cd cargo-miri-test && if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - cargo miri -q -- -Zmiri-start-fn + cargo miri -q else - cargo miri -q -- -Zmiri-start-fn >stdout.real 2>stderr.real && + cargo miri -q >stdout.real 2>stderr.real && cat stdout.real stderr.real && # Test `cargo miri` output. Not on mac because output redirecting doesn't # work. There is no error. It just stops CI. diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 4cd20901333..3deb5b5a314 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -99,6 +99,7 @@ fn main() { ); match (test, &kind[..]) { (true, "test") => { + // For test binaries we call `cargo rustc --test target -- ` if let Err(code) = process( vec!["--test".to_string(), target.name].into_iter().chain( args, @@ -109,6 +110,11 @@ fn main() { } } (true, "lib") => { + // For libraries we call `cargo rustc -- --test ` + // Notice now that `--test` is a rustc arg rather than a cargo arg. This tells + // rustc to build a test harness which calls all #[test] functions. We don't + // use the harness since we execute each #[test] function's MIR ourselves before + // compilation even completes, but this option is necessary to build the library. if let Err(code) = process( vec!["--".to_string(), "--test".to_string()].into_iter().chain( args, @@ -119,6 +125,7 @@ fn main() { } } (false, "bin") => { + // For ordinary binaries we call `cargo rustc --bin target -- ` if let Err(code) = process( vec!["--bin".to_string(), target.name].into_iter().chain( args, diff --git a/src/bin/miri-rustc-tests.rs b/src/bin/miri-rustc-tests.rs index 73a8d19c309..fb3b231d41c 100644 --- a/src/bin/miri-rustc-tests.rs +++ b/src/bin/miri-rustc-tests.rs @@ -95,7 +95,7 @@ fn after_analysis<'a, 'tcx>(state: &mut CompileState<'a, 'tcx>) { if i.attrs.iter().any(|attr| attr.name() == "test") { let did = self.0.hir.body_owner_def_id(body_id); println!("running test: {}", self.0.def_path_debug_str(did)); - miri::eval_main(self.0, did, None, /*validate*/true); + miri::eval_main(self.0, did, /*validate*/true); self.1.session.abort_if_errors(); } } @@ -106,7 +106,7 @@ fn after_analysis<'a, 'tcx>(state: &mut CompileState<'a, 'tcx>) { state.hir_crate.unwrap().visit_all_item_likes(&mut Visitor(tcx, state)); } else if let Some((entry_node_id, _, _)) = *state.session.entry_fn.borrow() { let entry_def_id = tcx.hir.local_def_id(entry_node_id); - miri::eval_main(tcx, entry_def_id, None, /*validate*/true); + miri::eval_main(tcx, entry_def_id, /*validate*/true); state.session.abort_if_errors(); } else { diff --git a/src/bin/miri.rs b/src/bin/miri.rs index d7207da0b3c..d4494a83885 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -26,11 +26,6 @@ use std::path::PathBuf; struct MiriCompilerCalls { default: Box, - /// Whether to begin interpretation at the start_fn lang item or not. - /// - /// If false, the interpretation begins at the `main` function. - start_fn: bool, - /// Whether to enforce the validity invariant. validate: bool, } @@ -90,10 +85,9 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls { let this = *self; let mut control = this.default.build_controller(sess, matches); control.after_hir_lowering.callback = Box::new(after_hir_lowering); - let start_fn = this.start_fn; let validate = this.validate; control.after_analysis.callback = - Box::new(move |state| after_analysis(state, start_fn, validate)); + Box::new(move |state| after_analysis(state, validate)); control.after_analysis.stop = Compilation::Stop; control } @@ -109,7 +103,6 @@ fn after_hir_lowering(state: &mut CompileState) { fn after_analysis<'a, 'tcx>( state: &mut CompileState<'a, 'tcx>, - use_start_fn: bool, validate: bool, ) { state.session.abort_if_errors(); @@ -134,7 +127,7 @@ fn after_analysis<'a, 'tcx>( "running test: {}", self.tcx.def_path_debug_str(did), ); - miri::eval_main(self.tcx, did, None, self.validate); + miri::eval_main(self.tcx, did, self.validate); self.state.session.abort_if_errors(); } } @@ -147,13 +140,7 @@ fn after_analysis<'a, 'tcx>( ); } else if let Some((entry_node_id, _, _)) = *state.session.entry_fn.borrow() { let entry_def_id = tcx.hir.local_def_id(entry_node_id); - // Use start_fn lang item if we have -Zmiri-start-fn set - let start_wrapper = if use_start_fn { - Some(tcx.lang_items().start_fn().unwrap()) - } else { - None - }; - miri::eval_main(tcx, entry_def_id, start_wrapper, validate); + miri::eval_main(tcx, entry_def_id, validate); state.session.abort_if_errors(); } else { @@ -231,14 +218,9 @@ fn main() { args.push(find_sysroot()); } - let mut start_fn = false; let mut validate = true; args.retain(|arg| { match arg.as_str() { - "-Zmiri-start-fn" => { - start_fn = true; - false - }, "-Zmiri-disable-validation" => { validate = false; false @@ -251,7 +233,6 @@ fn main() { let result = rustc_driver::run(move || { rustc_driver::run_compiler(&args, Box::new(MiriCompilerCalls { default: Box::new(RustcDefaultCalls), - start_fn, validate, }), None, None) }); diff --git a/src/fn_call.rs b/src/fn_call.rs index eb889c1d495..0cbd891a34e 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -1,11 +1,9 @@ use rustc::ty; use rustc::ty::layout::{Align, LayoutOf, Size}; -use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX}; +use rustc::hir::def_id::DefId; use rustc::mir; use syntax::attr; -use std::mem; - use super::*; pub trait EvalContextExt<'tcx, 'mir> { @@ -19,8 +17,6 @@ pub trait EvalContextExt<'tcx, 'mir> { ret: mir::BasicBlock, ) -> EvalResult<'tcx>; - fn resolve_path(&self, path: &[&str]) -> EvalResult<'tcx, ty::Instance<'tcx>>; - /// Emulate a function that should have MIR but does not. /// This is solely to support execution without full MIR. /// Fail if emulating this function is not supported. @@ -643,40 +639,6 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx, 'mir> for super::MiriEvalCo Ok(()) } - /// Get an instance for a path. - fn resolve_path(&self, path: &[&str]) -> EvalResult<'tcx, ty::Instance<'tcx>> { - self.tcx - .crates() - .iter() - .find(|&&krate| self.tcx.original_crate_name(krate) == path[0]) - .and_then(|krate| { - let krate = DefId { - krate: *krate, - index: CRATE_DEF_INDEX, - }; - let mut items = self.tcx.item_children(krate); - let mut path_it = path.iter().skip(1).peekable(); - - while let Some(segment) = path_it.next() { - for item in mem::replace(&mut items, Default::default()).iter() { - if item.ident.name == *segment { - if path_it.peek().is_none() { - return Some(ty::Instance::mono(self.tcx.tcx, item.def.def_id())); - } - - items = self.tcx.item_children(item.def.def_id()); - break; - } - } - } - None - }) - .ok_or_else(|| { - let path = path.iter().map(|&s| s.to_owned()).collect(); - EvalErrorKind::PathNotFound(path).into() - }) - } - fn emulate_missing_fn( &mut self, path: String, @@ -704,7 +666,7 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx, 'mir> for super::MiriEvalCo "std::io::_print" | "std::io::_eprint" => { warn!( - "Ignoring output. To run programs that print, make sure you have a libstd with full MIR." + "Ignoring output. To run programs that prints, make sure you have a libstd with full MIR." ); } "std::thread::Builder::new" => { diff --git a/src/helpers.rs b/src/helpers.rs index de787145e22..c4aad2033e5 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,13 +1,18 @@ -use super::{Scalar, ScalarMaybeUndef, EvalResult}; +use std::mem; -pub trait FalibleScalarExt { +use rustc::ty; +use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX}; + +use super::*; + +pub trait ScalarExt { /// HACK: this function just extracts all bits if `defined != 0` /// Mainly used for args of C-functions and we should totally correctly fetch the size /// of their arguments fn to_bytes(self) -> EvalResult<'static, u128>; } -impl FalibleScalarExt for Scalar { +impl ScalarExt for Scalar { fn to_bytes(self) -> EvalResult<'static, u128> { match self { Scalar::Bits { bits, size } => { @@ -19,8 +24,49 @@ impl FalibleScalarExt for Scalar { } } -impl FalibleScalarExt for ScalarMaybeUndef { +impl ScalarExt for ScalarMaybeUndef { fn to_bytes(self) -> EvalResult<'static, u128> { self.not_undef()?.to_bytes() } } + +pub trait EvalContextExt<'tcx> { + fn resolve_path(&self, path: &[&str]) -> EvalResult<'tcx, ty::Instance<'tcx>>; +} + + +impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'mir, 'tcx, super::Evaluator<'tcx>> { + /// Get an instance for a path. + fn resolve_path(&self, path: &[&str]) -> EvalResult<'tcx, ty::Instance<'tcx>> { + self.tcx + .crates() + .iter() + .find(|&&krate| self.tcx.original_crate_name(krate) == path[0]) + .and_then(|krate| { + let krate = DefId { + krate: *krate, + index: CRATE_DEF_INDEX, + }; + let mut items = self.tcx.item_children(krate); + let mut path_it = path.iter().skip(1).peekable(); + + while let Some(segment) = path_it.next() { + for item in mem::replace(&mut items, Default::default()).iter() { + if item.ident.name == *segment { + if path_it.peek().is_none() { + return Some(ty::Instance::mono(self.tcx.tcx, item.def.def_id())); + } + + items = self.tcx.item_children(item.def.def_id()); + break; + } + } + } + None + }) + .ok_or_else(|| { + let path = path.iter().map(|&s| s.to_owned()).collect(); + EvalErrorKind::PathNotFound(path).into() + }) + } +} diff --git a/src/intrinsic.rs b/src/intrinsic.rs index 2b02f22a382..5c86075883b 100644 --- a/src/intrinsic.rs +++ b/src/intrinsic.rs @@ -6,7 +6,7 @@ use rustc::mir::interpret::{EvalResult, PointerArithmetic}; use super::{ PlaceTy, OpTy, Value, Scalar, ScalarMaybeUndef, Borrow, - FalibleScalarExt, OperatorEvalContextExt + ScalarExt, OperatorEvalContextExt }; pub trait EvalContextExt<'tcx> { diff --git a/src/lib.rs b/src/lib.rs index 1ff29828dab..ed23eef3f55 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,14 +41,14 @@ use operator::EvalContextExt as OperatorEvalContextExt; use intrinsic::EvalContextExt as IntrinsicEvalContextExt; use tls::{EvalContextExt as TlsEvalContextExt, TlsData}; use range_map::RangeMap; -use helpers::FalibleScalarExt; +#[allow(unused_imports)] // FIXME rustc bug https://github.com/rust-lang/rust/issues/53682 +use helpers::{ScalarExt, EvalContextExt as HelpersEvalContextExt}; use mono_hash_map::MonoHashMap; use stacked_borrows::{EvalContextExt as StackedBorEvalContextExt, Borrow}; pub fn create_ecx<'a, 'mir: 'a, 'tcx: 'mir>( tcx: TyCtxt<'a, 'tcx, 'tcx>, main_id: DefId, - start_wrapper: Option, validate: bool, ) -> EvalResult<'tcx, EvalContext<'a, 'mir, 'tcx, Evaluator<'tcx>>> { let mut ecx = EvalContext::new( @@ -67,8 +67,14 @@ pub fn create_ecx<'a, 'mir: 'a, 'tcx: 'mir>( )); } - if let Some(start_id) = start_wrapper { - let main_ret_ty = ecx.tcx.fn_sig(main_id).output(); + let libstd_has_mir = { + let rustc_panic = ecx.resolve_path(&["std", "panicking", "rust_panic"])?; + ecx.load_mir(rustc_panic.def).is_ok() + }; + + if libstd_has_mir { + let start_id = tcx.lang_items().start_fn().unwrap(); + let main_ret_ty = tcx.fn_sig(main_id).output(); let main_ret_ty = main_ret_ty.no_late_bound_regions().unwrap(); let start_instance = ty::Instance::resolve( ecx.tcx.tcx, @@ -143,10 +149,9 @@ pub fn create_ecx<'a, 'mir: 'a, 'tcx: 'mir>( pub fn eval_main<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, main_id: DefId, - start_wrapper: Option, validate: bool, ) { - let mut ecx = create_ecx(tcx, main_id, start_wrapper, validate).expect("Couldn't create ecx"); + let mut ecx = create_ecx(tcx, main_id, validate).expect("Couldn't create ecx"); let res: EvalResult = (|| { ecx.run()?; diff --git a/tests/compile-fail-fullmir/reallocate-change-alloc.rs b/tests/compile-fail-fullmir/reallocate-change-alloc.rs index c73f86bc172..1e2178811ea 100644 --- a/tests/compile-fail-fullmir/reallocate-change-alloc.rs +++ b/tests/compile-fail-fullmir/reallocate-change-alloc.rs @@ -9,7 +9,6 @@ fn main() { unsafe { let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap(); Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1).unwrap(); - let _z = *(x.as_ptr() as *mut u8); //~ ERROR constant evaluation error - //~^ NOTE dangling pointer was dereferenced + let _z = *(x.as_ptr() as *mut u8); //~ ERROR dangling pointer was dereferenced } } diff --git a/tests/compile-fail/alignment.rs b/tests/compile-fail/alignment.rs index 71161f5d6da..4faaa359df6 100644 --- a/tests/compile-fail/alignment.rs +++ b/tests/compile-fail/alignment.rs @@ -5,8 +5,7 @@ fn main() { let x_ptr: *mut u8 = &mut x[0]; let y_ptr = x_ptr as *mut u64; unsafe { - *y_ptr = 42; //~ ERROR constant evaluation error - //~^ NOTE tried to access memory with alignment 1, but alignment + *y_ptr = 42; //~ ERROR tried to access memory with alignment 1, but alignment } panic!("unreachable in miri"); } diff --git a/tests/compile-fail/assume.rs b/tests/compile-fail/assume.rs index d9eec480cd0..3026124e1f9 100644 --- a/tests/compile-fail/assume.rs +++ b/tests/compile-fail/assume.rs @@ -5,7 +5,6 @@ fn main() { unsafe { std::intrinsics::assume(x < 10); std::intrinsics::assume(x > 1); - std::intrinsics::assume(x > 42); //~ ERROR constant evaluation error - //~^ NOTE `assume` argument was false + std::intrinsics::assume(x > 42); //~ `assume` argument was false } } diff --git a/tests/compile-fail/bitop-beyond-alignment.rs b/tests/compile-fail/bitop-beyond-alignment.rs index c8cbc9a9184..a30c054ab5d 100644 --- a/tests/compile-fail/bitop-beyond-alignment.rs +++ b/tests/compile-fail/bitop-beyond-alignment.rs @@ -28,11 +28,10 @@ fn mk_rec() -> Rec { fn is_u64_aligned(u: &Tag) -> bool { let p: usize = unsafe { mem::transmute(u) }; let u64_align = std::mem::align_of::(); - return (p & (u64_align + 1)) == 0; //~ ERROR constant evaluation error - //~^ NOTE a raw memory access tried to access part of a pointer value as raw bytes + return (p & (u64_align + 1)) == 0; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes } pub fn main() { let x = mk_rec(); - assert!(is_u64_aligned(&x.t)); //~ NOTE inside call to `is_u64_aligned + assert!(is_u64_aligned(&x.t)); } diff --git a/tests/compile-fail/cast_box_int_to_fn_ptr.rs b/tests/compile-fail/cast_box_int_to_fn_ptr.rs index cbf370e0236..c3b1fa59588 100644 --- a/tests/compile-fail/cast_box_int_to_fn_ptr.rs +++ b/tests/compile-fail/cast_box_int_to_fn_ptr.rs @@ -7,6 +7,5 @@ fn main() { std::mem::transmute::<&usize, &fn(i32)>(&b) }; - (*g)(42) //~ ERROR constant evaluation error - //~^ NOTE a memory access tried to interpret some bytes as a pointer + (*g)(42) //~ ERROR a memory access tried to interpret some bytes as a pointer } diff --git a/tests/compile-fail/cast_int_to_fn_ptr.rs b/tests/compile-fail/cast_int_to_fn_ptr.rs index 2a08d9f1f9f..1971ce1557e 100644 --- a/tests/compile-fail/cast_int_to_fn_ptr.rs +++ b/tests/compile-fail/cast_int_to_fn_ptr.rs @@ -6,6 +6,5 @@ fn main() { std::mem::transmute::(42) }; - g(42) //~ ERROR constant evaluation error - //~^ NOTE a memory access tried to interpret some bytes as a pointer + g(42) //~ ERROR a memory access tried to interpret some bytes as a pointer } diff --git a/tests/compile-fail/dangling_pointer_deref.rs b/tests/compile-fail/dangling_pointer_deref.rs index 434f5c780b4..e8072077305 100644 --- a/tests/compile-fail/dangling_pointer_deref.rs +++ b/tests/compile-fail/dangling_pointer_deref.rs @@ -3,7 +3,6 @@ fn main() { let b = Box::new(42); &*b as *const i32 }; - let x = unsafe { *p }; //~ ERROR constant evaluation error - //~^ NOTE dangling pointer was dereferenced + let x = unsafe { *p }; //~ ERROR dangling pointer was dereferenced panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/div-by-zero-2.rs b/tests/compile-fail/div-by-zero-2.rs index 94145c2cf32..181a41ce3b2 100644 --- a/tests/compile-fail/div-by-zero-2.rs +++ b/tests/compile-fail/div-by-zero-2.rs @@ -11,6 +11,5 @@ #![allow(const_err)] fn main() { - let _n = 1 / 0; //~ ERROR constant evaluation error - //~^ NOTE attempt to divide by zero + let _n = 1 / 0; //~ ERROR attempt to divide by zero } diff --git a/tests/compile-fail/execute_memory.rs b/tests/compile-fail/execute_memory.rs index 2f8fea38d8f..d859e9072e3 100644 --- a/tests/compile-fail/execute_memory.rs +++ b/tests/compile-fail/execute_memory.rs @@ -7,7 +7,6 @@ fn main() { let x = box 42; unsafe { let f = std::mem::transmute::, fn()>(x); - f() //~ ERROR constant evaluation error - //~^ NOTE tried to treat a memory pointer as a function pointer + f() //~ ERROR tried to treat a memory pointer as a function pointer } } diff --git a/tests/compile-fail/fn_ptr_offset.rs b/tests/compile-fail/fn_ptr_offset.rs index e6d1da1e073..cccb21790d6 100644 --- a/tests/compile-fail/fn_ptr_offset.rs +++ b/tests/compile-fail/fn_ptr_offset.rs @@ -10,6 +10,5 @@ fn main() { let y : *mut u8 = unsafe { mem::transmute(x) }; let y = y.wrapping_offset(1); let x : fn() = unsafe { mem::transmute(y) }; - x(); //~ ERROR constant evaluation error - //~^ NOTE tried to use a function pointer after offsetting it + x(); //~ ERROR tried to use a function pointer after offsetting it } diff --git a/tests/compile-fail/modifying_constants.rs b/tests/compile-fail/modifying_constants.rs index ba46651f58e..27c74e8dc87 100644 --- a/tests/compile-fail/modifying_constants.rs +++ b/tests/compile-fail/modifying_constants.rs @@ -2,7 +2,6 @@ fn main() { let x = &1; // the `&1` is promoted to a constant, but it used to be that only the pointer is marked static, not the pointee let y = unsafe { &mut *(x as *const i32 as *mut i32) }; - *y = 42; //~ ERROR constant evaluation error - //~^ NOTE tried to modify constant memory + *y = 42; //~ ERROR tried to modify constant memory assert_eq!(*x, 42); } diff --git a/tests/compile-fail/never_say_never.rs b/tests/compile-fail/never_say_never.rs index 9821723deb3..634488489b5 100644 --- a/tests/compile-fail/never_say_never.rs +++ b/tests/compile-fail/never_say_never.rs @@ -7,8 +7,7 @@ fn main() { let y = &5; let x: ! = unsafe { - *(y as *const _ as *const !) //~ ERROR constant evaluation error - //~^ NOTE entered unreachable code + *(y as *const _ as *const !) //~ ERROR entered unreachable code }; f(x) } diff --git a/tests/compile-fail/never_transmute_void.rs b/tests/compile-fail/never_transmute_void.rs index 11fc0f068de..5620b6559cf 100644 --- a/tests/compile-fail/never_transmute_void.rs +++ b/tests/compile-fail/never_transmute_void.rs @@ -8,8 +8,7 @@ enum Void {} fn f(v: Void) -> ! { - match v {} //~ ERROR constant evaluation error - //~^ NOTE entered unreachable code + match v {} //~ ERROR entered unreachable code } fn main() { diff --git a/tests/compile-fail/out_of_bounds_read.rs b/tests/compile-fail/out_of_bounds_read.rs index 3ccdb365fee..1ab2d971477 100644 --- a/tests/compile-fail/out_of_bounds_read.rs +++ b/tests/compile-fail/out_of_bounds_read.rs @@ -1,6 +1,5 @@ fn main() { let v: Vec = vec![1, 2]; - let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR constant evaluation error - //~^ NOTE which has size 2 + let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR outside bounds of allocation panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/out_of_bounds_read2.rs b/tests/compile-fail/out_of_bounds_read2.rs index e8bcf455840..1ab2d971477 100644 --- a/tests/compile-fail/out_of_bounds_read2.rs +++ b/tests/compile-fail/out_of_bounds_read2.rs @@ -1,6 +1,5 @@ fn main() { let v: Vec = vec![1, 2]; - let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR constant evaluation error - //~^ NOTE outside bounds of allocation + let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR outside bounds of allocation panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/overflowing-lsh-neg.rs b/tests/compile-fail/overflowing-lsh-neg.rs index 825a8222663..8c70c9c7df7 100644 --- a/tests/compile-fail/overflowing-lsh-neg.rs +++ b/tests/compile-fail/overflowing-lsh-neg.rs @@ -12,6 +12,5 @@ #![allow(const_err)] fn main() { - let _n = 2i64 << -1; //~ ERROR constant evaluation error - //~^ NOTE attempt to shift left with overflow + let _n = 2i64 << -1; //~ ERROR attempt to shift left with overflow } diff --git a/tests/compile-fail/overflowing-rsh-2.rs b/tests/compile-fail/overflowing-rsh-2.rs index cf107a76ae2..7b7486343c3 100644 --- a/tests/compile-fail/overflowing-rsh-2.rs +++ b/tests/compile-fail/overflowing-rsh-2.rs @@ -12,6 +12,5 @@ fn main() { // Make sure we catch overflows that would be hidden by first casting the RHS to u32 - let _n = 1i64 >> (u32::max_value() as i64 + 1); //~ ERROR constant evaluation error - //~^ NOTE attempt to shift right with overflow + let _n = 1i64 >> (u32::max_value() as i64 + 1); //~ ERROR attempt to shift right with overflow } diff --git a/tests/compile-fail/overflowing-rsh.rs b/tests/compile-fail/overflowing-rsh.rs index ea53d7e7309..355cbd86988 100644 --- a/tests/compile-fail/overflowing-rsh.rs +++ b/tests/compile-fail/overflowing-rsh.rs @@ -11,6 +11,5 @@ #![allow(exceeding_bitshifts)] fn main() { - let _n = 1i64 >> 64; //~ ERROR constant evaluation error - //~^ NOTE attempt to shift right with overflow + let _n = 1i64 >> 64; //~ ERROR attempt to shift right with overflow } diff --git a/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs b/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs index 7c38c057469..5c0d5b463d5 100644 --- a/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs +++ b/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs @@ -6,7 +6,6 @@ fn main() { // "attempted to interpret some raw bytes as a pointer address" instead of // "attempted to read undefined bytes" } - let x = *p; //~ ERROR constant evaluation error - //~^ NOTE attempted to read undefined bytes + let x = *p; //~ ERROR attempted to read undefined bytes panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/pointer_byte_read_2.rs b/tests/compile-fail/pointer_byte_read_2.rs index c8a1a2e10f5..5df8c4782c7 100644 --- a/tests/compile-fail/pointer_byte_read_2.rs +++ b/tests/compile-fail/pointer_byte_read_2.rs @@ -3,6 +3,5 @@ fn main() { let y = &x; let z = &y as *const &i32 as *const u8; // the deref fails, because we are reading only a part of the pointer - let _ = unsafe { *z }; //~ ERROR constant evaluation error - //~^ NOTE tried to access part of a pointer value as raw bytes + let _ = unsafe { *z }; //~ ERROR tried to access part of a pointer value as raw bytes } diff --git a/tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs b/tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs index 89cf357e201..124f84de5bf 100644 --- a/tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs +++ b/tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs @@ -1,8 +1,7 @@ fn main() { let x: *const u8 = &1; let y: *const u8 = &2; - if x < y { //~ ERROR constant evaluation error - //~^ NOTE attempted to do invalid arithmetic on pointers + if x < y { //~ ERROR attempted to do invalid arithmetic on pointers unreachable!() } } diff --git a/tests/compile-fail/ptr_int_cast.rs b/tests/compile-fail/ptr_int_cast.rs index 11243921bfd..576f0c333d1 100644 --- a/tests/compile-fail/ptr_int_cast.rs +++ b/tests/compile-fail/ptr_int_cast.rs @@ -2,8 +2,7 @@ fn main() { let x = &1; // Casting down to u8 and back up to a pointer loses too much precision; this must not work. let x = x as *const i32; - let x = x as u8; //~ ERROR constant evaluation error - //~^ NOTE a raw memory access tried to access part of a pointer value as raw bytes + let x = x as u8; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes let x = x as *const i32; let _ = unsafe { *x }; } diff --git a/tests/compile-fail/reading_half_a_pointer.rs b/tests/compile-fail/reading_half_a_pointer.rs index 3ea693a3f0f..049dfca340e 100644 --- a/tests/compile-fail/reading_half_a_pointer.rs +++ b/tests/compile-fail/reading_half_a_pointer.rs @@ -24,7 +24,6 @@ fn main() { // starts 1 byte to the right, so using it would actually be wrong! let d_alias = &mut w.data as *mut _ as *mut *const u8; unsafe { - let _x = *d_alias; //~ ERROR constant evaluation error - //~^ NOTE tried to access part of a pointer value as raw bytes + let _x = *d_alias; //~ ERROR tried to access part of a pointer value as raw bytes } } diff --git a/tests/compile-fail/reference_to_packed.rs b/tests/compile-fail/reference_to_packed.rs index d18f314c8aa..14a2afc33f7 100644 --- a/tests/compile-fail/reference_to_packed.rs +++ b/tests/compile-fail/reference_to_packed.rs @@ -15,6 +15,5 @@ fn main() { y: 99, }; let p = unsafe { &foo.x }; - let i = *p; //~ ERROR constant evaluation error - //~^ NOTE tried to access memory with alignment 1, but alignment 4 is required + let i = *p; //~ ERROR tried to access memory with alignment 1, but alignment 4 is required } diff --git a/tests/compile-fail/static_memory_modification.rs b/tests/compile-fail/static_memory_modification.rs index 9e39c2c01c2..304ab6c6b74 100644 --- a/tests/compile-fail/static_memory_modification.rs +++ b/tests/compile-fail/static_memory_modification.rs @@ -3,8 +3,7 @@ static X: usize = 5; #[allow(mutable_transmutes)] fn main() { unsafe { - *std::mem::transmute::<&usize, &mut usize>(&X) = 6; //~ ERROR constant evaluation error - //~^ NOTE tried to modify constant memory + *std::mem::transmute::<&usize, &mut usize>(&X) = 6; //~ ERROR tried to modify constant memory assert_eq!(X, 6); } } diff --git a/tests/compile-fail/static_memory_modification2.rs b/tests/compile-fail/static_memory_modification2.rs index 2f702f09c80..01c3b9bb2d8 100644 --- a/tests/compile-fail/static_memory_modification2.rs +++ b/tests/compile-fail/static_memory_modification2.rs @@ -7,7 +7,6 @@ use std::mem::transmute; fn main() { unsafe { let s = "this is a test"; - transmute::<&[u8], &mut [u8]>(s.as_bytes())[4] = 42; //~ ERROR constant evaluation error - //~^ NOTE tried to modify constant memory + transmute::<&[u8], &mut [u8]>(s.as_bytes())[4] = 42; //~ ERROR tried to modify constant memory } } diff --git a/tests/compile-fail/static_memory_modification3.rs b/tests/compile-fail/static_memory_modification3.rs index 37d8bfe02ce..ff09aad1bd5 100644 --- a/tests/compile-fail/static_memory_modification3.rs +++ b/tests/compile-fail/static_memory_modification3.rs @@ -4,7 +4,6 @@ use std::mem::transmute; fn main() { unsafe { let bs = b"this is a test"; - transmute::<&[u8], &mut [u8]>(bs)[4] = 42; //~ ERROR constant evaluation error - //~^ NOTE tried to modify constant memory + transmute::<&[u8], &mut [u8]>(bs)[4] = 42; //~ ERROR tried to modify constant memory } } diff --git a/tests/compile-fail/transmute-pair-undef.rs b/tests/compile-fail/transmute-pair-undef.rs index 9509bb60e8b..acc6098af7e 100644 --- a/tests/compile-fail/transmute-pair-undef.rs +++ b/tests/compile-fail/transmute-pair-undef.rs @@ -16,6 +16,5 @@ fn main() { assert_eq!(byte, 0); } let v = unsafe { *z.offset(first_undef) }; - if v == 0 {} //~ ERROR constant evaluation error - //~^ NOTE attempted to read undefined bytes + if v == 0 {} //~ ERROR attempted to read undefined bytes } diff --git a/tests/compile-fail/transmute_fat.rs b/tests/compile-fail/transmute_fat.rs index 3e3bf51c3f2..e1f916910d7 100644 --- a/tests/compile-fail/transmute_fat.rs +++ b/tests/compile-fail/transmute_fat.rs @@ -10,6 +10,5 @@ fn main() { let bad = unsafe { std::mem::transmute::<&[u8], [u8; 8]>(&[1u8]) }; - let _ = bad[0] + bad[bad.len()-1]; //~ ERROR constant evaluation error - //~^ NOTE a raw memory access tried to access part of a pointer value as raw bytes + let _ = bad[0] + bad[bad.len()-1]; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes } diff --git a/tests/compile-fail/transmute_fat2.rs b/tests/compile-fail/transmute_fat2.rs index e9e21a84294..3121a139d92 100644 --- a/tests/compile-fail/transmute_fat2.rs +++ b/tests/compile-fail/transmute_fat2.rs @@ -7,6 +7,5 @@ fn main() { let bad = unsafe { std::mem::transmute::(42) }; - bad[0]; //~ ERROR constant evaluation error - //~^ NOTE index out of bounds: the len is 0 but the index is 0 + bad[0]; //~ ERROR index out of bounds: the len is 0 but the index is 0 } diff --git a/tests/compile-fail/unaligned_ptr_cast.rs b/tests/compile-fail/unaligned_ptr_cast.rs index f91def30d12..88285dc69f3 100644 --- a/tests/compile-fail/unaligned_ptr_cast.rs +++ b/tests/compile-fail/unaligned_ptr_cast.rs @@ -2,6 +2,5 @@ fn main() { let x = &2u16; let x = x as *const _ as *const u32; // This must fail because alignment is violated - let _x = unsafe { *x }; //~ ERROR constant evaluation error - //~^ NOTE tried to access memory with alignment 2, but alignment 4 is required + let _x = unsafe { *x }; //~ ERROR tried to access memory with alignment 2, but alignment 4 is required } diff --git a/tests/compile-fail/unaligned_ptr_cast2.rs b/tests/compile-fail/unaligned_ptr_cast2.rs index f87dab76ba3..7541079def2 100644 --- a/tests/compile-fail/unaligned_ptr_cast2.rs +++ b/tests/compile-fail/unaligned_ptr_cast2.rs @@ -3,6 +3,5 @@ fn main() { let x = x as *const _ as *const *const u8; // This must fail because alignment is violated. Test specifically for loading pointers, which have special code // in miri's memory. - let _x = unsafe { *x }; //~ ERROR constant evaluation error - //~^ NOTE tried to access memory with alignment 2, but alignment + let _x = unsafe { *x }; //~ ERROR tried to access memory with alignment 2, but alignment } diff --git a/tests/compile-fail/unaligned_ptr_cast_zst.rs b/tests/compile-fail/unaligned_ptr_cast_zst.rs index 45016473c97..1b9b55c6be1 100644 --- a/tests/compile-fail/unaligned_ptr_cast_zst.rs +++ b/tests/compile-fail/unaligned_ptr_cast_zst.rs @@ -2,6 +2,5 @@ fn main() { let x = &2u16; let x = x as *const _ as *const [u32; 0]; // This must fail because alignment is violated. Test specifically for loading ZST. - let _x = unsafe { *x }; //~ ERROR constant evaluation error - //~^ NOTE tried to access memory with alignment 2, but alignment 4 is required + let _x = unsafe { *x }; //~ ERROR tried to access memory with alignment 2, but alignment 4 is required } diff --git a/tests/compile-fail/undefined_byte_read.rs b/tests/compile-fail/undefined_byte_read.rs index 24718bce7db..1f092936148 100644 --- a/tests/compile-fail/undefined_byte_read.rs +++ b/tests/compile-fail/undefined_byte_read.rs @@ -4,7 +4,6 @@ fn main() { let v: Vec = Vec::with_capacity(10); let undef = unsafe { *v.get_unchecked(5) }; - let x = undef + 1; //~ ERROR: error - //~^ NOTE attempted to read undefined bytes + let x = undef + 1; //~ ERROR attempted to read undefined bytes panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/wild_pointer_deref.rs b/tests/compile-fail/wild_pointer_deref.rs index 4096cfb93e7..8eec9737546 100644 --- a/tests/compile-fail/wild_pointer_deref.rs +++ b/tests/compile-fail/wild_pointer_deref.rs @@ -1,6 +1,5 @@ fn main() { let p = 44 as *const i32; - let x = unsafe { *p }; //~ ERROR constant evaluation error - //~^ NOTE a memory access tried to interpret some bytes as a pointer + let x = unsafe { *p }; //~ ERROR a memory access tried to interpret some bytes as a pointer panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/zst.rs b/tests/compile-fail/zst.rs index efb2dafd36f..2b179dcc8a4 100644 --- a/tests/compile-fail/zst.rs +++ b/tests/compile-fail/zst.rs @@ -1,5 +1,4 @@ fn main() { let x = &() as *const () as *const i32; - let _ = unsafe { *x }; //~ ERROR constant evaluation error - //~^ NOTE tried to access memory with alignment 1, but alignment 4 is required + let _ = unsafe { *x }; //~ ERROR tried to access memory with alignment 1, but alignment 4 is required } diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 7bec3fa8de2..7a7d7e49b2d 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -101,9 +101,6 @@ fn miri_pass(sysroot: &Path, path: &str, target: &str, host: &str, need_fullmir: let mut flags = Vec::new(); flags.push(format!("--sysroot {}", sysroot.display())); flags.push("-Dwarnings -Dunused".to_owned()); // overwrite the -Aunused in compiletest-rs - if have_fullmir() { - flags.push("-Zmiri-start-fn".to_owned()); - } if opt { // FIXME: Using level 1 (instead of 3) for now, as the optimizer is pretty broken // and crashes...