|
| 1 | +error[E0793]: reference to packed field is unaligned |
| 2 | + --> $DIR/issue-53114-safety-checks.rs:23:13 |
| 3 | + | |
| 4 | +LL | let _ = &p.b; |
| 5 | + | ^^^^ |
| 6 | + | |
| 7 | + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses |
| 8 | + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) |
| 9 | + = 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) |
| 10 | + |
| 11 | +error[E0793]: reference to packed field is unaligned |
| 12 | + --> $DIR/issue-53114-safety-checks.rs:28:17 |
| 13 | + | |
| 14 | +LL | let (_,) = (&p.b,); |
| 15 | + | ^^^^ |
| 16 | + | |
| 17 | + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses |
| 18 | + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) |
| 19 | + = 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) |
| 20 | + |
1 | 21 | error[E0133]: access to union field is unsafe and requires unsafe function or block |
2 | 22 | --> $DIR/issue-53114-safety-checks.rs:24:13 |
3 | 23 | | |
@@ -31,20 +51,20 @@ LL | let (_,) = (&u2.a,); |
31 | 51 | = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior |
32 | 52 |
|
33 | 53 | error[E0793]: reference to packed field is unaligned |
34 | | - --> $DIR/issue-53114-safety-checks.rs:23:13 |
| 54 | + --> $DIR/issue-53114-safety-checks.rs:37:16 |
35 | 55 | | |
36 | | -LL | let _ = &p.b; |
37 | | - | ^^^^ |
| 56 | +LL | let _: _ = &p.b; |
| 57 | + | ^^^^ |
38 | 58 | | |
39 | 59 | = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses |
40 | 60 | = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) |
41 | 61 | = 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) |
42 | 62 |
|
43 | 63 | error[E0793]: reference to packed field is unaligned |
44 | | - --> $DIR/issue-53114-safety-checks.rs:28:17 |
| 64 | + --> $DIR/issue-53114-safety-checks.rs:42:20 |
45 | 65 | | |
46 | | -LL | let (_,) = (&p.b,); |
47 | | - | ^^^^ |
| 66 | +LL | let (_,): _ = (&p.b,); |
| 67 | + | ^^^^ |
48 | 68 | | |
49 | 69 | = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses |
50 | 70 | = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) |
@@ -83,20 +103,20 @@ LL | let (_,): _ = (&u2.a,); |
83 | 103 | = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior |
84 | 104 |
|
85 | 105 | error[E0793]: reference to packed field is unaligned |
86 | | - --> $DIR/issue-53114-safety-checks.rs:37:16 |
| 106 | + --> $DIR/issue-53114-safety-checks.rs:51:11 |
87 | 107 | | |
88 | | -LL | let _: _ = &p.b; |
89 | | - | ^^^^ |
| 108 | +LL | match &p.b { _ => { } } |
| 109 | + | ^^^^ |
90 | 110 | | |
91 | 111 | = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses |
92 | 112 | = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) |
93 | 113 | = 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) |
94 | 114 |
|
95 | 115 | error[E0793]: reference to packed field is unaligned |
96 | | - --> $DIR/issue-53114-safety-checks.rs:42:20 |
| 116 | + --> $DIR/issue-53114-safety-checks.rs:56:12 |
97 | 117 | | |
98 | | -LL | let (_,): _ = (&p.b,); |
99 | | - | ^^^^ |
| 118 | +LL | match (&p.b,) { (_,) => { } } |
| 119 | + | ^^^^ |
100 | 120 | | |
101 | 121 | = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses |
102 | 122 | = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) |
@@ -134,26 +154,6 @@ LL | match (&u2.a,) { (_,) => { } } |
134 | 154 | | |
135 | 155 | = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior |
136 | 156 |
|
137 | | -error[E0793]: reference to packed field is unaligned |
138 | | - --> $DIR/issue-53114-safety-checks.rs:51:11 |
139 | | - | |
140 | | -LL | match &p.b { _ => { } } |
141 | | - | ^^^^ |
142 | | - | |
143 | | - = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses |
144 | | - = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) |
145 | | - = 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) |
146 | | - |
147 | | -error[E0793]: reference to packed field is unaligned |
148 | | - --> $DIR/issue-53114-safety-checks.rs:56:12 |
149 | | - | |
150 | | -LL | match (&p.b,) { (_,) => { } } |
151 | | - | ^^^^ |
152 | | - | |
153 | | - = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses |
154 | | - = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) |
155 | | - = 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) |
156 | | - |
157 | 157 | error: aborting due to 18 previous errors |
158 | 158 |
|
159 | 159 | Some errors have detailed explanations: E0133, E0793. |
|
0 commit comments