2020-08-03 03:47:25 -05:00
|
|
|
error: transmute from an integer to a pointer
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/transmutes_expressible_as_ptr_casts.rs:17:39
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
2020-08-11 08:43:21 -05:00
|
|
|
LL | let _ptr_i32_transmute = unsafe { transmute::<usize, *const i32>(usize::MAX) };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `usize::MAX as *const i32`
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
|
|
|
= note: `-D clippy::useless-transmute` implied by `-D warnings`
|
2023-08-01 07:02:21 -05:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::useless_transmute)]`
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
|
|
error: transmute from a pointer to a pointer
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/transmutes_expressible_as_ptr_casts.rs:21:38
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
2020-08-11 08:43:21 -05:00
|
|
|
LL | let _ptr_i8_transmute = unsafe { transmute::<*const i32, *const i8>(ptr_i32) };
|
2024-07-25 11:29:17 -05:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
|
|
|
= note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings`
|
2023-08-01 07:02:21 -05:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::transmute_ptr_to_ptr)]`
|
2024-07-25 11:29:17 -05:00
|
|
|
help: use `pointer::cast` instead
|
|
|
|
|
|
|
|
|
LL | let _ptr_i8_transmute = unsafe { ptr_i32.cast::<i8>() };
|
|
|
|
| ~~~~~~~~~~~~~~~~~~~~
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
|
|
error: transmute from a pointer to a pointer
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/transmutes_expressible_as_ptr_casts.rs:27:46
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
2022-03-14 06:02:53 -05:00
|
|
|
LL | let _ptr_to_unsized_transmute = unsafe { transmute::<*const [i32], *const [u32]>(slice_ptr) };
|
2024-07-25 11:29:17 -05:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
help: use an `as` cast instead
|
|
|
|
|
|
|
|
|
LL | let _ptr_to_unsized_transmute = unsafe { slice_ptr as *const [u32] };
|
|
|
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
|
|
error: transmute from `*const i32` to `usize` which could be expressed as a pointer cast instead
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/transmutes_expressible_as_ptr_casts.rs:33:50
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
2020-08-11 08:43:21 -05:00
|
|
|
LL | let _usize_from_int_ptr_transmute = unsafe { transmute::<*const i32, usize>(ptr_i32) };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr_i32 as usize`
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
|
|
|
= note: `-D clippy::transmutes-expressible-as-ptr-casts` implied by `-D warnings`
|
2023-08-01 07:02:21 -05:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::transmutes_expressible_as_ptr_casts)]`
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
|
|
error: transmute from a reference to a pointer
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/transmutes_expressible_as_ptr_casts.rs:39:41
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
2020-08-11 08:43:21 -05:00
|
|
|
LL | let _array_ptr_transmute = unsafe { transmute::<&[i32; 4], *const [i32; 4]>(array_ref) };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `array_ref as *const [i32; 4]`
|
2020-08-03 03:47:25 -05:00
|
|
|
|
2022-03-24 08:50:04 -05:00
|
|
|
error: transmute from `fn(usize) -> u8` to `*const usize` which could be expressed as a pointer cast instead
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/transmutes_expressible_as_ptr_casts.rs:47:41
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
2020-08-11 08:43:21 -05:00
|
|
|
LL | let _usize_ptr_transmute = unsafe { transmute::<fn(usize) -> u8, *const usize>(foo) };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `foo as *const usize`
|
2020-08-03 03:47:25 -05:00
|
|
|
|
2022-03-24 08:50:04 -05:00
|
|
|
error: transmute from `fn(usize) -> u8` to `usize` which could be expressed as a pointer cast instead
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/transmutes_expressible_as_ptr_casts.rs:51:49
|
2020-08-03 03:47:25 -05:00
|
|
|
|
|
2020-08-11 08:43:21 -05:00
|
|
|
LL | let _usize_from_fn_ptr_transmute = unsafe { transmute::<fn(usize) -> u8, usize>(foo) };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `foo as usize`
|
2020-08-03 03:47:25 -05:00
|
|
|
|
2023-01-27 14:09:08 -06:00
|
|
|
error: transmute from `*const u32` to `usize` which could be expressed as a pointer cast instead
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/transmutes_expressible_as_ptr_casts.rs:54:36
|
2023-01-27 14:09:08 -06:00
|
|
|
|
|
|
|
|
LL | let _usize_from_ref = unsafe { transmute::<*const u32, usize>(&1u32) };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&1u32 as *const u32 as usize`
|
|
|
|
|
2020-08-05 22:28:22 -05:00
|
|
|
error: transmute from a reference to a pointer
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/transmutes_expressible_as_ptr_casts.rs:65:14
|
2020-08-05 22:28:22 -05:00
|
|
|
|
|
|
|
|
LL | unsafe { transmute::<&[i32; 1], *const u8>(in_param) }
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `in_param as *const [i32; 1] as *const u8`
|
|
|
|
|
2023-04-11 08:31:08 -05:00
|
|
|
error: transmute from `fn()` to `*const u8` which could be expressed as a pointer cast instead
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/transmutes_expressible_as_ptr_casts.rs:83:28
|
2023-04-11 08:31:08 -05:00
|
|
|
|
|
|
|
|
LL | let _x: u8 = unsafe { *std::mem::transmute::<fn(), *const u8>(f) };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(f as *const u8)`
|
|
|
|
|
|
|
|
error: aborting due to 10 previous errors
|
2020-08-03 03:47:25 -05:00
|
|
|
|