rust/tests/ui/repr
David Rheinsberg b0dadff6de error/E0691: include alignment in error message
Include the computed alignment of the violating field when rejecting
transparent types with non-trivially aligned ZSTs.

ZST member fields in transparent types must have an alignment of 1 (to
ensure it does not raise the layout requirements of the transparent
field). The current error message looks like this:

 LL | struct Foobar(u32, [u32; 0]);
    |                    ^^^^^^^^ has alignment larger than 1

This patch changes the report to include the alignment of the violating
field:

 LL | struct Foobar(u32, [u32; 0]);
    |                    ^^^^^^^^ has alignment of 4, which is larger than 1

In case of unknown alignments, it will yield:

 LL | struct Foobar<T>(u32, [T; 0]);
    |                       ^^^^^^ may have alignment larger than 1

This allows developers to get a better grasp why a specific field is
rejected. Knowing the alignment of the violating field makes it easier
to judge where that alignment-requirement originates, and thus hopefully
provide better hints on how to mitigate the problem.

This idea was proposed in 2022 in #98071 as part of a bigger change.
This commit simply extracts this error-message change, to decouple it
from the other diagnostic improvements.
2023-07-21 11:04:16 +02:00
..
auxiliary Move /src/test to /tests 2023-01-11 09:32:08 +00:00
16-bit-repr-c-enum.rs Default repr(C) enums to c_int size 2023-02-16 15:06:17 -08:00
align-with-extern-c-fn.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
aligned_enum_cast.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
attr-usage-repr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
attr-usage-repr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid_repr_list_help.rs Don't bail out early when checking invalid repr attr 2023-05-01 15:05:39 +01:00
invalid_repr_list_help.stderr Don't bail out early when checking invalid repr attr 2023-05-01 15:05:39 +01:00
issue-83505-repr-simd.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-83505-repr-simd.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-83921-ice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-83921-ice.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr_c_int_align.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-align-assign.fixed Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-align-assign.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-align-assign.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-align.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-align.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-disallow-on-variant.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-disallow-on-variant.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-packed-contains-align.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-packed-contains-align.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-issue-87496.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-issue-87496.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-non-exhaustive.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-non-exhaustive.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-other-items.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-other-items.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-other-reprs.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-other-reprs.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent.stderr error/E0691: include alignment in error message 2023-07-21 11:04:16 +02:00
repr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transparent-enum-too-many-variants.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transparent-enum-too-many-variants.stderr Migrate rustc_hir_analysis to session diagnostic 2023-04-21 23:50:03 +03:00