rust/compiler/rustc_hir_analysis/src/check
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
..
check.rs error/E0691: include alignment in error message 2023-07-21 11:04:16 +02:00
compare_impl_item.rs Rename arg_iter to iter_instantiated 2023-07-17 21:04:12 +00:00
dropck.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
entry.rs Check entry type as part of item type checking. 2023-07-15 22:02:16 +00:00
intrinsic.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
intrinsicck.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
mod.rs Rename arg_iter to iter_instantiated 2023-07-17 21:04:12 +00:00
region.rs Separate AnonConst from ConstBlock in HIR. 2023-06-02 21:25:18 +00:00
wfcheck.rs Rename arg_iter to iter_instantiated 2023-07-17 21:04:12 +00:00