about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-07-21 17:17:42 +0200
committerGitHub <noreply@github.com>2023-07-21 17:17:42 +0200
commit4a90553717ab9274b6faa19cccb47d7c427dbe92 (patch)
treea97b2e5cec47833b1180db4ddd955a5992fae38e /compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
parentb91c41b1f4e36640c8915959016c1a95bc9e6a51 (diff)
parentb0dadff6de0a0d17b38ebfcae333cc88a8b6e47e (diff)
downloadrust-4a90553717ab9274b6faa19cccb47d7c427dbe92.tar.gz
rust-4a90553717ab9274b6faa19cccb47d7c427dbe92.zip
Rollup merge of #113913 - dvdhrm:pr/transpalign, r=jackh726
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:

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

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

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

In case of unknown alignments, it will yield:

```text
 LL | struct Foobar(u32, [u32; 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.

(Originally proposed by `@compiler-errors` in #98071)
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp')
0 files changed, 0 insertions, 0 deletions