@@ -131,30 +131,67 @@ LL | *std::mem::transmute::<_, *mut i32>(num) += 1;
131
131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
132
132
133
133
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
134
- --> $DIR/reference_casting.rs:76:5
134
+ --> $DIR/reference_casting.rs:74:5
135
+ |
136
+ LL | / std::ptr::write(
137
+ LL | |
138
+ LL | | std::mem::transmute::<*const i32, *mut i32>(num),
139
+ LL | | -1i32,
140
+ LL | | );
141
+ | |_____^
142
+
143
+ error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
144
+ --> $DIR/reference_casting.rs:81:5
135
145
|
136
146
LL | let value = num as *const i32 as *mut i32;
137
147
| ----------------------------- casting happend here
138
148
LL | *value = 1;
139
149
| ^^^^^^^^^^
140
150
141
151
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
142
- --> $DIR/reference_casting.rs:78 :5
152
+ --> $DIR/reference_casting.rs:83 :5
143
153
|
144
154
LL | *(num as *const i32).cast::<i32>().cast_mut() = 2;
145
155
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146
156
147
157
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
148
- --> $DIR/reference_casting.rs:80 :5
158
+ --> $DIR/reference_casting.rs:85 :5
149
159
|
150
160
LL | *(num as *const _ as usize as *mut i32) = 2;
151
161
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
152
162
153
163
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
154
- --> $DIR/reference_casting.rs:84:9
164
+ --> $DIR/reference_casting.rs:87:5
165
+ |
166
+ LL | let value = num as *const i32 as *mut i32;
167
+ | ----------------------------- casting happend here
168
+ ...
169
+ LL | std::ptr::write(value, 2);
170
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
171
+
172
+ error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
173
+ --> $DIR/reference_casting.rs:89:5
174
+ |
175
+ LL | let value = num as *const i32 as *mut i32;
176
+ | ----------------------------- casting happend here
177
+ ...
178
+ LL | std::ptr::write_unaligned(value, 2);
179
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
180
+
181
+ error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
182
+ --> $DIR/reference_casting.rs:91:5
183
+ |
184
+ LL | let value = num as *const i32 as *mut i32;
185
+ | ----------------------------- casting happend here
186
+ ...
187
+ LL | std::ptr::write_volatile(value, 2);
188
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
189
+
190
+ error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
191
+ --> $DIR/reference_casting.rs:95:9
155
192
|
156
193
LL | *(this as *const _ as *mut _) = a;
157
194
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
158
195
159
- error: aborting due to 25 previous errors
196
+ error: aborting due to 29 previous errors
160
197
0 commit comments