]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/cast_raw_slice_pointer_cast.fixed
Rollup merge of #102345 - chenyukang:fix-102182-impl-trait, r=estebank
[rust.git] / src / tools / clippy / tests / ui / cast_raw_slice_pointer_cast.fixed
1 // run-rustfix
2 #![warn(clippy::cast_slice_from_raw_parts)]
3
4 #[allow(unused_imports, unused_unsafe)]
5 fn main() {
6     let mut vec = vec![0u8; 1];
7     let ptr: *const u8 = vec.as_ptr();
8     let mptr = vec.as_mut_ptr();
9     let _: *const [u8] = unsafe { core::ptr::slice_from_raw_parts(ptr, 1) };
10     let _: *const [u8] = unsafe { core::ptr::slice_from_raw_parts_mut(mptr, 1) };
11     let _: *const [u8] = core::ptr::slice_from_raw_parts(ptr, 1);
12     {
13         use core::slice;
14         let _: *const [u8] = core::ptr::slice_from_raw_parts(ptr, 1);
15         use slice as one;
16         let _: *const [u8] = core::ptr::slice_from_raw_parts(ptr, 1);
17     }
18     {
19         use std::slice;
20         let _: *const [u8] = core::ptr::slice_from_raw_parts(ptr, 1);
21         use slice as one;
22         let _: *const [u8] = core::ptr::slice_from_raw_parts(ptr, 1);
23     }
24 }