@@ -756,10 +756,10 @@ declare_lint! {
756
756
/// *subsequent* fields of the associated structs to use an alignment value
757
757
/// where the floating-point type is aligned on a 4-byte boundary.
758
758
///
759
- /// The power alignment rule for structs needed for C compatibility is
760
- /// unimplementable within `repr(C)` in the compiler without building in
761
- /// handling of references to packed fields and infectious nested layouts,
762
- /// so a warning is produced in these situations .
759
+ /// Effectively, subsequent floating-point fields act as-if they are `repr(packed(4))`. This
760
+ /// would be unsound to do in a `repr(C)` type without all the restrictions that come with
761
+ /// `repr(packed)`. Rust instead chooses a layout that maintains soundness of Rust code, at the
762
+ /// expense of incompatibility with C code .
763
763
///
764
764
/// ### Example
765
765
///
@@ -791,8 +791,10 @@ declare_lint! {
791
791
/// - offset_of!(Floats, a) == 0
792
792
/// - offset_of!(Floats, b) == 8
793
793
/// - offset_of!(Floats, c) == 12
794
- /// However, rust currently aligns `c` at offset_of!(Floats, c) == 16.
795
- /// Thus, a warning should be produced for the above struct in this case.
794
+ ///
795
+ /// However, Rust currently aligns `c` at `offset_of!(Floats, c) == 16`.
796
+ /// Using offset 12 would be unsound since `f64` generally must be 8-aligned on this target.
797
+ /// Thus, a warning is produced for the above struct.
796
798
USES_POWER_ALIGNMENT ,
797
799
Warn ,
798
800
"Structs do not follow the power alignment rule under repr(C)"
0 commit comments