about summary refs log tree commit diff
path: root/tests/ui/lint/fn-ptr-comparisons-some.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/lint/fn-ptr-comparisons-some.rs')
-rw-r--r--tests/ui/lint/fn-ptr-comparisons-some.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/lint/fn-ptr-comparisons-some.rs b/tests/ui/lint/fn-ptr-comparisons-some.rs
new file mode 100644
index 00000000000..152e16b9884
--- /dev/null
+++ b/tests/ui/lint/fn-ptr-comparisons-some.rs
@@ -0,0 +1,17 @@
+// This test checks that we lint on Option of fn ptr.
+//
+// https://github.com/rust-lang/rust/issues/134527.
+//
+//@ check-pass
+
+unsafe extern "C" fn func() {}
+
+type FnPtr = unsafe extern "C" fn();
+
+fn main() {
+    let _ = Some::<FnPtr>(func) == Some(func as unsafe extern "C" fn());
+    //~^ WARN function pointer comparisons
+
+    // Undecided as of https://github.com/rust-lang/rust/pull/134536
+    assert_eq!(Some::<FnPtr>(func), Some(func as unsafe extern "C" fn()));
+}