-
Notifications
You must be signed in to change notification settings - Fork 114
Add transmute_mut!
macro
#550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
[package] | ||
edition = "2021" | ||
name = "zerocopy" | ||
version = "0.7.16" | ||
version = "0.7.17" | ||
authors = ["Joshua Liebow-Feeser <[email protected]>"] | ||
description = "Utilities for zero-copy parsing and serialization" | ||
license = "BSD-2-Clause OR Apache-2.0 OR MIT" | ||
|
@@ -45,7 +45,7 @@ simd-nightly = ["simd"] | |
__internal_use_only_features_that_work_on_stable = ["alloc", "derive", "simd"] | ||
|
||
[dependencies] | ||
zerocopy-derive = { version = "=0.7.16", path = "zerocopy-derive", optional = true } | ||
zerocopy-derive = { version = "=0.7.17", path = "zerocopy-derive", optional = true } | ||
|
||
[dependencies.byteorder] | ||
version = "1.3" | ||
|
@@ -56,7 +56,7 @@ optional = true | |
# zerocopy-derive remain equal, even if the 'derive' feature isn't used. | ||
# See: https://github.com/matklad/macro-dep-test | ||
[target.'cfg(any())'.dependencies] | ||
zerocopy-derive = { version = "=0.7.16", path = "zerocopy-derive" } | ||
zerocopy-derive = { version = "=0.7.17", path = "zerocopy-derive" } | ||
|
||
[dev-dependencies] | ||
assert_matches = "1.5" | ||
|
@@ -71,4 +71,4 @@ testutil = { path = "testutil" } | |
# CI test failures. | ||
trybuild = { version = "=1.0.85", features = ["diff"] } | ||
# In tests, unlike in production, zerocopy-derive is not optional | ||
zerocopy-derive = { version = "=0.7.16", path = "zerocopy-derive" } | ||
zerocopy-derive = { version = "=0.7.17", path = "zerocopy-derive" } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.