forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#81479 - osa1:issue24151, r=lcnr
Allow casting mut array ref to mut ptr Allow casting mut array ref to mut ptr We now allow two new casts: - mut array reference to mut ptr. Example: let mut x: [usize; 2] = [0, 0]; let p = &mut x as *mut usize; We allow casting const array references to const pointers so not allowing mut references to mut pointers was inconsistent. - mut array reference to const ptr. Example: let mut x: [usize; 2] = [0, 0]; let p = &mut x as *const usize; This was similarly inconsistent as we allow casting mut references to const pointers. Existing test 'vector-cast-weirdness' updated to test both cases. Fixes rust-lang#24151
- Loading branch information
Showing
4 changed files
with
55 additions
and
25 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,9 +1,21 @@ | ||
error[E0606]: casting `&mut [u8; 2]` as `*mut u8` is invalid | ||
--> $DIR/vector-cast-weirdness.rs:21:23 | ||
error[E0606]: casting `&[u8; 2]` as `*mut u8` is invalid | ||
--> $DIR/vector-cast-weirdness.rs:19:23 | ||
| | ||
LL | let p1: *mut u8 = &mut x1.y as *mut _; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | let p1: *mut u8 = &x1.y as *mut _; | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
error[E0606]: casting `&[u8; 2]` as `*mut [u8; 2]` is invalid | ||
--> $DIR/vector-cast-weirdness.rs:22:28 | ||
| | ||
LL | let t1: *mut [u8; 2] = &x1.y as *mut _; | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error[E0606]: casting `&[u8; 2]` as `*mut [u8; 2]` is invalid | ||
--> $DIR/vector-cast-weirdness.rs:25:28 | ||
| | ||
LL | let t1: *mut [u8; 2] = &x1.y as *mut [u8; 2]; | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0606`. |