about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-05-24 10:10:07 +0200
committerGitHub <noreply@github.com>2024-05-24 10:10:07 +0200
commitb84620ff17b386969052d26b2868aa7e2557be79 (patch)
tree976c73e8de663ce68754314d64f6ac1efcc7310b /src
parent1b374dfd9bcb234f44270ebb8f3b957d2e8a7820 (diff)
downloadrust-b84620ff17b386969052d26b2868aa7e2557be79.tar.gz
rust-b84620ff17b386969052d26b2868aa7e2557be79.zip
extend comments
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/src/alloc_bytes.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/tools/miri/src/alloc_bytes.rs b/src/tools/miri/src/alloc_bytes.rs
index 0ae581dacdc..97841a05cde 100644
--- a/src/tools/miri/src/alloc_bytes.rs
+++ b/src/tools/miri/src/alloc_bytes.rs
@@ -14,8 +14,7 @@ pub struct MiriAllocBytes {
     layout: alloc::Layout,
     /// Pointer to the allocation contents.
     /// Invariant:
-    /// * If `self.layout.size() == 0`, then `self.ptr` is some suitably aligned pointer
-    ///   that was allocated with the same layout but `size == 1`.
+    /// * If `self.layout.size() == 0`, then `self.ptr` was allocated with the equivalent layout with size 1.
     /// * Otherwise, `self.ptr` points to memory allocated with `self.layout`.
     ptr: *mut u8,
 }
@@ -30,6 +29,8 @@ impl Clone for MiriAllocBytes {
 
 impl Drop for MiriAllocBytes {
     fn drop(&mut self) {
+        // We have to reconstruct the actual layout used for allocation.
+        // (`Deref` relies on `size` so we can't just always set it to at least 1.)
         let alloc_layout = if self.layout.size() == 0 {
             Layout::from_size_align(1, self.layout.align()).unwrap()
         } else {