diff --git a/Cargo.toml b/Cargo.toml index d690f87b536..f7caa4d1c2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ env_logger = "0.5" log = "0.4" [build-dependencies] -vergen = "2" +vergen = "3" [features] cargo_miri = ["cargo_metadata"] diff --git a/build.rs b/build.rs index 73eb68359a8..97bb9358832 100644 --- a/build.rs +++ b/build.rs @@ -8,17 +8,6 @@ fn main() { // Don't rebuild miri even if nothing changed println!("cargo:rerun-if-changed=build.rs"); // vergen - vergen().expect("Unable to generate vergen constants!"); -} - -fn vergen() -> vergen::Result<()> { - use vergen::{ConstantsFlags, Vergen}; - - let vergen = Vergen::new(ConstantsFlags::all())?; - - for (k, v) in vergen.build_info() { - println!("cargo:rustc-env={}={}", k.name(), v); - } - - Ok(()) + vergen::generate_cargo_keys(vergen::ConstantsFlags::all()) + .expect("Unable to generate vergen keys!"); } diff --git a/rust-toolchain b/rust-toolchain index c062614a6f9..5fb054b088e 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2018-10-01 +nightly-2018-10-10 diff --git a/src/lib.rs b/src/lib.rs index e25ae3a27d1..e4a389427c5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -233,6 +233,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> { type MemoryKinds = MiriMemoryKind; const MUT_STATIC_KIND: Option = Some(MiriMemoryKind::MutStatic); + const ENFORCE_VALIDITY: bool = false; // this is still WIP /// Returns Ok() when the function was handled, fail otherwise fn find_fn( diff --git a/src/operator.rs b/src/operator.rs index 6fed43914e1..4662a162679 100644 --- a/src/operator.rs +++ b/src/operator.rs @@ -142,8 +142,8 @@ fn ptr_eq( // allocations sit right next to each other. The C/C++ standards are // somewhat fuzzy about this case, so I think for now this check is // "good enough". - self.memory.check_bounds(left, false)?; - self.memory.check_bounds(right, false)?; + self.memory.check_bounds_ptr(left, false)?; + self.memory.check_bounds_ptr(right, false)?; // Two live in-bounds pointers, we can compare across allocations left == right } @@ -153,7 +153,7 @@ fn ptr_eq( (Scalar::Bits { bits, size }, Scalar::Ptr(ptr)) => { assert_eq!(size as u64, self.pointer_size().bytes()); let bits = bits as u64; - let (alloc_size, alloc_align) = self.memory.get_size_and_align(ptr.alloc_id)?; + let (alloc_size, alloc_align) = self.memory.get_size_and_align(ptr.alloc_id); // Case I: Comparing with NULL if bits == 0 { @@ -288,9 +288,9 @@ fn pointer_offset_inbounds( if let Scalar::Ptr(ptr) = ptr { // Both old and new pointer must be in-bounds. // (Of the same allocation, but that part is trivial with our representation.) - self.memory.check_bounds(ptr, false)?; + self.memory.check_bounds_ptr(ptr, false)?; let ptr = ptr.signed_offset(offset, self)?; - self.memory.check_bounds(ptr, false)?; + self.memory.check_bounds_ptr(ptr, false)?; Ok(Scalar::Ptr(ptr)) } else { // An integer pointer. They can only be offset by 0, and we pretend there diff --git a/tests/compile-fail/cast_fn_ptr5.rs b/tests/compile-fail/cast_fn_ptr5.rs new file mode 100644 index 00000000000..e4ac95e6767 --- /dev/null +++ b/tests/compile-fail/cast_fn_ptr5.rs @@ -0,0 +1,9 @@ +fn main() { + fn f() -> u32 { 42 } + + let g = unsafe { + std::mem::transmute:: u32, fn()>(f) + }; + + g() //~ ERROR tried to call a function with return type u32 passing return place of type () +} diff --git a/tests/compile-fail/deref_fn_ptr.rs b/tests/compile-fail/deref_fn_ptr.rs index 1b36c77bd32..68826a6ff03 100644 --- a/tests/compile-fail/deref_fn_ptr.rs +++ b/tests/compile-fail/deref_fn_ptr.rs @@ -1,8 +1,8 @@ fn f() {} fn main() { - let x: i32 = unsafe { - *std::mem::transmute::(f) //~ ERROR constant evaluation error: tried to dereference a function pointer + let x: u8 = unsafe { + *std::mem::transmute::(f) //~ ERROR constant evaluation error: tried to dereference a function pointer }; panic!("this should never print: {}", x); }