|
1 | 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 |
| 2 | + --> $DIR/reference_casting.rs:20:9 |
3 | 3 | |
|
4 | 4 | LL | (*(a as *const _ as *mut String)).push_str(" world");
|
5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
6 | 6 | |
|
7 |
| - = note: `#[deny(cast_ref_to_mut)]` on by default |
| 7 | +note: the lint level is defined here |
| 8 | + --> $DIR/reference_casting.rs:4:9 |
| 9 | + | |
| 10 | +LL | #![deny(invalid_reference_casting)] |
| 11 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
8 | 12 |
|
9 | 13 | 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 |
| 14 | + --> $DIR/reference_casting.rs:22:9 |
11 | 15 | |
|
12 | 16 | LL | *(a as *const _ as *mut _) = String::from("Replaced");
|
13 | 17 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
14 | 18 |
|
15 | 19 | 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 |
| 20 | + --> $DIR/reference_casting.rs:24:9 |
17 | 21 | |
|
18 | 22 | LL | *(a as *const _ as *mut String) += " world";
|
19 | 23 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
20 | 24 |
|
21 | 25 | 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 |
| 26 | + --> $DIR/reference_casting.rs:26:25 |
23 | 27 | |
|
24 | 28 | LL | let _num = &mut *(num as *const i32 as *mut i32);
|
25 | 29 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
26 | 30 |
|
27 | 31 | 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 |
| 32 | + --> $DIR/reference_casting.rs:28:25 |
29 | 33 | |
|
30 | 34 | LL | let _num = &mut *(num as *const i32).cast_mut();
|
31 | 35 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
32 | 36 |
|
33 | 37 | 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 |
| 38 | + --> $DIR/reference_casting.rs:30:20 |
35 | 39 | |
|
36 | 40 | LL | let _num = *{ num as *const i32 }.cast_mut();
|
37 | 41 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
38 | 42 |
|
39 | 43 | 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 |
| 44 | + --> $DIR/reference_casting.rs:32:9 |
41 | 45 | |
|
42 | 46 | LL | *std::ptr::from_ref(num).cast_mut() += 1;
|
43 | 47 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
44 | 48 |
|
45 | 49 | 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 |
| 50 | + --> $DIR/reference_casting.rs:34:9 |
47 | 51 | |
|
48 | 52 | LL | *std::ptr::from_ref({ num }).cast_mut() += 1;
|
49 | 53 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
50 | 54 |
|
51 | 55 | 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 |
| 56 | + --> $DIR/reference_casting.rs:36:9 |
53 | 57 | |
|
54 | 58 | LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1;
|
55 | 59 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
56 | 60 |
|
57 | 61 | 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 |
| 62 | + --> $DIR/reference_casting.rs:38:9 |
59 | 63 | |
|
60 | 64 | LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1;
|
61 | 65 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
0 commit comments