Skip to content

Commit 98e64e3

Browse files
Allow clippy::unstable_intrinsics_with_stable_wrapper in transmute ui test
1 parent 8800140 commit 98e64e3

File tree

2 files changed

+42
-37
lines changed

2 files changed

+42
-37
lines changed

tests/ui/transmute.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
#![allow(dead_code, clippy::borrow_as_ptr, clippy::needless_lifetimes)]
1+
#![allow(
2+
dead_code,
3+
clippy::borrow_as_ptr,
4+
clippy::needless_lifetimes,
5+
clippy::unstable_intrinsics_with_stable_wrapper
6+
)]
27
//@no-rustfix
38
extern crate core;
49

tests/ui/transmute.stderr

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: transmute from a reference to a pointer
2-
--> $DIR/transmute.rs:24:23
2+
--> $DIR/transmute.rs:29:23
33
|
44
LL | let _: *const T = core::intrinsics::transmute(t);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T`
@@ -8,61 +8,61 @@ LL | let _: *const T = core::intrinsics::transmute(t);
88
= help: to override `-D warnings` add `#[allow(clippy::useless_transmute)]`
99

1010
error: transmute from a reference to a pointer
11-
--> $DIR/transmute.rs:28:21
11+
--> $DIR/transmute.rs:33:21
1212
|
1313
LL | let _: *mut T = core::intrinsics::transmute(t);
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T`
1515

1616
error: transmute from a reference to a pointer
17-
--> $DIR/transmute.rs:31:23
17+
--> $DIR/transmute.rs:36:23
1818
|
1919
LL | let _: *const U = core::intrinsics::transmute(t);
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U`
2121

2222
error: transmute from a type (`std::vec::Vec<i32>`) to itself
23-
--> $DIR/transmute.rs:38:27
23+
--> $DIR/transmute.rs:43:27
2424
|
2525
LL | let _: Vec<i32> = core::intrinsics::transmute(my_vec());
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2727

2828
error: transmute from a type (`std::vec::Vec<i32>`) to itself
29-
--> $DIR/transmute.rs:41:27
29+
--> $DIR/transmute.rs:46:27
3030
|
3131
LL | let _: Vec<i32> = core::mem::transmute(my_vec());
3232
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3333

3434
error: transmute from a type (`std::vec::Vec<i32>`) to itself
35-
--> $DIR/transmute.rs:44:27
35+
--> $DIR/transmute.rs:49:27
3636
|
3737
LL | let _: Vec<i32> = std::intrinsics::transmute(my_vec());
3838
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3939

4040
error: transmute from a type (`std::vec::Vec<i32>`) to itself
41-
--> $DIR/transmute.rs:47:27
41+
--> $DIR/transmute.rs:52:27
4242
|
4343
LL | let _: Vec<i32> = std::mem::transmute(my_vec());
4444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4545

4646
error: transmute from a type (`std::vec::Vec<i32>`) to itself
47-
--> $DIR/transmute.rs:50:27
47+
--> $DIR/transmute.rs:55:27
4848
|
4949
LL | let _: Vec<i32> = my_transmute(my_vec());
5050
| ^^^^^^^^^^^^^^^^^^^^^^
5151

5252
error: transmute from an integer to a pointer
53-
--> $DIR/transmute.rs:53:31
53+
--> $DIR/transmute.rs:58:31
5454
|
5555
LL | let _: *const usize = std::mem::transmute(5_isize);
5656
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize`
5757

5858
error: transmute from an integer to a pointer
59-
--> $DIR/transmute.rs:58:31
59+
--> $DIR/transmute.rs:63:31
6060
|
6161
LL | let _: *const usize = std::mem::transmute(1 + 1usize);
6262
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1 + 1usize) as *const usize`
6363

6464
error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`)
65-
--> $DIR/transmute.rs:90:24
65+
--> $DIR/transmute.rs:95:24
6666
|
6767
LL | let _: Usize = core::intrinsics::transmute(int_const_ptr);
6868
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -71,25 +71,25 @@ LL | let _: Usize = core::intrinsics::transmute(int_const_ptr);
7171
= help: to override `-D warnings` add `#[allow(clippy::crosspointer_transmute)]`
7272

7373
error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`)
74-
--> $DIR/transmute.rs:94:24
74+
--> $DIR/transmute.rs:99:24
7575
|
7676
LL | let _: Usize = core::intrinsics::transmute(int_mut_ptr);
7777
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7878

7979
error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`)
80-
--> $DIR/transmute.rs:97:31
80+
--> $DIR/transmute.rs:102:31
8181
|
8282
LL | let _: *const Usize = core::intrinsics::transmute(my_int());
8383
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8484

8585
error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`)
86-
--> $DIR/transmute.rs:100:29
86+
--> $DIR/transmute.rs:105:29
8787
|
8888
LL | let _: *mut Usize = core::intrinsics::transmute(my_int());
8989
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9090

9191
error: transmute from a `u8` to a `bool`
92-
--> $DIR/transmute.rs:107:28
92+
--> $DIR/transmute.rs:112:28
9393
|
9494
LL | let _: bool = unsafe { std::mem::transmute(0_u8) };
9595
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0`
@@ -98,7 +98,7 @@ LL | let _: bool = unsafe { std::mem::transmute(0_u8) };
9898
= help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_bool)]`
9999

100100
error: transmute from a `u32` to a `f32`
101-
--> $DIR/transmute.rs:115:31
101+
--> $DIR/transmute.rs:120:31
102102
|
103103
LL | let _: f32 = unsafe { std::mem::transmute(0_u32) };
104104
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)`
@@ -107,25 +107,25 @@ LL | let _: f32 = unsafe { std::mem::transmute(0_u32) };
107107
= help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_float)]`
108108

109109
error: transmute from a `i32` to a `f32`
110-
--> $DIR/transmute.rs:118:31
110+
--> $DIR/transmute.rs:123:31
111111
|
112112
LL | let _: f32 = unsafe { std::mem::transmute(0_i32) };
113113
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)`
114114

115115
error: transmute from a `u64` to a `f64`
116-
--> $DIR/transmute.rs:120:31
116+
--> $DIR/transmute.rs:125:31
117117
|
118118
LL | let _: f64 = unsafe { std::mem::transmute(0_u64) };
119119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_u64)`
120120

121121
error: transmute from a `i64` to a `f64`
122-
--> $DIR/transmute.rs:122:31
122+
--> $DIR/transmute.rs:127:31
123123
|
124124
LL | let _: f64 = unsafe { std::mem::transmute(0_i64) };
125125
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_i64 as u64)`
126126

127127
error: transmute from a `u8` to a `[u8; 1]`
128-
--> $DIR/transmute.rs:143:30
128+
--> $DIR/transmute.rs:148:30
129129
|
130130
LL | let _: [u8; 1] = std::mem::transmute(0u8);
131131
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()`
@@ -134,85 +134,85 @@ LL | let _: [u8; 1] = std::mem::transmute(0u8);
134134
= help: to override `-D warnings` add `#[allow(clippy::transmute_num_to_bytes)]`
135135

136136
error: transmute from a `u32` to a `[u8; 4]`
137-
--> $DIR/transmute.rs:146:30
137+
--> $DIR/transmute.rs:151:30
138138
|
139139
LL | let _: [u8; 4] = std::mem::transmute(0u32);
140140
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()`
141141

142142
error: transmute from a `u128` to a `[u8; 16]`
143-
--> $DIR/transmute.rs:148:31
143+
--> $DIR/transmute.rs:153:31
144144
|
145145
LL | let _: [u8; 16] = std::mem::transmute(0u128);
146146
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()`
147147

148148
error: transmute from a `i8` to a `[u8; 1]`
149-
--> $DIR/transmute.rs:150:30
149+
--> $DIR/transmute.rs:155:30
150150
|
151151
LL | let _: [u8; 1] = std::mem::transmute(0i8);
152152
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()`
153153

154154
error: transmute from a `i32` to a `[u8; 4]`
155-
--> $DIR/transmute.rs:152:30
155+
--> $DIR/transmute.rs:157:30
156156
|
157157
LL | let _: [u8; 4] = std::mem::transmute(0i32);
158158
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()`
159159

160160
error: transmute from a `i128` to a `[u8; 16]`
161-
--> $DIR/transmute.rs:154:31
161+
--> $DIR/transmute.rs:159:31
162162
|
163163
LL | let _: [u8; 16] = std::mem::transmute(0i128);
164164
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()`
165165

166166
error: transmute from a `f32` to a `[u8; 4]`
167-
--> $DIR/transmute.rs:156:30
167+
--> $DIR/transmute.rs:161:30
168168
|
169169
LL | let _: [u8; 4] = std::mem::transmute(0.0f32);
170170
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()`
171171

172172
error: transmute from a `f64` to a `[u8; 8]`
173-
--> $DIR/transmute.rs:158:30
173+
--> $DIR/transmute.rs:163:30
174174
|
175175
LL | let _: [u8; 8] = std::mem::transmute(0.0f64);
176176
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()`
177177

178178
error: transmute from a `u8` to a `[u8; 1]`
179-
--> $DIR/transmute.rs:164:30
179+
--> $DIR/transmute.rs:169:30
180180
|
181181
LL | let _: [u8; 1] = std::mem::transmute(0u8);
182182
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()`
183183

184184
error: transmute from a `u32` to a `[u8; 4]`
185-
--> $DIR/transmute.rs:166:30
185+
--> $DIR/transmute.rs:171:30
186186
|
187187
LL | let _: [u8; 4] = std::mem::transmute(0u32);
188188
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()`
189189

190190
error: transmute from a `u128` to a `[u8; 16]`
191-
--> $DIR/transmute.rs:168:31
191+
--> $DIR/transmute.rs:173:31
192192
|
193193
LL | let _: [u8; 16] = std::mem::transmute(0u128);
194194
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()`
195195

196196
error: transmute from a `i8` to a `[u8; 1]`
197-
--> $DIR/transmute.rs:170:30
197+
--> $DIR/transmute.rs:175:30
198198
|
199199
LL | let _: [u8; 1] = std::mem::transmute(0i8);
200200
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()`
201201

202202
error: transmute from a `i32` to a `[u8; 4]`
203-
--> $DIR/transmute.rs:172:30
203+
--> $DIR/transmute.rs:177:30
204204
|
205205
LL | let _: [u8; 4] = std::mem::transmute(0i32);
206206
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()`
207207

208208
error: transmute from a `i128` to a `[u8; 16]`
209-
--> $DIR/transmute.rs:174:31
209+
--> $DIR/transmute.rs:179:31
210210
|
211211
LL | let _: [u8; 16] = std::mem::transmute(0i128);
212212
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()`
213213

214214
error: transmute from a `&[u8]` to a `&str`
215-
--> $DIR/transmute.rs:185:28
215+
--> $DIR/transmute.rs:190:28
216216
|
217217
LL | let _: &str = unsafe { std::mem::transmute(B) };
218218
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(B).unwrap()`
@@ -221,13 +221,13 @@ LL | let _: &str = unsafe { std::mem::transmute(B) };
221221
= help: to override `-D warnings` add `#[allow(clippy::transmute_bytes_to_str)]`
222222

223223
error: transmute from a `&mut [u8]` to a `&mut str`
224-
--> $DIR/transmute.rs:188:32
224+
--> $DIR/transmute.rs:193:32
225225
|
226226
LL | let _: &mut str = unsafe { std::mem::transmute(mb) };
227227
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()`
228228

229229
error: transmute from a `&[u8]` to a `&str`
230-
--> $DIR/transmute.rs:190:30
230+
--> $DIR/transmute.rs:195:30
231231
|
232232
LL | const _: &str = unsafe { std::mem::transmute(B) };
233233
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_unchecked(B)`

0 commit comments

Comments
 (0)