1 #![warn(clippy::cast_ref_to_mut)]
2 #![allow(clippy::no_effect)]
5 // N.B., mutability can be easily incorrect in FFI calls -- as
6 // in C, the default is mutable pointers.
8 fn int_ffi(c: *mut i32);
12 let s = String::from("Hello");
16 let mut_num = &mut 3i32;
17 // Should be warned against
18 (*(a as *const _ as *mut String)).push_str(" world");
19 *(a as *const _ as *mut _) = String::from("Replaced");
20 *(a as *const _ as *mut String) += " world";
21 // Shouldn't be warned against
22 println!("{}", *(num as *const _ as *const i16));
23 println!("{}", *(mut_num as *mut _ as *mut i16));
24 ffi(a.as_ptr() as *mut _);
25 int_ffi(num as *const _ as *mut _);
26 int_ffi(&3 as *const _ as *mut _);
28 let value: *const i32 = &mut value;
29 *(value as *const i16 as *mut i16) = 42;