mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 13:40:15 +03:00
rustup; test for return type mismatch
This commit is contained in:
@@ -233,6 +233,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
|
||||
type MemoryKinds = MiriMemoryKind;
|
||||
|
||||
const MUT_STATIC_KIND: Option<MiriMemoryKind> = Some(MiriMemoryKind::MutStatic);
|
||||
const ENFORCE_VALIDITY: bool = false; // this is still WIP
|
||||
|
||||
/// Returns Ok() when the function was handled, fail otherwise
|
||||
fn find_fn(
|
||||
|
||||
+4
-4
@@ -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
|
||||
}
|
||||
@@ -296,9 +296,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 move around freely, as long as they do not overflow
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fn main() {
|
||||
fn f() -> u32 { 42 }
|
||||
|
||||
let g = unsafe {
|
||||
std::mem::transmute::<fn() -> u32, fn()>(f)
|
||||
};
|
||||
|
||||
g() //~ ERROR tried to call a function with return type u32 passing return place of type ()
|
||||
}
|
||||
Reference in New Issue
Block a user