Skip to content

Commit

Permalink
Rollup merge of rust-lang#63374 - RalfJung:pin-packed, r=cramertj
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Centril authored Aug 8, 2019
2 parents 7cdb7ab + fa58c27 commit a645f99
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libcore/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@
//! you do not accidentally use `self`/`this` in a way that is in conflict with pinning.
//!
//! Moreover, if your type is `#[repr(packed)]`, the compiler will automatically
//! move fields around to be able to drop them. As a consequence, you cannot use
//! move fields around to be able to drop them. It might even do
//! that for fields that happen to be sufficiently aligned. As a consequence, you cannot use
//! pinning with a `#[repr(packed)]` type.
//!
//! # Projections and Structural Pinning
Expand Down

0 comments on commit a645f99

Please sign in to comment.