Skip to content

Commit ca528fc

Browse files
authored
Rollup merge of #67504 - Mark-Simulacrum:note-data-offset, r=Centril
Warn against relying on ?Sized being last Fixes #62522
2 parents c355463 + a34c267 commit ca528fc

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/liballoc/rc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2106,6 +2106,8 @@ impl<T: ?Sized> Unpin for Rc<T> { }
21062106
unsafe fn data_offset<T: ?Sized>(ptr: *const T) -> isize {
21072107
// Align the unsized value to the end of the `RcBox`.
21082108
// Because it is ?Sized, it will always be the last field in memory.
2109+
// Note: This is a detail of the current implementation of the compiler,
2110+
// and is not a guaranteed language detail. Do not rely on it outside of std.
21092111
data_offset_align(align_of_val(&*ptr))
21102112
}
21112113

src/liballoc/sync.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2161,6 +2161,8 @@ impl<T: ?Sized> Unpin for Arc<T> { }
21612161
unsafe fn data_offset<T: ?Sized>(ptr: *const T) -> isize {
21622162
// Align the unsized value to the end of the `ArcInner`.
21632163
// Because it is `?Sized`, it will always be the last field in memory.
2164+
// Note: This is a detail of the current implementation of the compiler,
2165+
// and is not a guaranteed language detail. Do not rely on it outside of std.
21642166
data_offset_align(align_of_val(&*ptr))
21652167
}
21662168

0 commit comments

Comments
 (0)