Skip to content

Commit 3d71bad

Browse files
authored
Rollup merge of #122173 - compiler-errors:ptr-equality-in-ctfe, r=lcnr
Don't ICE in CTFE if raw/fn-ptr types differ Fixes #121688 r? lcnr
2 parents 3e634f8 + 025ad40 commit 3d71bad

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

compiler/rustc_const_eval/src/transform/check_consts/check.rs

-1
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
581581
if is_int_bool_or_char(lhs_ty) && is_int_bool_or_char(rhs_ty) {
582582
// Int, bool, and char operations are fine.
583583
} else if lhs_ty.is_fn_ptr() || lhs_ty.is_unsafe_ptr() {
584-
assert_eq!(lhs_ty, rhs_ty);
585584
assert!(matches!(
586585
op,
587586
BinOp::Eq
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const fn cmp(x: fn(&'static ()), y: for<'a> fn(&'a ())) -> bool {
2+
x == y
3+
//~^ ERROR pointers cannot be reliably compared during const eval
4+
}
5+
6+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: pointers cannot be reliably compared during const eval
2+
--> $DIR/different-fn-ptr-binders-during-ctfe.rs:2:5
3+
|
4+
LL | x == y
5+
| ^^^^^^
6+
|
7+
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
8+
9+
error: aborting due to 1 previous error
10+

0 commit comments

Comments
 (0)