I was reading this post on optimizing struct field ordering, and it mentioned a case in which this optimization broke Servo because Servo was relying on the layout of types that were not marked as
I was thinking that:
- This is probably an easy mistake to make. I’ve been working on some unsafe code recently, and only noticed a little while in that I’d forgotten to mark a type as
- It might be possible to design a Clippy lint that would detect code that appeared to rely on the order and offset of struct fields. This would certainly be a very fuzzy lint - it’d probably have tons of false positives and false negatives - but it might be made good enough to still be useful.