about summary refs log tree commit diff
path: root/src/test/ui/binding
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2021-12-09 12:45:00 -0500
committerRalf Jung <post@ralfj.de>2021-12-09 16:48:51 -0500
commit7d18a456cafa4bc09fe6ac014b208e3f9570f18b (patch)
tree019e2681bd00a462ea7e8a06ac034cc87247038a /src/test/ui/binding
parente25077704164071a1ef87cdc90fe7dd1872ba3fa (diff)
downloadrust-7d18a456cafa4bc09fe6ac014b208e3f9570f18b.tar.gz
rust-7d18a456cafa4bc09fe6ac014b208e3f9570f18b.zip
give more help in the unaligned_references lint
Diffstat (limited to 'src/test/ui/binding')
-rw-r--r--src/test/ui/binding/issue-53114-safety-checks.stderr4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/test/ui/binding/issue-53114-safety-checks.stderr b/src/test/ui/binding/issue-53114-safety-checks.stderr
index 9e7deea4524..84cdb1453f8 100644
--- a/src/test/ui/binding/issue-53114-safety-checks.stderr
+++ b/src/test/ui/binding/issue-53114-safety-checks.stderr
@@ -8,6 +8,7 @@ LL |     let _ = &p.b;
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
    = note: fields of packed structs are not properly aligned, and 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 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)
 
 warning: reference to packed field is unaligned
   --> $DIR/issue-53114-safety-checks.rs:29:17
@@ -18,6 +19,7 @@ LL |     let (_,) = (&p.b,);
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
    = note: fields of packed structs are not properly aligned, and 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 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)
 
 warning: reference to packed field is unaligned
   --> $DIR/issue-53114-safety-checks.rs:39:11
@@ -28,6 +30,7 @@ LL |     match &p.b  { _ => { } }
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
    = note: fields of packed structs are not properly aligned, and 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 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)
 
 warning: reference to packed field is unaligned
   --> $DIR/issue-53114-safety-checks.rs:45:12
@@ -38,6 +41,7 @@ LL |     match (&p.b,)  { (_,) => { } }
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
    = note: fields of packed structs are not properly aligned, and 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 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)
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
   --> $DIR/issue-53114-safety-checks.rs:26:13