Skip to content

Commit c400932

Browse files
committed
remove redundant check for 0 as *const, which is already made in type_check.rs
1 parent 2da6069 commit c400932

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

c2rust-analyze/src/dataflow/type_check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ impl<'tcx> TypeChecker<'tcx, '_> {
244244
}
245245
}
246246
AggregateKind::Tuple => {
247-
assert!(matches!(lty.kind(), TyKind::Tuple(..)));
247+
assert!(matches!(rvalue_lty.kind(), TyKind::Tuple(..)));
248248
// Pseudo-assign from each operand to the element type of the tuple.
249-
for (op, elem_lty) in ops.iter().zip(lty.args.iter()) {
249+
for (op, elem_lty) in ops.iter().zip(rvalue_lty.args.iter()) {
250250
let op_lty = self.acx.type_of(op);
251251
self.do_assign(elem_lty, op_lty);
252252
}

c2rust-analyze/src/main.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ use rustc_hir::def_id::{DefId, LocalDefId};
3434
use rustc_index::vec::IndexVec;
3535
use rustc_middle::mir::visit::Visitor;
3636
use rustc_middle::mir::{
37-
AggregateKind, BindingForm, Body, CastKind, LocalDecl, LocalInfo, LocalKind, Location, Operand,
38-
Rvalue, StatementKind,
37+
AggregateKind, BindingForm, Body, LocalDecl, LocalInfo, LocalKind, Location, Operand, Rvalue,
38+
StatementKind,
3939
};
4040
use rustc_middle::ty::tls;
4141
use rustc_middle::ty::{GenericArgKind, Ty, TyCtxt, TyKind, WithOptConstParam};
@@ -394,15 +394,6 @@ fn label_rvalue_tys<'tcx>(acx: &mut AnalysisCtxt<'_, 'tcx>, mir: &Body<'tcx>) {
394394
}
395395
_ => continue,
396396
},
397-
Rvalue::Cast(CastKind::PointerFromExposedAddress, ref op, ty) => {
398-
// We support only one case here, which is the case of null pointers
399-
// constructed via casts such as `0 as *const T`
400-
if let Some(true) = op.constant().cloned().map(util::is_null_const) {
401-
acx.assign_pointer_ids(ty)
402-
} else {
403-
panic!("Creating non-null pointers from exposed addresses not supported");
404-
}
405-
}
406397
Rvalue::Cast(_, _, ty) => acx.assign_pointer_ids(ty),
407398
_ => continue,
408399
};

0 commit comments

Comments
 (0)