improve error notes for packed struct reference diagnostic
This commit is contained in:
parent
f495605381
commit
107d480892
8 changed files with 55 additions and 27 deletions
|
@ -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 \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue