mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 17:07:17 +00:00
4b478a5731
which checks for `as` casts between raw pointers without changing its mutability and suggest replacing it with `pointer::cast`.
34 lines
1.4 KiB
Text
34 lines
1.4 KiB
Text
error: `as` casting between raw pointers without changing its mutability
|
|
--> $DIR/ptr_as_ptr.rs:9:13
|
|
|
|
|
LL | let _ = ptr as *const i32;
|
|
| ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::<i32>()`
|
|
|
|
|
= note: `-D clippy::ptr-as-ptr` implied by `-D warnings`
|
|
|
|
error: `as` casting between raw pointers without changing its mutability
|
|
--> $DIR/ptr_as_ptr.rs:10:13
|
|
|
|
|
LL | let _ = mut_ptr as *mut i32;
|
|
| ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::<i32>()`
|
|
|
|
error: `as` casting between raw pointers without changing its mutability
|
|
--> $DIR/ptr_as_ptr.rs:15:17
|
|
|
|
|
LL | let _ = *ptr_ptr as *const i32;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `(*ptr_ptr).cast::<i32>()`
|
|
|
|
error: `as` casting between raw pointers without changing its mutability
|
|
--> $DIR/ptr_as_ptr.rs:28:25
|
|
|
|
|
LL | let _: *const i32 = ptr as *const _;
|
|
| ^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast()`
|
|
|
|
error: `as` casting between raw pointers without changing its mutability
|
|
--> $DIR/ptr_as_ptr.rs:29:23
|
|
|
|
|
LL | let _: *mut i32 = mut_ptr as _;
|
|
| ^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast()`
|
|
|
|
error: aborting due to 5 previous errors
|
|
|