11warning: 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
33 |
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+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66 |
77 = note: this is dangerous because dereferencing the resulting pointer is undefined behavior
88 = 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) };
1212 = note: `#[warn(integer_to_ptr_transmutes)]` on by default
1313help: use `as` cast instead to use a previously exposed provenance
1414 |
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) };
1717 |
1818
1919warning: 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
2121 |
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+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424 |
2525 = note: this is dangerous because dereferencing the resulting pointer is undefined behavior
2626 = 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) };
2929 = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
3030help: use `as` cast instead to use a previously exposed provenance
3131 |
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 ) };
3434 |
3535
3636warning: 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
3872 |
3973LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(42usize) };
4074 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -47,11 +81,11 @@ LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(42usize) };
4781help: use `as` cast instead to use a previously exposed provenance
4882 |
4983LL - 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) };
5185 |
5286
5387warning: 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
5589 |
5690LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) };
5791 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -64,14 +98,48 @@ LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) };
6498help: use `as` cast instead to use a previously exposed provenance
6599 |
66100LL - 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) };
68102 |
69103
70104warning: 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
72140 |
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+ | ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
75143 |
76144 = note: this is dangerous because dereferencing the resulting pointer is undefined behavior
77145 = 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) };
80148 = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
81149help: use `as` cast instead to use a previously exposed provenance
82150 |
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) };
85153 |
86154
87155warning: 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
89157 |
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+ | ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
92160 |
93161 = note: this is dangerous because dereferencing the resulting pointer is undefined behavior
94162 = 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) };
97165 = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
98166help: use `as` cast instead to use a previously exposed provenance
99167 |
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) };
102170 |
103171
104172warning: 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
106174 |
107175LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(42usize) };
108176 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -119,7 +187,7 @@ LL + let _ptr = unsafe { 42usize as *const u8 };
119187 |
120188
121189warning: 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
123191 |
124192LL | let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) };
125193 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -135,5 +203,5 @@ LL - let _ptr = unsafe { std::mem::transmute::<usize, *const u8>(a + a) };
135203LL + let _ptr = unsafe { (a + a) as *const u8 };
136204 |
137205
138- warning: 8 warnings emitted
206+ warning: 12 warnings emitted
139207
0 commit comments