-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #10879 - Centri3:ptr_cast_constness, r=blyxyas,xFrednet
[`ptr_cast_constness`]: Only lint on casts which don't change type fixes #10874 changelog: [`ptr_cast_constness`]: Only lint on casts which don't change type
- Loading branch information
Showing
4 changed files
with
67 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,46 @@ | ||
error: `as` casting between raw pointers while changing its constness | ||
--> $DIR/ptr_cast_constness.rs:20:17 | ||
error: `as` casting between raw pointers while changing only its constness | ||
--> $DIR/ptr_cast_constness.rs:11:41 | ||
| | ||
LL | let _ = *ptr_ptr as *mut i32; | ||
| ^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `(*ptr_ptr).cast_mut()` | ||
LL | let _: &mut T = std::mem::transmute(p as *mut T); | ||
| ^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `p.cast_mut()` | ||
| | ||
= note: `-D clippy::ptr-cast-constness` implied by `-D warnings` | ||
|
||
error: `as` casting between raw pointers while changing its constness | ||
--> $DIR/ptr_cast_constness.rs:23:13 | ||
error: `as` casting between raw pointers while changing only its constness | ||
--> $DIR/ptr_cast_constness.rs:12:19 | ||
| | ||
LL | let _ = &mut *(p as *mut T); | ||
| ^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `p.cast_mut()` | ||
|
||
error: `as` casting between raw pointers while changing only its constness | ||
--> $DIR/ptr_cast_constness.rs:27:17 | ||
| | ||
LL | let _ = *ptr_ptr as *mut u32; | ||
| ^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `(*ptr_ptr).cast_mut()` | ||
|
||
error: `as` casting between raw pointers while changing only its constness | ||
--> $DIR/ptr_cast_constness.rs:30:13 | ||
| | ||
LL | let _ = ptr as *mut i32; | ||
LL | let _ = ptr as *mut u32; | ||
| ^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `ptr.cast_mut()` | ||
|
||
error: `as` casting between raw pointers while changing its constness | ||
--> $DIR/ptr_cast_constness.rs:24:13 | ||
error: `as` casting between raw pointers while changing only its constness | ||
--> $DIR/ptr_cast_constness.rs:31:13 | ||
| | ||
LL | let _ = mut_ptr as *const i32; | ||
LL | let _ = mut_ptr as *const u32; | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_const`, a safer alternative: `mut_ptr.cast_const()` | ||
|
||
error: `as` casting between raw pointers while changing its constness | ||
--> $DIR/ptr_cast_constness.rs:53:13 | ||
error: `as` casting between raw pointers while changing only its constness | ||
--> $DIR/ptr_cast_constness.rs:60:13 | ||
| | ||
LL | let _ = ptr as *mut i32; | ||
LL | let _ = ptr as *mut u32; | ||
| ^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `ptr.cast_mut()` | ||
|
||
error: `as` casting between raw pointers while changing its constness | ||
--> $DIR/ptr_cast_constness.rs:54:13 | ||
error: `as` casting between raw pointers while changing only its constness | ||
--> $DIR/ptr_cast_constness.rs:61:13 | ||
| | ||
LL | let _ = mut_ptr as *const i32; | ||
LL | let _ = mut_ptr as *const u32; | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_const`, a safer alternative: `mut_ptr.cast_const()` | ||
|
||
error: aborting due to 5 previous errors | ||
error: aborting due to 7 previous errors | ||
|