Turning `#[packed]` into a permanent warning and backporting to 1.2


In Rust 1.2 beta the unused #[packed] attribute was removed from the compiler causing some crates to break.

Every break we introduce tarnishes our long-term reputation and we need to establish ourselves as a serious project that can maintain our commitments to users.

While this is minor breakage, it is avoidable and I suggest we revert the original patch and turn packed into a permanent warning.

I’ll be happy to put a patch together. Any other opinions?


(IMO) The fact that it was left in the compiler was a bug (although it is still documented in the reference…). Does #[repr(C)] now imply #[packed]? If not, these crates were broken anyways.


#[packed] does nothing. I know because I encountered my code segfaulting (which depends on packed structs to work) some time in the pre-1.0 era and traced it down to needing to use #[repr(packed)] now. So all the crates that still use #[packed] are broken.


I want to address this due to it seemingly being a common misconception. “packed” means no padding areas in the struct layout, which is not portable in general. C’s struct layout is implementation defined but will lay out the fields so that they are well aligned and insert padding areas as appropriate. What it does guarantee is that the first member is at offset 0 from the start, and the order of the members is preserved.


It sounds like there’s not a lot of sympathy for crates mentioning #[packed], so I’ve opened a PR to mention the breakage in the release notes instead.


:raising_hand_woman: I’d like to contribute moral support for not breaking things in general, even if this case is not terribly sympathetic since all uses are likely bugs.


Thanks @comex, my no-breakage buddy!