1
Fork 0

Delete Rvalue::Len

Everything's moved to `PtrMetadata` instead.
This commit is contained in:
Scott McMurray 2024-12-13 17:43:16 -08:00
parent b22856d192
commit 5ba54c9e31
36 changed files with 50 additions and 271 deletions

View file

@ -246,7 +246,6 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
let offset = self.parse_operand(args[1])?;
Ok(Rvalue::BinaryOp(BinOp::Offset, Box::new((ptr, offset))))
},
@call(mir_len, args) => Ok(Rvalue::Len(self.parse_place(args[0])?)),
@call(mir_ptr_metadata, args) => Ok(Rvalue::UnaryOp(UnOp::PtrMetadata, self.parse_operand(args[0])?)),
@call(mir_copy_for_deref, args) => Ok(Rvalue::CopyForDeref(self.parse_place(args[0])?)),
ExprKind::Borrow { borrow_kind, arg } => Ok(

View file

@ -635,7 +635,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
///
/// For arrays it'll be `Operand::Constant` with the actual length;
/// For slices it'll be `Operand::Move` of a local using `PtrMetadata`.
fn len_of_slice_or_array(
pub(in crate::builder) fn len_of_slice_or_array(
&mut self,
block: BasicBlock,
place: Place<'tcx>,

View file

@ -243,11 +243,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
TestKind::Len { len, op } => {
let usize_ty = self.tcx.types.usize;
let actual = self.temp(usize_ty, test.span);
// actual = len(place)
self.cfg.push_assign(block, source_info, actual, Rvalue::Len(place));
let actual = self.len_of_slice_or_array(block, place, test.span, source_info);
// expected = <N>
let expected = self.push_usize(block, source_info, len);
@ -262,7 +259,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fail_block,
source_info,
op,
Operand::Move(actual),
actual,
Operand::Move(expected),
);
}