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


#1

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?


#2

(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.


#3

#[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.


#4

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.


#5

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.


#6

: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.


#7

Thanks @comex, my no-breakage buddy!