]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/swap_ptr_to_ref.fixed
Rollup merge of #102345 - chenyukang:fix-102182-impl-trait, r=estebank
[rust.git] / src / tools / clippy / tests / ui / swap_ptr_to_ref.fixed
1 // run-rustfix
2
3 #![warn(clippy::swap_ptr_to_ref)]
4
5 use core::ptr::addr_of_mut;
6
7 fn main() {
8     let mut x = 0u32;
9     let y: *mut _ = &mut x;
10     let z: *mut _ = &mut x;
11
12     unsafe {
13         core::ptr::swap(y, z);
14         core::ptr::swap(y, &mut x);
15         core::ptr::swap(&mut x, y);
16         core::ptr::swap(addr_of_mut!(x), addr_of_mut!(x));
17     }
18
19     let y = &mut x;
20     let mut z = 0u32;
21     let z = &mut z;
22
23     core::mem::swap(y, z);
24 }