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