diff options
Diffstat (limited to 'src/tools/clippy/tests/ui/ptr_cast_constness.fixed')
| -rw-r--r-- | src/tools/clippy/tests/ui/ptr_cast_constness.fixed | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/ptr_cast_constness.fixed b/src/tools/clippy/tests/ui/ptr_cast_constness.fixed index 9a5272c7adc..6dded72d3e1 100644 --- a/src/tools/clippy/tests/ui/ptr_cast_constness.fixed +++ b/src/tools/clippy/tests/ui/ptr_cast_constness.fixed @@ -13,7 +13,9 @@ use proc_macros::{external, inline_macros}; unsafe fn ptr_to_ref<T, U>(p: *const T, om: *mut U) { let _: &mut T = std::mem::transmute(p.cast_mut()); + //~^ ptr_cast_constness let _ = &mut *p.cast_mut(); + //~^ ptr_cast_constness let _: &T = &*(om as *const T); } @@ -29,10 +31,13 @@ fn main() { unsafe { let ptr_ptr: *const *const u32 = &ptr; let _ = (*ptr_ptr).cast_mut(); + //~^ ptr_cast_constness } let _ = ptr.cast_mut(); + //~^ ptr_cast_constness let _ = mut_ptr.cast_const(); + //~^ ptr_cast_constness // Lint this, since pointer::cast_mut and pointer::cast_const have ?Sized let ptr_of_array: *const [u32; 4] = &[1, 2, 3, 4]; @@ -66,20 +71,28 @@ fn _msrv_1_65() { let mut_ptr: *mut u32 = &mut 42_u32; let _ = ptr.cast_mut(); + //~^ ptr_cast_constness let _ = mut_ptr.cast_const(); + //~^ ptr_cast_constness } #[inline_macros] fn null_pointers() { use std::ptr; let _ = std::ptr::null_mut::<String>(); + //~^ ptr_cast_constness let _ = std::ptr::null::<u32>(); + //~^ ptr_cast_constness let _ = std::ptr::null_mut::<u32>(); + //~^ ptr_cast_constness let _ = std::ptr::null::<u32>(); + //~^ ptr_cast_constness // Make sure the lint is triggered inside a macro let _ = inline!(std::ptr::null_mut::<u32>()); + //~^ ptr_cast_constness let _ = inline!(std::ptr::null_mut::<u32>()); + //~^ ptr_cast_constness // Do not lint inside macros from external crates let _ = external!(ptr::null::<u32>() as *mut u32); |
