Skip to content

Commit a439262

Browse files
authored
Merge branch 'master' into ptr-offset
2 parents 0641d5b + 5a496dd commit a439262

File tree

7 files changed

+21
-22
lines changed

7 files changed

+21
-22
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ env_logger = "0.5"
3232
log = "0.4"
3333

3434
[build-dependencies]
35-
vergen = "2"
35+
vergen = "3"
3636

3737
[features]
3838
cargo_miri = ["cargo_metadata"]

build.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@ fn main() {
88
// Don't rebuild miri even if nothing changed
99
println!("cargo:rerun-if-changed=build.rs");
1010
// vergen
11-
vergen().expect("Unable to generate vergen constants!");
12-
}
13-
14-
fn vergen() -> vergen::Result<()> {
15-
use vergen::{ConstantsFlags, Vergen};
16-
17-
let vergen = Vergen::new(ConstantsFlags::all())?;
18-
19-
for (k, v) in vergen.build_info() {
20-
println!("cargo:rustc-env={}={}", k.name(), v);
21-
}
22-
23-
Ok(())
11+
vergen::generate_cargo_keys(vergen::ConstantsFlags::all())
12+
.expect("Unable to generate vergen keys!");
2413
}

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2018-10-01
1+
nightly-2018-10-10

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
233233
type MemoryKinds = MiriMemoryKind;
234234

235235
const MUT_STATIC_KIND: Option<MiriMemoryKind> = Some(MiriMemoryKind::MutStatic);
236+
const ENFORCE_VALIDITY: bool = false; // this is still WIP
236237

237238
/// Returns Ok() when the function was handled, fail otherwise
238239
fn find_fn(

src/operator.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'mir, 'tcx, super:
142142
// allocations sit right next to each other. The C/C++ standards are
143143
// somewhat fuzzy about this case, so I think for now this check is
144144
// "good enough".
145-
self.memory.check_bounds(left, false)?;
146-
self.memory.check_bounds(right, false)?;
145+
self.memory.check_bounds_ptr(left, false)?;
146+
self.memory.check_bounds_ptr(right, false)?;
147147
// Two live in-bounds pointers, we can compare across allocations
148148
left == right
149149
}
@@ -153,7 +153,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'mir, 'tcx, super:
153153
(Scalar::Bits { bits, size }, Scalar::Ptr(ptr)) => {
154154
assert_eq!(size as u64, self.pointer_size().bytes());
155155
let bits = bits as u64;
156-
let (alloc_size, alloc_align) = self.memory.get_size_and_align(ptr.alloc_id)?;
156+
let (alloc_size, alloc_align) = self.memory.get_size_and_align(ptr.alloc_id);
157157

158158
// Case I: Comparing with NULL
159159
if bits == 0 {
@@ -288,9 +288,9 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'mir, 'tcx, super:
288288
if let Scalar::Ptr(ptr) = ptr {
289289
// Both old and new pointer must be in-bounds.
290290
// (Of the same allocation, but that part is trivial with our representation.)
291-
self.memory.check_bounds(ptr, false)?;
291+
self.memory.check_bounds_ptr(ptr, false)?;
292292
let ptr = ptr.signed_offset(offset, self)?;
293-
self.memory.check_bounds(ptr, false)?;
293+
self.memory.check_bounds_ptr(ptr, false)?;
294294
Ok(Scalar::Ptr(ptr))
295295
} else {
296296
// An integer pointer. They can only be offset by 0, and we pretend there

tests/compile-fail/cast_fn_ptr5.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn main() {
2+
fn f() -> u32 { 42 }
3+
4+
let g = unsafe {
5+
std::mem::transmute::<fn() -> u32, fn()>(f)
6+
};
7+
8+
g() //~ ERROR tried to call a function with return type u32 passing return place of type ()
9+
}

tests/compile-fail/deref_fn_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
fn f() {}
22

33
fn main() {
4-
let x: i32 = unsafe {
5-
*std::mem::transmute::<fn(), *const i32>(f) //~ ERROR constant evaluation error: tried to dereference a function pointer
4+
let x: u8 = unsafe {
5+
*std::mem::transmute::<fn(), *const u8>(f) //~ ERROR constant evaluation error: tried to dereference a function pointer
66
};
77
panic!("this should never print: {}", x);
88
}

0 commit comments

Comments
 (0)