Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f5c81e0a986e4285d3d0fd781a1bd475753eb12c
4af3ee8ee2a2bc1286b021db7600ba990359cf3f
22 changes: 10 additions & 12 deletions tests/run-pass/coerce_non_capture_closure_to_fn_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ static FOO: fn() = || { assert_ne!(42, 43) };
static BAR: fn(i32, i32) = |a, b| { assert_ne!(a, b) };

// use to first make the closure FnOnce() before making it fn()
fn magic0<R, F: FnOnce() -> R>(f: F) -> F { f }
fn magic1<T, R, F: FnOnce(T) -> R>(f: F) -> F { f }
fn force_once0<R, F: FnOnce() -> R>(f: F) -> F { f }
fn force_once1<T, R, F: FnOnce(T) -> R>(f: F) -> F { f }
fn force_mut0<R, F: FnMut() -> R>(f: F) -> F { f }
fn force_mut1<T, R, F: FnMut(T) -> R>(f: F) -> F { f }

fn main() {
FOO();
Expand All @@ -18,19 +20,15 @@ fn main() {

let f: fn() = ||{};
f();
let f = magic0(||{}) as fn();
let f = force_once0(||{}) as fn();
f();
let f = force_mut0(||{}) as fn();
f();

let g: fn(i32) = |i| assert_eq!(i, 2);
g(2);
let g = magic1(|i| assert_eq!(i, 2)) as fn(i32);
let g = force_once1(|i| assert_eq!(i, 2)) as fn(i32);
g(2);
let g = force_mut1(|i| assert_eq!(i, 2)) as fn(i32);
g(2);

// FIXME: This fails with "invalid use of NULL pointer" <https://github.com/rust-lang/miri/issues/1075>
//let h: fn() -> ! = || std::process::exit(0);
//h();
// FIXME: This does not even compile?!? <https://github.com/rust-lang/rust/issues/66738>
//let h = magic0(|| std::process::exit(0)) as fn() -> !;
//h();
// Once these tests pass, they should be in separate files as they terminate the process.
}
6 changes: 6 additions & 0 deletions tests/run-pass/issue-miri-1075.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {
let f: fn() -> ! = || std::process::exit(0);
f();

// FIXME: Also add a test for <https://github.com/rust-lang/rust/issues/66738>, once that is fixed.
}