Skip to content

Commit 538aedf

Browse files
committed
Auto merge of #1984 - RalfJung:rustup, r=RalfJung
rustup
2 parents 6a39eeb + 444396d commit 538aedf

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b8967b0d52a2ba5f0c9da0da03e78ccba5534e4a
1+
3d127e2040b57157936f5f24e114a8b4c9a505ef

tests/compile-fail/validity/execute_memory.rs

-8
This file was deleted.

tests/compile-fail/validity/fn_ptr_offset.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ fn main() {
66
let x : fn() = f;
77
let y : *mut u8 = unsafe { mem::transmute(x) };
88
let y = y.wrapping_offset(1);
9-
let _x : fn() = unsafe { mem::transmute(y) }; //~ ERROR expected a function pointer
9+
let _x : fn() = unsafe { mem::transmute(y) }; //~ ERROR encountered a potentially null function pointer
1010
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![allow(invalid_value)]
2+
3+
fn main() {
4+
let _b: fn() = unsafe { std::mem::transmute(0usize) }; //~ ERROR encountered a potentially null function pointer
5+
}

tests/compile-fail/validity/invalid_fnptr_uninit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ union MyUninit {
66
}
77

88
fn main() {
9-
let _b = unsafe { MyUninit { init: () }.uninit }; //~ ERROR encountered uninitialized bytes, but expected a function pointer
9+
let _b = unsafe { MyUninit { init: () }.uninit }; //~ ERROR encountered uninitialized bytes
1010
}

tests/run-pass/function_pointers.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::mem;
2+
13
trait Answer {
24
fn answer() -> Self;
35
}
@@ -56,4 +58,13 @@ fn main() {
5658
assert!(return_fn_ptr(g) == g);
5759
assert!(return_fn_ptr(g) as unsafe fn() -> i32 == g as fn() -> i32 as unsafe fn() -> i32);
5860
assert!(return_fn_ptr(f) != f);
61+
62+
// Any non-null value is okay for function pointers.
63+
unsafe {
64+
let _x: fn() = mem::transmute(1usize);
65+
let mut b = Box::new(42);
66+
let ptr = &mut *b as *mut _;
67+
drop(b);
68+
let _x: fn() = mem::transmute(ptr);
69+
}
5970
}

0 commit comments

Comments
 (0)