Skip to content

Commit 432b55e

Browse files
authored
Rollup merge of rust-lang#63374 - RalfJung:pin-packed, r=cramertj
move of packed fields might or might not occur when they actually are sufficiently aligned See taiki-e/pin-project#34, where it was pointed out that we actually don't move fields of 1-aligned types when dropping a packed struct -- but e.g. in a `packed(2)` struct, we don't do something similar for 2-aligned types. The code for that is [here](https://github.com/rust-lang/rust/blob/db7c773a6be2f050d1d1504763819ea3916f5428/src/librustc_mir/util/alignment.rs#L7).
2 parents 82e9762 + fa58c27 commit 432b55e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libcore/pin.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@
188188
//! you do not accidentally use `self`/`this` in a way that is in conflict with pinning.
189189
//!
190190
//! Moreover, if your type is `#[repr(packed)]`, the compiler will automatically
191-
//! move fields around to be able to drop them. As a consequence, you cannot use
191+
//! move fields around to be able to drop them. It might even do
192+
//! that for fields that happen to be sufficiently aligned. As a consequence, you cannot use
192193
//! pinning with a `#[repr(packed)]` type.
193194
//!
194195
//! # Projections and Structural Pinning

0 commit comments

Comments
 (0)