]> git.lizzy.rs Git - rust.git/blob - tests/ui/transmute.stderr
Auto merge of #3635 - matthiaskrgr:revert_random_state_3603, r=xfix
[rust.git] / tests / ui / transmute.stderr
1 error: transmute from a type (`&'a T`) to itself
2   --> $DIR/transmute.rs:28:20
3    |
4 LL |     let _: &'a T = core::intrinsics::transmute(t);
5    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6    |
7    = note: `-D clippy::useless-transmute` implied by `-D warnings`
8
9 error: transmute from a reference to a pointer
10   --> $DIR/transmute.rs:32:23
11    |
12 LL |     let _: *const T = core::intrinsics::transmute(t);
13    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T`
14
15 error: transmute from a reference to a pointer
16   --> $DIR/transmute.rs:34:21
17    |
18 LL |     let _: *mut T = core::intrinsics::transmute(t);
19    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T`
20
21 error: transmute from a reference to a pointer
22   --> $DIR/transmute.rs:36:23
23    |
24 LL |     let _: *const U = core::intrinsics::transmute(t);
25    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U`
26
27 error: transmute from a pointer type (`*const T`) to a reference type (`&T`)
28   --> $DIR/transmute.rs:41:17
29    |
30 LL |     let _: &T = std::mem::transmute(p);
31    |                 ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p`
32    |
33    = note: `-D clippy::transmute-ptr-to-ref` implied by `-D warnings`
34
35 error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`)
36   --> $DIR/transmute.rs:44:21
37    |
38 LL |     let _: &mut T = std::mem::transmute(m);
39    |                     ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *m`
40
41 error: transmute from a pointer type (`*mut T`) to a reference type (`&T`)
42   --> $DIR/transmute.rs:47:17
43    |
44 LL |     let _: &T = std::mem::transmute(m);
45    |                 ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*m`
46
47 error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`)
48   --> $DIR/transmute.rs:50:21
49    |
50 LL |     let _: &mut T = std::mem::transmute(p as *mut T);
51    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(p as *mut T)`
52
53 error: transmute from a pointer type (`*const U`) to a reference type (`&T`)
54   --> $DIR/transmute.rs:53:17
55    |
56 LL |     let _: &T = std::mem::transmute(o);
57    |                 ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(o as *const T)`
58
59 error: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`)
60   --> $DIR/transmute.rs:56:21
61    |
62 LL |     let _: &mut T = std::mem::transmute(om);
63    |                     ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(om as *mut T)`
64
65 error: transmute from a pointer type (`*mut U`) to a reference type (`&T`)
66   --> $DIR/transmute.rs:59:17
67    |
68 LL |     let _: &T = std::mem::transmute(om);
69    |                 ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(om as *const T)`
70
71 error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, u8>`)
72   --> $DIR/transmute.rs:70:32
73    |
74 LL |     let _: &Foo<u8> = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) };
75    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<_>)`
76
77 error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, &u8>`)
78   --> $DIR/transmute.rs:72:33
79    |
80 LL |     let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) };
81    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<&_>)`
82
83 error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`)
84   --> $DIR/transmute.rs:76:14
85    |
86 LL |     unsafe { std::mem::transmute::<_, Bar>(raw) };
87    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const u8)`
88
89 error: transmute from a type (`std::vec::Vec<i32>`) to itself
90   --> $DIR/transmute.rs:82:27
91    |
92 LL |         let _: Vec<i32> = core::intrinsics::transmute(my_vec());
93    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
94
95 error: transmute from a type (`std::vec::Vec<i32>`) to itself
96   --> $DIR/transmute.rs:84:27
97    |
98 LL |         let _: Vec<i32> = core::mem::transmute(my_vec());
99    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
100
101 error: transmute from a type (`std::vec::Vec<i32>`) to itself
102   --> $DIR/transmute.rs:86:27
103    |
104 LL |         let _: Vec<i32> = std::intrinsics::transmute(my_vec());
105    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106
107 error: transmute from a type (`std::vec::Vec<i32>`) to itself
108   --> $DIR/transmute.rs:88:27
109    |
110 LL |         let _: Vec<i32> = std::mem::transmute(my_vec());
111    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
112
113 error: transmute from a type (`std::vec::Vec<i32>`) to itself
114   --> $DIR/transmute.rs:90:27
115    |
116 LL |         let _: Vec<i32> = my_transmute(my_vec());
117    |                           ^^^^^^^^^^^^^^^^^^^^^^
118
119 error: transmute from an integer to a pointer
120   --> $DIR/transmute.rs:98:31
121    |
122 LL |         let _: *const usize = std::mem::transmute(5_isize);
123    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize`
124
125 error: transmute from an integer to a pointer
126   --> $DIR/transmute.rs:102:31
127    |
128 LL |         let _: *const usize = std::mem::transmute(1 + 1usize);
129    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1 + 1usize) as *const usize`
130
131 error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`)
132   --> $DIR/transmute.rs:117:24
133    |
134 LL |         let _: Usize = core::intrinsics::transmute(int_const_ptr);
135    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
136    |
137    = note: `-D clippy::crosspointer-transmute` implied by `-D warnings`
138
139 error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`)
140   --> $DIR/transmute.rs:119:24
141    |
142 LL |         let _: Usize = core::intrinsics::transmute(int_mut_ptr);
143    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144
145 error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`)
146   --> $DIR/transmute.rs:121:31
147    |
148 LL |         let _: *const Usize = core::intrinsics::transmute(my_int());
149    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150
151 error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`)
152   --> $DIR/transmute.rs:123:29
153    |
154 LL |         let _: *mut Usize = core::intrinsics::transmute(my_int());
155    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156
157 error: transmute from a `u32` to a `char`
158   --> $DIR/transmute.rs:129:28
159    |
160 LL |     let _: char = unsafe { std::mem::transmute(0_u32) };
161    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_u32).unwrap()`
162    |
163    = note: `-D clippy::transmute-int-to-char` implied by `-D warnings`
164
165 error: transmute from a `i32` to a `char`
166   --> $DIR/transmute.rs:130:28
167    |
168 LL |     let _: char = unsafe { std::mem::transmute(0_i32) };
169    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_i32 as u32).unwrap()`
170
171 error: transmute from a `u8` to a `bool`
172   --> $DIR/transmute.rs:135:28
173    |
174 LL |     let _: bool = unsafe { std::mem::transmute(0_u8) };
175    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0`
176    |
177    = note: `-D clippy::transmute-int-to-bool` implied by `-D warnings`
178
179 error: transmute from a `u32` to a `f32`
180   --> $DIR/transmute.rs:140:27
181    |
182 LL |     let _: f32 = unsafe { std::mem::transmute(0_u32) };
183    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)`
184    |
185    = note: `-D clippy::transmute-int-to-float` implied by `-D warnings`
186
187 error: transmute from a `i32` to a `f32`
188   --> $DIR/transmute.rs:141:27
189    |
190 LL |     let _: f32 = unsafe { std::mem::transmute(0_i32) };
191    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)`
192
193 error: transmute from a `&[u8]` to a `&str`
194   --> $DIR/transmute.rs:145:28
195    |
196 LL |     let _: &str = unsafe { std::mem::transmute(b) };
197    |                            ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(b).unwrap()`
198    |
199    = note: `-D clippy::transmute-bytes-to-str` implied by `-D warnings`
200
201 error: transmute from a `&mut [u8]` to a `&mut str`
202   --> $DIR/transmute.rs:146:32
203    |
204 LL |     let _: &mut str = unsafe { std::mem::transmute(mb) };
205    |                                ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()`
206
207 error: transmute from a pointer to a pointer
208   --> $DIR/transmute.rs:178:29
209    |
210 LL |         let _: *const f32 = std::mem::transmute(ptr);
211    |                             ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr as *const f32`
212    |
213    = note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings`
214
215 error: transmute from a pointer to a pointer
216   --> $DIR/transmute.rs:179:27
217    |
218 LL |         let _: *mut f32 = std::mem::transmute(mut_ptr);
219    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `mut_ptr as *mut f32`
220
221 error: transmute from a reference to a reference
222   --> $DIR/transmute.rs:181:23
223    |
224 LL |         let _: &f32 = std::mem::transmute(&1u32);
225    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1u32 as *const u32 as *const f32)`
226
227 error: transmute from a reference to a reference
228   --> $DIR/transmute.rs:182:23
229    |
230 LL |         let _: &f64 = std::mem::transmute(&1f32);
231    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f32 as *const f32 as *const f64)`
232
233 error: transmute from a reference to a reference
234   --> $DIR/transmute.rs:185:27
235    |
236 LL |         let _: &mut f32 = std::mem::transmute(&mut 1u32);
237    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(&mut 1u32 as *mut u32 as *mut f32)`
238
239 error: transmute from a reference to a reference
240   --> $DIR/transmute.rs:186:37
241    |
242 LL |         let _: &GenericParam<f32> = std::mem::transmute(&GenericParam { t: 1u32 });
243    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam<u32> as *const GenericParam<f32>)`
244
245 error: aborting due to 38 previous errors
246