about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/ptr_cast_constness.stderr
blob: 4adb5cc5ad7fe20cc8b31d541026d46751b355f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
error: `as` casting between raw pointers while changing only its constness
  --> tests/ui/ptr_cast_constness.rs:16:45
   |
LL |         let _: &mut T = std::mem::transmute(p as *mut T);
   |                                             ^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `p.cast_mut()`
   |
   = note: `-D clippy::ptr-cast-constness` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::ptr_cast_constness)]`

error: `as` casting between raw pointers while changing only its constness
  --> tests/ui/ptr_cast_constness.rs:18:23
   |
LL |         let _ = &mut *(p as *mut T);
   |                       ^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `p.cast_mut()`

error: `as` casting between raw pointers while changing only its constness
  --> tests/ui/ptr_cast_constness.rs:35:17
   |
LL |         let _ = *ptr_ptr as *mut u32;
   |                 ^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `(*ptr_ptr).cast_mut()`

error: `as` casting between raw pointers while changing only its constness
  --> tests/ui/ptr_cast_constness.rs:39:13
   |
LL |     let _ = ptr as *mut u32;
   |             ^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `ptr.cast_mut()`

error: `as` casting between raw pointers while changing only its constness
  --> tests/ui/ptr_cast_constness.rs:41:13
   |
LL |     let _ = mut_ptr as *const u32;
   |             ^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_const`, a safer alternative: `mut_ptr.cast_const()`

error: `as` casting between raw pointers while changing only its constness
  --> tests/ui/ptr_cast_constness.rs:75:13
   |
LL |     let _ = ptr as *mut u32;
   |             ^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `ptr.cast_mut()`

error: `as` casting between raw pointers while changing only its constness
  --> tests/ui/ptr_cast_constness.rs:77:13
   |
LL |     let _ = mut_ptr as *const u32;
   |             ^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_const`, a safer alternative: `mut_ptr.cast_const()`

error: `as` casting to make a const null pointer into a mutable null pointer
  --> tests/ui/ptr_cast_constness.rs:84:13
   |
LL |     let _ = ptr::null::<String>() as *mut String;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `null_mut()` directly instead: `std::ptr::null_mut::<String>()`

error: `as` casting to make a mutable null pointer into a const null pointer
  --> tests/ui/ptr_cast_constness.rs:86:13
   |
LL |     let _ = ptr::null_mut::<u32>() as *const u32;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `null()` directly instead: `std::ptr::null::<u32>()`

error: changing constness of a null pointer
  --> tests/ui/ptr_cast_constness.rs:88:13
   |
LL |     let _ = ptr::null::<u32>().cast_mut();
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `null_mut()` directly instead: `std::ptr::null_mut::<u32>()`

error: changing constness of a null pointer
  --> tests/ui/ptr_cast_constness.rs:90:13
   |
LL |     let _ = ptr::null_mut::<u32>().cast_const();
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `null()` directly instead: `std::ptr::null::<u32>()`

error: `as` casting to make a const null pointer into a mutable null pointer
  --> tests/ui/ptr_cast_constness.rs:94:21
   |
LL |     let _ = inline!(ptr::null::<u32>() as *mut u32);
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `null_mut()` directly instead: `std::ptr::null_mut::<u32>()`
   |
   = note: this error originates in the macro `__inline_mac_fn_null_pointers` (in Nightly builds, run with -Z macro-backtrace for more info)

error: changing constness of a null pointer
  --> tests/ui/ptr_cast_constness.rs:96:21
   |
LL |     let _ = inline!(ptr::null::<u32>().cast_mut());
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `null_mut()` directly instead: `std::ptr::null_mut::<u32>()`
   |
   = note: this error originates in the macro `__inline_mac_fn_null_pointers` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `as` casting between raw pointers while changing only its constness
  --> tests/ui/ptr_cast_constness.rs:106:13
   |
LL |     let _ = std::ptr::addr_of_mut!(local) as *const _;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_const`, a safer alternative: `std::ptr::addr_of_mut!(local).cast_const()`

error: `as` casting between raw pointers while changing only its constness
  --> tests/ui/ptr_cast_constness.rs:112:26
   |
LL |     let _ptr: *mut u32 = r as *const _ as *mut _;
   |                          ^^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `(r as *const u32).cast_mut()`

error: aborting due to 15 previous errors