Skip to content

Commit d4b3654

Browse files
committed
points the user away from the Allocation type and towards the Memory type
1 parent 50ddcbb commit d4b3654

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/librustc/mir/interpret/allocation.rs

+12
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
245245
/// as a slice.
246246
///
247247
/// It is the caller's responsibility to check bounds and alignment beforehand.
248+
/// Most likely, you want to use the `PlaceTy` and `OperandTy`-based methods
249+
/// on `InterpCx` instead.
248250
#[inline]
249251
pub fn get_bytes(
250252
&self,
@@ -275,6 +277,8 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
275277
/// so be sure to actually put data there!
276278
///
277279
/// It is the caller's responsibility to check bounds and alignment beforehand.
280+
/// Most likely, you want to use the `PlaceTy` and `OperandTy`-based methods
281+
/// on `InterpCx` instead.
278282
pub fn get_bytes_mut(
279283
&mut self,
280284
cx: &impl HasDataLayout,
@@ -297,6 +301,8 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
297301
impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
298302
/// Reads bytes until a `0` is encountered. Will error if the end of the allocation is reached
299303
/// before a `0` is found.
304+
///
305+
/// Most likely, you want to call `Memory::read_c_str` instead of this method.
300306
pub fn read_c_str(
301307
&self,
302308
cx: &impl HasDataLayout,
@@ -342,6 +348,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
342348
/// Writes `src` to the memory starting at `ptr.offset`.
343349
///
344350
/// It is the caller's responsibility to check bounds and alignment beforehand.
351+
/// Most likely, you want to call `Memory::write_bytes` instead of this method.
345352
pub fn write_bytes(
346353
&mut self,
347354
cx: &impl HasDataLayout,
@@ -363,6 +370,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
363370
/// Sets `count` bytes starting at `ptr.offset` with `val`. Basically `memset`.
364371
///
365372
/// It is the caller's responsibility to check bounds and alignment beforehand.
373+
/// Most likely, you want to call `Memory::write_bytes` instead of this method.
366374
pub fn write_repeat(
367375
&mut self,
368376
cx: &impl HasDataLayout,
@@ -386,6 +394,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
386394
/// pointers being valid for ZSTs.
387395
///
388396
/// It is the caller's responsibility to check bounds and alignment beforehand.
397+
/// Most likely, you want to call `InterpCx::read_scalar` instead of this method.
389398
pub fn read_scalar(
390399
&self,
391400
cx: &impl HasDataLayout,
@@ -424,6 +433,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
424433
/// Reads a pointer-sized scalar.
425434
///
426435
/// It is the caller's responsibility to check bounds and alignment beforehand.
436+
/// Most likely, you want to call `InterpCx::read_scalar` instead of this method.
427437
pub fn read_ptr_sized(
428438
&self,
429439
cx: &impl HasDataLayout,
@@ -441,6 +451,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
441451
/// pointers being valid for ZSTs.
442452
///
443453
/// It is the caller's responsibility to check bounds and alignment beforehand.
454+
/// Most likely, you want to call `InterpCx::write_scalar` instead of this method.
444455
pub fn write_scalar(
445456
&mut self,
446457
cx: &impl HasDataLayout,
@@ -483,6 +494,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
483494
/// Writes a pointer-sized scalar.
484495
///
485496
/// It is the caller's responsibility to check bounds and alignment beforehand.
497+
/// Most likely, you want to call `InterpCx::write_scalar` instead of this method.
486498
pub fn write_ptr_sized(
487499
&mut self,
488500
cx: &impl HasDataLayout,

0 commit comments

Comments
 (0)