From bba9359256d5b5ffa4caef5c60237ca2b325c7f7 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 27 Nov 2019 21:50:20 +0100 Subject: [PATCH 1/3] expand coerce fn test --- .../coerce_non_capture_closure_to_fn_ptr.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/run-pass/coerce_non_capture_closure_to_fn_ptr.rs b/tests/run-pass/coerce_non_capture_closure_to_fn_ptr.rs index 4da2c0c61b..71f244b2bc 100644 --- a/tests/run-pass/coerce_non_capture_closure_to_fn_ptr.rs +++ b/tests/run-pass/coerce_non_capture_closure_to_fn_ptr.rs @@ -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: F) -> F { f } -fn magic1 R>(f: F) -> F { f } +fn force_once0 R>(f: F) -> F { f } +fn force_once1 R>(f: F) -> F { f } +fn force_mut0 R>(f: F) -> F { f } +fn force_mut1 R>(f: F) -> F { f } fn main() { FOO(); @@ -18,12 +20,16 @@ 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" From 9f9e547d791c5031f2dde9fa5424903d52934cc1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 27 Nov 2019 23:28:59 +0100 Subject: [PATCH 2/3] test diverging closure fn ptr coercion --- tests/run-pass/coerce_non_capture_closure_to_fn_ptr.rs | 8 -------- tests/run-pass/issue-miri-1075.rs | 6 ++++++ 2 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 tests/run-pass/issue-miri-1075.rs diff --git a/tests/run-pass/coerce_non_capture_closure_to_fn_ptr.rs b/tests/run-pass/coerce_non_capture_closure_to_fn_ptr.rs index 71f244b2bc..32393a37d2 100644 --- a/tests/run-pass/coerce_non_capture_closure_to_fn_ptr.rs +++ b/tests/run-pass/coerce_non_capture_closure_to_fn_ptr.rs @@ -31,12 +31,4 @@ fn main() { 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" - //let h: fn() -> ! = || std::process::exit(0); - //h(); - // FIXME: This does not even compile?!? - //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. } diff --git a/tests/run-pass/issue-miri-1075.rs b/tests/run-pass/issue-miri-1075.rs new file mode 100644 index 0000000000..8bacaca9c2 --- /dev/null +++ b/tests/run-pass/issue-miri-1075.rs @@ -0,0 +1,6 @@ +fn main() { + let f: fn() -> ! = || std::process::exit(0); + f(); + + // FIXME: Also add a test for , once that is fixed. +} From 42732cc9bb6cec922b9cc0ef723e97dd0b83bc52 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 2 Dec 2019 15:42:38 +0100 Subject: [PATCH 3/3] rustup --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index 3a0cf96e13..b2b29eb527 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -f5c81e0a986e4285d3d0fd781a1bd475753eb12c +4af3ee8ee2a2bc1286b021db7600ba990359cf3f