|
| 1 | +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` |
| 2 | + --> $DIR/cast_ref_to_mut.rs:19:9 |
| 3 | + | |
| 4 | +LL | (*(a as *const _ as *mut String)).push_str(" world"); |
| 5 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 6 | + | |
| 7 | + = note: `#[deny(cast_ref_to_mut)]` on by default |
| 8 | + |
| 9 | +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` |
| 10 | + --> $DIR/cast_ref_to_mut.rs:21:9 |
| 11 | + | |
| 12 | +LL | *(a as *const _ as *mut _) = String::from("Replaced"); |
| 13 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 14 | + |
| 15 | +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` |
| 16 | + --> $DIR/cast_ref_to_mut.rs:23:9 |
| 17 | + | |
| 18 | +LL | *(a as *const _ as *mut String) += " world"; |
| 19 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 20 | + |
| 21 | +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` |
| 22 | + --> $DIR/cast_ref_to_mut.rs:25:25 |
| 23 | + | |
| 24 | +LL | let _num = &mut *(num as *const i32 as *mut i32); |
| 25 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 26 | + |
| 27 | +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` |
| 28 | + --> $DIR/cast_ref_to_mut.rs:27:25 |
| 29 | + | |
| 30 | +LL | let _num = &mut *(num as *const i32).cast_mut(); |
| 31 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 32 | + |
| 33 | +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` |
| 34 | + --> $DIR/cast_ref_to_mut.rs:29:20 |
| 35 | + | |
| 36 | +LL | let _num = *{ num as *const i32 }.cast_mut(); |
| 37 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 38 | + |
| 39 | +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` |
| 40 | + --> $DIR/cast_ref_to_mut.rs:31:9 |
| 41 | + | |
| 42 | +LL | *std::ptr::from_ref(num).cast_mut() += 1; |
| 43 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 44 | + |
| 45 | +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` |
| 46 | + --> $DIR/cast_ref_to_mut.rs:33:9 |
| 47 | + | |
| 48 | +LL | *std::ptr::from_ref({ num }).cast_mut() += 1; |
| 49 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 50 | + |
| 51 | +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` |
| 52 | + --> $DIR/cast_ref_to_mut.rs:35:9 |
| 53 | + | |
| 54 | +LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1; |
| 55 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 56 | + |
| 57 | +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` |
| 58 | + --> $DIR/cast_ref_to_mut.rs:37:9 |
| 59 | + | |
| 60 | +LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1; |
| 61 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 62 | + |
| 63 | +error: aborting due to 10 previous errors |
| 64 | + |
0 commit comments