about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-12-21 20:35:41 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-12-21 20:35:41 -0500
commita34c2677afeee2747d680536f302a8c5665a65f4 (patch)
tree801ed39851373350e3459668a53cf3ad004ffda9 /src/liballoc
parent5535c253140bd0e48488fad43e60013b48ecd716 (diff)
Warn against relying on ?Sized being last
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/rc.rs2
-rw-r--r--src/liballoc/sync.rs2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index 42a278de98b..00c4b5462be 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -2106,6 +2106,8 @@ impl<T: ?Sized> Unpin for Rc<T> { }
 unsafe fn data_offset<T: ?Sized>(ptr: *const T) -> isize {
     // Align the unsized value to the end of the `RcBox`.
     // Because it is ?Sized, it will always be the last field in memory.
+    // Note: This is a detail of the current implementation of the compiler,
+    // and is not a guaranteed language detail. Do not rely on it outside of std.
     data_offset_align(align_of_val(&*ptr))
 }
 
diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs
index a99564c0dac..37995a7ec79 100644
--- a/src/liballoc/sync.rs
+++ b/src/liballoc/sync.rs
@@ -2161,6 +2161,8 @@ impl<T: ?Sized> Unpin for Arc<T> { }
 unsafe fn data_offset<T: ?Sized>(ptr: *const T) -> isize {
     // Align the unsized value to the end of the `ArcInner`.
     // Because it is `?Sized`, it will always be the last field in memory.
+    // Note: This is a detail of the current implementation of the compiler,
+    // and is not a guaranteed language detail. Do not rely on it outside of std.
     data_offset_align(align_of_val(&*ptr))
 }