Skip to content

Commit 6d20f40

Browse files
committed
(c2rust-analyze) Revert the use of is_transmutable_to in TypeChecker::do_unify (back to strict equality) as #883 resolved this (#839 (comment)).
1 parent 32ca464 commit 6d20f40

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

c2rust-analyze/src/dataflow/type_check.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use super::DataflowConstraints;
22
use crate::c_void_casts::CVoidCastDirection;
33
use crate::context::{AnalysisCtxt, LTy, PermissionSet, PointerId};
44
use crate::util::{
5-
describe_rvalue, is_null_const, is_transmutable_ptr_cast, is_transmutable_to, ty_callee,
6-
Callee, RvalueDesc,
5+
describe_rvalue, is_null_const, is_transmutable_ptr_cast, ty_callee, Callee, RvalueDesc,
76
};
87
use assert_matches::assert_matches;
98
use rustc_hir::def_id::DefId;
@@ -276,7 +275,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
276275

277276
/// Unify corresponding [`PointerId`]s in `pl_lty` and `rv_lty`.
278277
///
279-
/// The two inputs must have compatible ([safely transmutable](is_transmutable_to)) underlying types.
278+
/// The two inputs must have identical underlying types.
280279
/// For any position where the underlying type has a pointer,
281280
/// this function unifies the [`PointerId`]s that `pl_lty` and `rv_lty` have at that position.
282281
/// For example, given
@@ -292,10 +291,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
292291
fn do_unify(&mut self, pl_lty: LTy<'tcx>, rv_lty: LTy<'tcx>) {
293292
let rv_ty = self.acx.tcx().erase_regions(rv_lty.ty);
294293
let pl_ty = self.acx.tcx().erase_regions(pl_lty.ty);
295-
assert!(
296-
is_transmutable_to(rv_ty, pl_ty),
297-
"types not transmutable (compatible), so PointerId unification cannot be done: *{rv_ty:?} as *{pl_ty:?}",
298-
);
294+
assert_eq!(rv_ty, pl_ty);
299295
for (sub_lty1, sub_lty2) in pl_lty.iter().zip(rv_lty.iter()) {
300296
eprintln!("equate {:?} = {:?}", sub_lty1, sub_lty2);
301297
if sub_lty1.label != PointerId::NONE || sub_lty2.label != PointerId::NONE {

0 commit comments

Comments
 (0)