do not promote comparing function pointers
This commit is contained in:
parent
1886d5fe1c
commit
1397836380
3 changed files with 10 additions and 2 deletions
|
|
@ -750,7 +750,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
|
|||
}
|
||||
|
||||
Rvalue::BinaryOp(op, ref lhs, _) => {
|
||||
if let ty::RawPtr(_) = lhs.ty(self.mir, self.tcx).sty {
|
||||
if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(self.mir, self.tcx).sty {
|
||||
assert!(op == BinOp::Eq || op == BinOp::Ne ||
|
||||
op == BinOp::Le || op == BinOp::Lt ||
|
||||
op == BinOp::Ge || op == BinOp::Gt ||
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ fn check_expr_kind<'a, 'tcx>(
|
|||
return NotPromotable;
|
||||
}
|
||||
match v.tables.node_id_to_type(lhs.hir_id).sty {
|
||||
ty::RawPtr(_) => {
|
||||
ty::RawPtr(_) | ty::FnPtr(..) => {
|
||||
assert!(op.node == hir::BinOpKind::Eq || op.node == hir::BinOpKind::Ne ||
|
||||
op.node == hir::BinOpKind::Le || op.node == hir::BinOpKind::Lt ||
|
||||
op.node == hir::BinOpKind::Ge || op.node == hir::BinOpKind::Gt);
|
||||
|
|
|
|||
8
src/test/run-pass/issues/issue-54696.rs
Normal file
8
src/test/run-pass/issues/issue-54696.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// run-pass
|
||||
|
||||
fn main() {
|
||||
// We shouldn't promote this
|
||||
&(main as fn() == main as fn());
|
||||
// Also check nested case
|
||||
&(&(main as fn()) == &(main as fn()));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue