@@ -131,30 +131,67 @@ LL | *std::mem::transmute::<_, *mut i32>(num) += 1;
131131 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
132132
133133error: 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
135145 |
136146LL | let value = num as *const i32 as *mut i32;
137147 | ----------------------------- casting happend here
138148LL | *value = 1;
139149 | ^^^^^^^^^^
140150
141151error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
142- --> $DIR/reference_casting.rs:78 :5
152+ --> $DIR/reference_casting.rs:83 :5
143153 |
144154LL | *(num as *const i32).cast::<i32>().cast_mut() = 2;
145155 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146156
147157error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
148- --> $DIR/reference_casting.rs:80 :5
158+ --> $DIR/reference_casting.rs:85 :5
149159 |
150160LL | *(num as *const _ as usize as *mut i32) = 2;
151161 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
152162
153163error: 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
155192 |
156193LL | *(this as *const _ as *mut _) = a;
157194 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
158195
159- error: aborting due to 25 previous errors
196+ error: aborting due to 29 previous errors
160197
0 commit comments