about summary refs log tree commit diff
path: root/src/test/ui/function-pointer
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-06-22 07:37:54 +0900
committerGitHub <noreply@github.com>2021-06-22 07:37:54 +0900
commitfdb1daa00cf73b4f9793bfdc0355d084c7d67b0c (patch)
tree79843c472ed9689a4f5fbe1e3e438da97199bed7 /src/test/ui/function-pointer
parentd2852354dcf3378516a8ef0d005405c2a128c0a1 (diff)
parent22029a2ea7ee0a6bc2dcde64a6799aaa5df5c6af (diff)
downloadrust-fdb1daa00cf73b4f9793bfdc0355d084c7d67b0c.tar.gz
rust-fdb1daa00cf73b4f9793bfdc0355d084c7d67b0c.zip
Rollup merge of #86398 - yerke:add-test-for-issue-54685, r=Mark-Simulacrum
Add regression test for issue #54685

Closes #54685

Took the test from #54685 and modified it a bit to use assertion. Made sure that the updated test catches the original issue on 1.50 by running on Compiler Explorer (https://godbolt.org/z/E64onYeT5).
Diffstat (limited to 'src/test/ui/function-pointer')
-rw-r--r--src/test/ui/function-pointer/function-pointer-comparison-issue-54685.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/ui/function-pointer/function-pointer-comparison-issue-54685.rs b/src/test/ui/function-pointer/function-pointer-comparison-issue-54685.rs
new file mode 100644
index 00000000000..a036d10e639
--- /dev/null
+++ b/src/test/ui/function-pointer/function-pointer-comparison-issue-54685.rs
@@ -0,0 +1,31 @@
+// min-llvm-version: 12.0
+// compile-flags: -C opt-level=3
+// run-pass
+
+fn foo(_i: i32) -> i32 {
+    1
+}
+fn bar(_i: i32) -> i32 {
+    1
+}
+
+fn main() {
+    let x: fn(i32) -> i32 = foo;
+    let y: fn(i32) -> i32 = bar;
+
+    let s1;
+    if x == y {
+        s1 = "same".to_string();
+    } else {
+        s1 = format!("{:?}, {:?}", x, y);
+    }
+
+    let s2;
+    if x == y {
+        s2 = "same".to_string();
+    } else {
+        s2 = format!("{:?}, {:?}", x, y);
+    }
+
+    assert_eq!(s1, s2);
+}