1
Fork 0

Rollup merge of #91718 - RalfJung:unaligned_references, r=nagisa

give more help in the unaligned_references lint

Cc https://github.com/rust-lang/rust/issues/82523#issuecomment-988138440 ``@kaisq``
This commit is contained in:
Matthias Krüger 2021-12-11 16:02:49 +01:00 committed by GitHub
commit bc0269dbed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 25 additions and 0 deletions

View file

@ -105,6 +105,11 @@ impl<'tcx> Visitor<'tcx> for PackedRefChecker<'_, 'tcx> {
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 \
reference with a raw pointer and use `read_unaligned`/`write_unaligned` \
(loads and stores via `*p` must be properly aligned even when using raw pointers)"
)
.emit()
},
);