2023-05-14 09:20:32 -05:00
|
|
|
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
|
2023-07-06 14:50:34 -05:00
|
|
|
--> $DIR/reference_casting.rs:20:9
|
2023-05-14 09:20:32 -05:00
|
|
|
|
|
|
|
|
LL | (*(a as *const _ as *mut String)).push_str(" world");
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2023-07-06 14:50:34 -05:00
|
|
|
note: the lint level is defined here
|
|
|
|
--> $DIR/reference_casting.rs:4:9
|
|
|
|
|
|
|
|
|
LL | #![deny(invalid_reference_casting)]
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
2023-05-14 09:20:32 -05:00
|
|
|
|
|
|
|
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
|
2023-07-06 14:50:34 -05:00
|
|
|
--> $DIR/reference_casting.rs:22:9
|
2023-05-14 09:20:32 -05:00
|
|
|
|
|
|
|
|
LL | *(a as *const _ as *mut _) = String::from("Replaced");
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
|
2023-07-06 14:50:34 -05:00
|
|
|
--> $DIR/reference_casting.rs:24:9
|
2023-05-14 09:20:32 -05:00
|
|
|
|
|
|
|
|
LL | *(a as *const _ as *mut String) += " world";
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
|
2023-07-06 14:50:34 -05:00
|
|
|
--> $DIR/reference_casting.rs:26:25
|
2023-05-14 09:20:32 -05:00
|
|
|
|
|
|
|
|
LL | let _num = &mut *(num as *const i32 as *mut i32);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
|
2023-07-06 14:50:34 -05:00
|
|
|
--> $DIR/reference_casting.rs:28:25
|
2023-05-14 09:20:32 -05:00
|
|
|
|
|
|
|
|
LL | let _num = &mut *(num as *const i32).cast_mut();
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
|
2023-07-06 14:50:34 -05:00
|
|
|
--> $DIR/reference_casting.rs:30:20
|
2023-05-14 09:20:32 -05:00
|
|
|
|
|
|
|
|
LL | let _num = *{ num as *const i32 }.cast_mut();
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
|
2023-07-06 14:50:34 -05:00
|
|
|
--> $DIR/reference_casting.rs:32:9
|
2023-05-14 09:20:32 -05:00
|
|
|
|
|
|
|
|
LL | *std::ptr::from_ref(num).cast_mut() += 1;
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
|
2023-07-06 14:50:34 -05:00
|
|
|
--> $DIR/reference_casting.rs:34:9
|
2023-05-14 09:20:32 -05:00
|
|
|
|
|
|
|
|
LL | *std::ptr::from_ref({ num }).cast_mut() += 1;
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
|
2023-07-06 14:50:34 -05:00
|
|
|
--> $DIR/reference_casting.rs:36:9
|
2023-05-14 09:20:32 -05:00
|
|
|
|
|
|
|
|
LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1;
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
|
2023-07-06 14:50:34 -05:00
|
|
|
--> $DIR/reference_casting.rs:38:9
|
2023-05-14 09:20:32 -05:00
|
|
|
|
|
|
|
|
LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1;
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
error: aborting due to 10 previous errors
|
|
|
|
|