Skip to content

Commit 2e52fe0

Browse files
committed
remove some now-unnecessary parameters from check_bytes
1 parent da13935 commit 2e52fe0

File tree

3 files changed

+7
-31
lines changed

3 files changed

+7
-31
lines changed

compiler/rustc_const_eval/src/interpret/memory.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -962,15 +962,10 @@ impl<'tcx, 'a, Prov: Provenance, Extra> AllocRef<'a, 'tcx, Prov, Extra> {
962962
}
963963

964964
/// `range` is relative to this allocation reference, not the base of the allocation.
965-
pub fn check_bytes(
966-
&self,
967-
range: AllocRange,
968-
allow_uninit: bool,
969-
allow_ptr: bool,
970-
) -> InterpResult<'tcx> {
965+
pub fn check_bytes(&self, range: AllocRange) -> InterpResult<'tcx> {
971966
Ok(self
972967
.alloc
973-
.check_bytes(&self.tcx, self.range.subrange(range), allow_uninit, allow_ptr)
968+
.check_bytes(&self.tcx, self.range.subrange(range))
974969
.map_err(|e| e.to_interp_error(self.alloc_id))?)
975970
}
976971

compiler/rustc_const_eval/src/interpret/validity.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -893,11 +893,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
893893
// We also accept uninit, for consistency with the slow path.
894894
let alloc = self.ecx.get_ptr_alloc(mplace.ptr, size, mplace.align)?.expect("we already excluded size 0");
895895

896-
match alloc.check_bytes(
897-
alloc_range(Size::ZERO, size),
898-
/*allow_uninit*/ false,
899-
/*allow_ptr*/ false,
900-
) {
896+
match alloc.check_bytes(alloc_range(Size::ZERO, size)) {
901897
// In the happy case, we needn't check anything else.
902898
Ok(()) => {}
903899
// Some error happened, try to provide a more detailed description.

compiler/rustc_middle/src/mir/interpret/allocation.rs

+4-19
Original file line numberDiff line numberDiff line change
@@ -415,25 +415,10 @@ impl<Prov: Provenance, Extra> Allocation<Prov, Extra> {
415415

416416
/// Reading and writing.
417417
impl<Prov: Provenance, Extra> Allocation<Prov, Extra> {
418-
/// Validates that `ptr.offset` and `ptr.offset + size` do not point to the middle of a
419-
/// relocation. If `allow_uninit`/`allow_ptr` is `false`, also enforces that the memory in the
420-
/// given range contains no uninitialized bytes/relocations.
421-
pub fn check_bytes(
422-
&self,
423-
cx: &impl HasDataLayout,
424-
range: AllocRange,
425-
allow_uninit: bool,
426-
allow_ptr: bool,
427-
) -> AllocResult {
428-
// Check bounds and relocations on the edges.
429-
self.get_bytes_with_uninit_and_ptr(cx, range)?;
430-
// Check uninit and ptr.
431-
if !allow_uninit {
432-
self.check_init(range)?;
433-
}
434-
if !allow_ptr {
435-
self.check_relocations(cx, range)?;
436-
}
418+
/// Validates that this memory range is initiailized and contains no relocations.
419+
pub fn check_bytes(&self, cx: &impl HasDataLayout, range: AllocRange) -> AllocResult {
420+
// This implicitly does all the checking we are asking for.
421+
self.get_bytes(cx, range)?;
437422
Ok(())
438423
}
439424

0 commit comments

Comments
 (0)