Skip to content

Commit 3ec1feb

Browse files
committed
add caution to some comments
1 parent 85ee04c commit 3ec1feb

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

compiler/rustc_const_eval/src/interpret/memory.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
10581058
// operating system this can avoid physically allocating the page.
10591059
dest_alloc
10601060
.write_uninit(&tcx, dest_range)
1061-
.map_err(|e| e.to_interp_error(dest_alloc_id))?; // `Size` multiplication
1061+
.map_err(|e| e.to_interp_error(dest_alloc_id))?;
10621062
// We can forget about the relocations, this is all not initialized anyway.
10631063
return Ok(());
10641064
}

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl<Tag: Provenance, Extra> Allocation<Tag, Extra> {
269269
/// `get_bytes_with_uninit_and_ptr` instead,
270270
///
271271
/// This function also guarantees that the resulting pointer will remain stable
272-
/// even when new allocations are pushed to the `HashMap`. `copy_repeatedly` relies
272+
/// even when new allocations are pushed to the `HashMap`. `mem_copy_repeatedly` relies
273273
/// on that.
274274
///
275275
/// It is the caller's responsibility to check bounds and alignment beforehand.
@@ -605,6 +605,9 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
605605
/// Applies a relocation copy.
606606
/// The affected range, as defined in the parameters to `prepare_relocation_copy` is expected
607607
/// to be clear of relocations.
608+
///
609+
/// This is dangerous to use as it can violate internal `Allocation` invariants!
610+
/// It only exists to support an efficient implementation of `mem_copy_repeatedly`.
608611
pub fn mark_relocation_range(&mut self, relocations: AllocationRelocations<Tag>) {
609612
self.relocations.0.insert_presorted(relocations.relative_relocations);
610613
}
@@ -1124,6 +1127,9 @@ impl<Tag, Extra> Allocation<Tag, Extra> {
11241127
}
11251128

11261129
/// Applies multiple instances of the run-length encoding to the initialization mask.
1130+
///
1131+
/// This is dangerous to use as it can violate internal `Allocation` invariants!
1132+
/// It only exists to support an efficient implementation of `mem_copy_repeatedly`.
11271133
pub fn mark_compressed_init_range(
11281134
&mut self,
11291135
defined: &InitMaskCompressed,

0 commit comments

Comments
 (0)