1
1
warning: transmuting an integer to a pointer creates a pointer without provenance
2
- --> $DIR/int_to_ptr.rs:10:25
2
+ --> $DIR/int_to_ptr.rs:10:36
3
3
|
4
- LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a) };
5
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4
+ LL | let _ptr: *const u8 = unsafe { std::mem::transmute::<usize, *const u8>(a) };
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6
6
|
7
7
= note: this is dangerous because dereferencing the resulting pointer is undefined behavior
8
8
= note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
@@ -12,15 +12,15 @@ LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a) };
12
12
= note: `#[warn(integer_to_ptr_transmutes)]` on by default
13
13
help: use `as` cast instead to use a previously exposed provenance
14
14
|
15
- LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a) };
16
- LL + let _ptr = unsafe { a as *const u8 };
15
+ LL - let _ptr: *const u8 = unsafe { std::mem::transmute::<usize, *const u8>(a) };
16
+ LL + let _ptr: *const u8 = unsafe { std::ptr::with_exposed_provenance::<u8>(a) };
17
17
|
18
18
19
19
warning: transmuting an integer to a pointer creates a pointer without provenance
20
- --> $DIR/int_to_ptr.rs:12:25
20
+ --> $DIR/int_to_ptr.rs:12:34
21
21
|
22
- LL | let _ptr = unsafe { std::mem::transmute::<usize, &'static u8>(a) };
23
- | ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22
+ LL | let _ptr: *mut u8 = unsafe { std::mem::transmute::<usize, *mut u8>(a) };
23
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24
24
|
25
25
= note: this is dangerous because dereferencing the resulting pointer is undefined behavior
26
26
= note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
@@ -29,12 +29,46 @@ LL | let _ptr = unsafe { std::mem::transmute::<usize, &'static u8>(a) };
29
29
= help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
30
30
help: use `as` cast instead to use a previously exposed provenance
31
31
|
32
- LL - let _ptr = unsafe { std::mem::transmute::<usize, &'static u8>(a) };
33
- LL + let _ptr = unsafe { &*(a as *const u8 ) };
32
+ LL - let _ptr: *mut u8 = unsafe { std::mem::transmute::<usize, *mut u8>(a) };
33
+ LL + let _ptr: *mut u8 = unsafe { std::ptr::with_exposed_provenance_mut::<u8>(a ) };
34
34
|
35
35
36
36
warning: transmuting an integer to a pointer creates a pointer without provenance
37
- --> $DIR/int_to_ptr.rs:14:25
37
+ --> $DIR/int_to_ptr.rs:14:38
38
+ |
39
+ LL | let _ref: &'static u8 = unsafe { std::mem::transmute::<usize, &'static u8>(a) };
40
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41
+ |
42
+ = note: this is dangerous because dereferencing the resulting pointer is undefined behavior
43
+ = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
44
+ = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`
45
+ = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>
46
+ = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
47
+ help: use `as` cast instead to use a previously exposed provenance
48
+ |
49
+ LL - let _ref: &'static u8 = unsafe { std::mem::transmute::<usize, &'static u8>(a) };
50
+ LL + let _ref: &'static u8 = unsafe { &*std::ptr::with_exposed_provenance::<u8>(a) };
51
+ |
52
+
53
+ warning: transmuting an integer to a pointer creates a pointer without provenance
54
+ --> $DIR/int_to_ptr.rs:16:42
55
+ |
56
+ LL | let _ref: &'static mut u8 = unsafe { std::mem::transmute::<usize, &'static mut u8>(a) };
57
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58
+ |
59
+ = note: this is dangerous because dereferencing the resulting pointer is undefined behavior
60
+ = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
61
+ = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`
62
+ = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>
63
+ = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
64
+ help: use `as` cast instead to use a previously exposed provenance
65
+ |
66
+ LL - let _ref: &'static mut u8 = unsafe { std::mem::transmute::<usize, &'static mut u8>(a) };
67
+ LL + let _ref: &'static mut u8 = unsafe { &mut *std::ptr::with_exposed_provenance_mut::<u8>(a) };
68
+ |
69
+
70
+ warning: transmuting an integer to a pointer creates a pointer without provenance
71
+ --> $DIR/int_to_ptr.rs:19:25
38
72
|
39
73
LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(42usize) };
40
74
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -47,11 +81,11 @@ LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(42usize) };
47
81
help: use `as` cast instead to use a previously exposed provenance
48
82
|
49
83
LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(42usize) };
50
- LL + let _ptr = unsafe { 42usize as *const u8 };
84
+ LL + let _ptr = unsafe { std::ptr::with_exposed_provenance::<u8>(42usize) };
51
85
|
52
86
53
87
warning: transmuting an integer to a pointer creates a pointer without provenance
54
- --> $DIR/int_to_ptr.rs:16 :25
88
+ --> $DIR/int_to_ptr.rs:21 :25
55
89
|
56
90
LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) };
57
91
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -64,14 +98,48 @@ LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) };
64
98
help: use `as` cast instead to use a previously exposed provenance
65
99
|
66
100
LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) };
67
- LL + let _ptr = unsafe { (a + a) as *const u8 };
101
+ LL + let _ptr = unsafe { std::ptr::with_exposed_provenance::<u8> (a + a) };
68
102
|
69
103
70
104
warning: transmuting an integer to a pointer creates a pointer without provenance
71
- --> $DIR/int_to_ptr.rs:21:25
105
+ --> $DIR/int_to_ptr.rs:26:36
106
+ |
107
+ LL | let _ptr: *const u8 = unsafe { std::mem::transmute::<usize, *const u8>(a) };
108
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
109
+ |
110
+ = note: this is dangerous because dereferencing the resulting pointer is undefined behavior
111
+ = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
112
+ = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`
113
+ = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>
114
+ = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
115
+ help: use `as` cast instead to use a previously exposed provenance
116
+ |
117
+ LL - let _ptr: *const u8 = unsafe { std::mem::transmute::<usize, *const u8>(a) };
118
+ LL + let _ptr: *const u8 = unsafe { a as *const u8 };
119
+ |
120
+
121
+ warning: transmuting an integer to a pointer creates a pointer without provenance
122
+ --> $DIR/int_to_ptr.rs:28:34
123
+ |
124
+ LL | let _ptr: *mut u8 = unsafe { std::mem::transmute::<usize, *mut u8>(a) };
125
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
126
+ |
127
+ = note: this is dangerous because dereferencing the resulting pointer is undefined behavior
128
+ = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
129
+ = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`
130
+ = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>
131
+ = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
132
+ help: use `as` cast instead to use a previously exposed provenance
133
+ |
134
+ LL - let _ptr: *mut u8 = unsafe { std::mem::transmute::<usize, *mut u8>(a) };
135
+ LL + let _ptr: *mut u8 = unsafe { a as *mut u8 };
136
+ |
137
+
138
+ warning: transmuting an integer to a pointer creates a pointer without provenance
139
+ --> $DIR/int_to_ptr.rs:30:38
72
140
|
73
- LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a) };
74
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
141
+ LL | let _ref: &'static u8 = unsafe { std::mem::transmute::<usize, &'static u8>(a) };
142
+ | ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
75
143
|
76
144
= note: this is dangerous because dereferencing the resulting pointer is undefined behavior
77
145
= note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
@@ -80,15 +148,15 @@ LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a) };
80
148
= help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
81
149
help: use `as` cast instead to use a previously exposed provenance
82
150
|
83
- LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a) };
84
- LL + let _ptr = unsafe { a as *const u8 };
151
+ LL - let _ref: &'static u8 = unsafe { std::mem::transmute::<usize, &'static u8>(a) };
152
+ LL + let _ref: &'static u8 = unsafe { &*( a as *const u8) };
85
153
|
86
154
87
155
warning: transmuting an integer to a pointer creates a pointer without provenance
88
- --> $DIR/int_to_ptr.rs:23:25
156
+ --> $DIR/int_to_ptr.rs:32:42
89
157
|
90
- LL | let _ptr = unsafe { std::mem::transmute::<usize, &'static u8>(a) };
91
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
158
+ LL | let _ref: &'static mut u8 = unsafe { std::mem::transmute::<usize, &'static mut u8>(a) };
159
+ | ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
92
160
|
93
161
= note: this is dangerous because dereferencing the resulting pointer is undefined behavior
94
162
= note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
@@ -97,12 +165,12 @@ LL | let _ptr = unsafe { std::mem::transmute::<usize, &'static u8>(a) };
97
165
= help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
98
166
help: use `as` cast instead to use a previously exposed provenance
99
167
|
100
- LL - let _ptr = unsafe { std::mem::transmute::<usize, &'static u8>(a) };
101
- LL + let _ptr = unsafe { &*(a as *const u8) };
168
+ LL - let _ref: &'static mut u8 = unsafe { std::mem::transmute::<usize, &'static mut u8>(a) };
169
+ LL + let _ref: &'static mut u8 = unsafe { &mut *(a as *mut u8) };
102
170
|
103
171
104
172
warning: transmuting an integer to a pointer creates a pointer without provenance
105
- --> $DIR/int_to_ptr.rs:25 :25
173
+ --> $DIR/int_to_ptr.rs:35 :25
106
174
|
107
175
LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(42usize) };
108
176
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -119,7 +187,7 @@ LL + let _ptr = unsafe { 42usize as *const u8 };
119
187
|
120
188
121
189
warning: transmuting an integer to a pointer creates a pointer without provenance
122
- --> $DIR/int_to_ptr.rs:27 :25
190
+ --> $DIR/int_to_ptr.rs:37 :25
123
191
|
124
192
LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) };
125
193
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -135,5 +203,5 @@ LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) };
135
203
LL + let _ptr = unsafe { (a + a) as *const u8 };
136
204
|
137
205
138
- warning: 8 warnings emitted
206
+ warning: 12 warnings emitted
139
207
0 commit comments