@@ -37,56 +37,68 @@ LL | let _num = &mut *(std::ptr::from_ref({ num }) as *mut i32);
37
37
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38
38
39
39
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:29:16
40
+ --> $DIR/reference_casting.rs:27:16
41
+ |
42
+ LL | let _num = &mut *std::mem::transmute::<_, *mut i32>(num);
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/reference_casting.rs:31:16
41
47
|
42
48
LL | let deferred = num as *const i32 as *mut i32;
43
49
| ----------------------------- casting happend here
44
50
LL | let _num = &mut *deferred;
45
51
| ^^^^^^^^^^^^^^
46
52
47
53
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
48
- --> $DIR/reference_casting.rs:38 :5
54
+ --> $DIR/reference_casting.rs:40 :5
49
55
|
50
56
LL | *(a as *const _ as *mut _) = String::from("Replaced");
51
57
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52
58
53
59
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
54
- --> $DIR/reference_casting.rs:40 :5
60
+ --> $DIR/reference_casting.rs:42 :5
55
61
|
56
62
LL | *(a as *const _ as *mut String) += " world";
57
63
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58
64
59
65
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
60
- --> $DIR/reference_casting.rs:42 :5
66
+ --> $DIR/reference_casting.rs:44 :5
61
67
|
62
68
LL | *std::ptr::from_ref(num).cast_mut() += 1;
63
69
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64
70
65
71
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
66
- --> $DIR/reference_casting.rs:44 :5
72
+ --> $DIR/reference_casting.rs:46 :5
67
73
|
68
74
LL | *std::ptr::from_ref({ num }).cast_mut() += 1;
69
75
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70
76
71
77
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
72
- --> $DIR/reference_casting.rs:46 :5
78
+ --> $DIR/reference_casting.rs:48 :5
73
79
|
74
80
LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1;
75
81
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76
82
77
83
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
78
- --> $DIR/reference_casting.rs:48 :5
84
+ --> $DIR/reference_casting.rs:50 :5
79
85
|
80
86
LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1;
81
87
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
82
88
83
89
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
84
- --> $DIR/reference_casting.rs:51:5
90
+ --> $DIR/reference_casting.rs:52:5
91
+ |
92
+ LL | *std::mem::transmute::<_, *mut i32>(num) += 1;
93
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
94
+
95
+ error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
96
+ --> $DIR/reference_casting.rs:56:5
85
97
|
86
98
LL | let value = num as *const i32 as *mut i32;
87
99
| ----------------------------- casting happend here
88
100
LL | *value = 1;
89
101
| ^^^^^^^^^^
90
102
91
- error: aborting due to 14 previous errors
103
+ error: aborting due to 16 previous errors
92
104
0 commit comments