Skip to content

Commit

Permalink
Rollup merge of #122173 - compiler-errors:ptr-equality-in-ctfe, r=lcnr
Browse files Browse the repository at this point in the history
Don't ICE in CTFE if raw/fn-ptr types differ

Fixes #121688

r? lcnr
  • Loading branch information
matthiaskrgr authored Mar 8, 2024
2 parents 3e634f8 + 025ad40 commit 3d71bad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/consts/different-fn-ptr-binders-during-ctfe.rs
Original file line number Diff line number Diff line change
@@ -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() {}
10 changes: 10 additions & 0 deletions tests/ui/consts/different-fn-ptr-binders-during-ctfe.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3d71bad

Please sign in to comment.