Skip to content

Commit eea70af

Browse files
committed
Remove NullOp
1 parent ea72d0f commit eea70af

File tree

4 files changed

+3
-36
lines changed

4 files changed

+3
-36
lines changed

crates/flux-refineck/src/checker.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ impl<'ck, 'genv, 'tcx, M: Mode> Checker<'ck, 'genv, 'tcx, M> {
12871287
self.check_binary_op(infcx, env, stmt_span, *bin_op, op1, op2)
12881288
.with_span(stmt_span)
12891289
}
1290-
Rvalue::NullaryOp(null_op, ty) => Ok(self.check_nullary_op(*null_op, ty)),
1290+
12911291
Rvalue::UnaryOp(UnOp::PtrMetadata, Operand::Copy(place))
12921292
| Rvalue::UnaryOp(UnOp::PtrMetadata, Operand::Move(place)) => {
12931293
self.check_raw_ptr_metadata(infcx, env, stmt_span, place)
@@ -1413,16 +1413,6 @@ impl<'ck, 'genv, 'tcx, M: Mode> Checker<'ck, 'genv, 'tcx, M> {
14131413
}
14141414
}
14151415

1416-
fn check_nullary_op(&self, null_op: mir::NullOp, _ty: &ty::Ty) -> Ty {
1417-
match null_op {
1418-
mir::NullOp::SizeOf | mir::NullOp::AlignOf => {
1419-
// We could try to get the layout of type to index this with the actual value, but
1420-
// this enough for now. Revisit if we ever need the precision.
1421-
Ty::uint(UintTy::Usize)
1422-
}
1423-
}
1424-
}
1425-
14261416
fn check_unary_op(
14271417
&mut self,
14281418
infcx: &mut InferCtxt<'_, 'genv, 'tcx>,

crates/flux-refineck/src/ghost_statements/fold_unfold.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ impl<M: Mode> FoldUnfoldAnalysis<'_, '_, '_, M> {
335335
Rvalue::Repeat(op, _) => {
336336
self.operand(op, env)?;
337337
}
338-
Rvalue::NullaryOp(_, _) => {}
339338
}
340339
M::projection(self, env, place)?;
341340
}

crates/flux-rustc-bridge/src/lowering.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_trait_selection::traits::SelectionContext;
2121
use super::{
2222
mir::{
2323
AggregateKind, AssertKind, BasicBlockData, BinOp, Body, CallArgs, CastKind, Constant,
24-
LocalDecl, NonDivergingIntrinsic, NullOp, Operand, Place, PlaceElem, PointerCast, Rvalue,
24+
LocalDecl, NonDivergingIntrinsic, Operand, Place, PlaceElem, PointerCast, Rvalue,
2525
Statement, StatementKind, Terminator, TerminatorKind,
2626
},
2727
ty::{
@@ -469,9 +469,6 @@ impl<'sess, 'tcx> MirLoweringCtxt<'_, 'sess, 'tcx> {
469469
self.lower_operand(op2)?,
470470
))
471471
}
472-
rustc_mir::Rvalue::NullaryOp(null_op, ty) => {
473-
Ok(Rvalue::NullaryOp(self.lower_null_op(*null_op)?, ty.lower(self.tcx)?))
474-
}
475472
rustc_mir::Rvalue::UnaryOp(un_op, op) => {
476473
Ok(Rvalue::UnaryOp(*un_op, self.lower_operand(op)?))
477474
}
@@ -487,6 +484,7 @@ impl<'sess, 'tcx> MirLoweringCtxt<'_, 'sess, 'tcx> {
487484
Ok(Rvalue::ShallowInitBox(self.lower_operand(op)?, ty.lower(self.tcx)?))
488485
}
489486
rustc_mir::Rvalue::ThreadLocalRef(_)
487+
| rustc_mir::Rvalue::NullaryOp(..)
490488
| rustc_mir::Rvalue::CopyForDeref(_)
491489
| rustc_mir::Rvalue::WrapUnsafeBinder(..) => {
492490
Err(UnsupportedReason::new(format!("unsupported rvalue `{rvalue:?}`")))
@@ -602,18 +600,6 @@ impl<'sess, 'tcx> MirLoweringCtxt<'_, 'sess, 'tcx> {
602600
}
603601
}
604602

605-
fn lower_null_op(&self, null_op: rustc_mir::NullOp) -> Result<NullOp, UnsupportedReason> {
606-
match null_op {
607-
rustc_mir::NullOp::SizeOf => Ok(NullOp::SizeOf),
608-
rustc_mir::NullOp::AlignOf => Ok(NullOp::AlignOf),
609-
rustc_mir::NullOp::OffsetOf(_)
610-
| rustc_mir::NullOp::UbChecks
611-
| rustc_mir::NullOp::ContractChecks => {
612-
Err(UnsupportedReason::new(format!("unsupported nullary op `{null_op:?}`")))
613-
}
614-
}
615-
}
616-
617603
fn lower_operand(&self, op: &rustc_mir::Operand<'tcx>) -> Result<Operand, UnsupportedReason> {
618604
match op {
619605
rustc_mir::Operand::Copy(place) => Ok(Operand::Copy(lower_place(self.tcx, place)?)),

crates/flux-rustc-bridge/src/mir.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ pub enum Rvalue {
209209
RawPtr(RawPtrKind, Place),
210210
Cast(CastKind, Operand, Ty),
211211
BinaryOp(BinOp, Operand, Operand),
212-
NullaryOp(NullOp, Ty),
213212
UnaryOp(UnOp, Operand),
214213
Discriminant(Place),
215214
Aggregate(AggregateKind, Vec<Operand>),
@@ -264,12 +263,6 @@ pub enum BinOp {
264263
Shr,
265264
}
266265

267-
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
268-
pub enum NullOp {
269-
SizeOf,
270-
AlignOf,
271-
}
272-
273266
pub enum Operand {
274267
Copy(Place),
275268
Move(Place),
@@ -681,7 +674,6 @@ impl fmt::Debug for Rvalue {
681674
Rvalue::RawPtr(mutbl, place) => write!(f, "&raw {} {place:?}", mutbl.ptr_str()),
682675
Rvalue::Discriminant(place) => write!(f, "discriminant({place:?})"),
683676
Rvalue::BinaryOp(bin_op, op1, op2) => write!(f, "{bin_op:?}({op1:?}, {op2:?})"),
684-
Rvalue::NullaryOp(null_op, ty) => write!(f, "{null_op:?}({ty:?})"),
685677
Rvalue::UnaryOp(un_op, op) => write!(f, "{un_op:?}({op:?})"),
686678
Rvalue::Aggregate(AggregateKind::Adt(def_id, variant_idx, args, _, _), operands) => {
687679
let (fname, variant_name) = rustc_middle::ty::tls::with(|tcx| {

0 commit comments

Comments
 (0)