ManuallyDrop ABI 是否保证 repr(透明)?

Is the ManuallyDrop ABI guaranteed to be repr(transparent)?

nomicon 说:

repr(transparent)

[...] This repr is only considered part of the public ABI of a type if either the single field is pub, or if its layout is documented in prose. Otherwise, the layout should not be relied upon by other crates.

ManuallyDrop<T>repr(transparent),但它的单个字段不是pub。它的文档说:

[...] This wrapper is 0-cost.

ManuallyDrop<T> is subject to the same layout optimizations as T. [...]

这算作在散文中记录其布局吗?假设我可以从 T 转换或以其他方式转换(例如指针转换)到 ManuallyDrop<T> 是否安全?

这实际上是 just clarified with today's release of Rust 1.61.0ManuallyDrop 的文档现在指定(添加的文本以粗体突出显示):

ManuallyDrop<T> is guaranteed to have the same layout as T, and is subject to the same layout optimizations as T.