forked from google/zerocopy
-
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.
Add
transmute_mut!
macro (google#550)
This macro is like the existing `transmute!`, but it transmutes mutable references rather than values. Releasing 0.7.17 Issue google#159
- Loading branch information
Showing
154 changed files
with
2,908 additions
and
404 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
../ui-nightly/transmute-mut-alignment-increase.rs |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> tests/ui-msrv/transmute-mut-alignment-increase.rs:19:39 | ||
| | ||
19 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `AlignOf<[u8; 2]>` (8 bits) | ||
= note: target type: `MaxAlignsOf<[u8; 2], AU16>` (16 bits) | ||
= note: this error originates in the macro `$crate::assert_align_gt_eq` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0658]: mutable references are not allowed in constants | ||
--> tests/ui-msrv/transmute-mut-alignment-increase.rs:19:54 | ||
| | ||
19 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information | ||
|
||
error[E0015]: cannot call non-const fn `INCREASE_ALIGNMENT::transmute::<[u8; 2], AU16>` in constants | ||
--> tests/ui-msrv/transmute-mut-alignment-increase.rs:19:39 | ||
| | ||
19 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0716]: temporary value dropped while borrowed | ||
--> tests/ui-msrv/transmute-mut-alignment-increase.rs:19:59 | ||
| | ||
19 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); | ||
| --------------------^^^^^^^^- | ||
| | | | ||
| | creates a temporary which is freed while still in use | ||
| temporary value is freed at the end of this statement | ||
| using this value as a constant requires that borrow lasts for `'static` |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
../ui-nightly/transmute-mut-const.rs |
Oops, something went wrong.