about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/check.rs1
-rw-r--r--tests/ui/consts/different-fn-ptr-binders-during-ctfe.rs6
-rw-r--r--tests/ui/consts/different-fn-ptr-binders-during-ctfe.stderr10
3 files changed, 16 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs
index 0b41b4f9682..7ec78e7b9cf 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs
@@ -581,7 +581,6 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
                 if is_int_bool_or_char(lhs_ty) && is_int_bool_or_char(rhs_ty) {
                     // Int, bool, and char operations are fine.
                 } else if lhs_ty.is_fn_ptr() || lhs_ty.is_unsafe_ptr() {
-                    assert_eq!(lhs_ty, rhs_ty);
                     assert!(matches!(
                         op,
                         BinOp::Eq
diff --git a/tests/ui/consts/different-fn-ptr-binders-during-ctfe.rs b/tests/ui/consts/different-fn-ptr-binders-during-ctfe.rs
new file mode 100644
index 00000000000..b378542e573
--- /dev/null
+++ b/tests/ui/consts/different-fn-ptr-binders-during-ctfe.rs
@@ -0,0 +1,6 @@
+const fn cmp(x: fn(&'static ()), y: for<'a> fn(&'a ())) -> bool {
+    x == y
+    //~^ ERROR pointers cannot be reliably compared during const eval
+}
+
+fn main() {}
diff --git a/tests/ui/consts/different-fn-ptr-binders-during-ctfe.stderr b/tests/ui/consts/different-fn-ptr-binders-during-ctfe.stderr
new file mode 100644
index 00000000000..43a7b9ce66c
--- /dev/null
+++ b/tests/ui/consts/different-fn-ptr-binders-during-ctfe.stderr
@@ -0,0 +1,10 @@
+error: pointers cannot be reliably compared during const eval
+  --> $DIR/different-fn-ptr-binders-during-ctfe.rs:2:5
+   |
+LL |     x == y
+   |     ^^^^^^
+   |
+   = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
+
+error: aborting due to 1 previous error
+