From 7ec9601a0b8479d570a581ddcbaa62c2919d08a1 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Tue, 13 Feb 2024 17:20:48 +0000 Subject: [PATCH] Add test. --- tests/mir-opt/issue_120925_unsafefncast.rs | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/mir-opt/issue_120925_unsafefncast.rs diff --git a/tests/mir-opt/issue_120925_unsafefncast.rs b/tests/mir-opt/issue_120925_unsafefncast.rs new file mode 100644 index 00000000000..f80ae66efda --- /dev/null +++ b/tests/mir-opt/issue_120925_unsafefncast.rs @@ -0,0 +1,25 @@ +// Verify that we do not ICE when attempting to interpret casts between fn types. +// skip-filecheck + +static FOO: fn() = || assert_ne!(42, 43); +static BAR: fn(i32, i32) = |a, b| assert_ne!(a, b); + +fn main() { + FOO(); + + let bar: unsafe fn(i32, i32) = BAR; + + let f: fn() = || {}; + f(); + + f(); + + f(); + + let g: fn(i32) = |i| assert_eq!(i, 2); + g(2); + + g(2); + + g(2); +}