improve error notes for packed struct reference diagnostic

This commit is contained in:
bindsdev 2023-04-28 20:28:56 -05:00
parent f495605381
commit 107d480892
8 changed files with 55 additions and 27 deletions

View file

@ -56,8 +56,11 @@ impl<'tcx> Visitor<'tcx> for PackedRefChecker<'_, 'tcx> {
"reference to packed field is unaligned"
)
.note(
"fields of packed structs are not properly aligned, and creating \
a misaligned reference is undefined behavior (even if that \
"packed structs are only aligned by one byte, and many modern architectures \
penalize unaligned field accesses"
)
.note(
"creating a misaligned reference is undefined behavior (even if that \
reference is never dereferenced)",
).help(
"copy the field contents to a local variable, or replace the \