Make rc::RcBox and sync::ArcInner repr(C)
Future-proof these types in case rustc reorders the inner fields. As per discussion in PR #68099.
This commit is contained in:
parent
b4c96a9199
commit
586c7e3907
|
@ -259,6 +259,10 @@ use crate::vec::Vec;
|
|||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
// This is repr(C) to future-proof against possible field-reordering, which
|
||||
// would interfere with otherwise safe [into|from]_raw() of transmutable
|
||||
// inner types.
|
||||
#[repr(C)]
|
||||
struct RcBox<T: ?Sized> {
|
||||
strong: Cell<usize>,
|
||||
weak: Cell<usize>,
|
||||
|
|
|
@ -270,6 +270,10 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
|
|||
}
|
||||
}
|
||||
|
||||
// This is repr(C) to future-proof against possible field-reordering, which
|
||||
// would interfere with otherwise safe [into|from]_raw() of transmutable
|
||||
// inner types.
|
||||
#[repr(C)]
|
||||
struct ArcInner<T: ?Sized> {
|
||||
strong: atomic::AtomicUsize,
|
||||
|
||||
|
|
Loading…
Reference in New Issue