-
Notifications
You must be signed in to change notification settings - Fork 108
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
Replace transmute!
macro with transmute
fn
#190
Draft
jswrenn
wants to merge
1
commit into
more-transmute-ui-tests
Choose a base branch
from
transmute-fn
base: more-transmute-ui-tests
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
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 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,22 +1,5 @@ | ||
error[E0277]: the trait bound `NotZerocopy<AU16>: FromBytes` is not satisfied | ||
--> tests/ui-msrv/transmute-bound-dst-not-frombytes.rs:9:47 | ||
error[E0433]: failed to resolve: could not find `transmute` in `zerocopy` | ||
--> tests/ui-msrv/transmute-bound-dst-not-frombytes.rs:9:57 | ||
| | ||
9 | const DST_NOT_FROM_BYTES: NotZerocopy<AU16> = zerocopy::transmute!(AU16(0)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy<AU16>` | ||
| | ||
= help: the following other types implement trait `FromBytes`: | ||
() | ||
AU16 | ||
F32<O> | ||
F64<O> | ||
I128<O> | ||
I16<O> | ||
I32<O> | ||
I64<O> | ||
and $N others | ||
note: required by a bound in `DST_NOT_FROM_BYTES::transmute` | ||
--> tests/ui-msrv/transmute-bound-dst-not-frombytes.rs:9:47 | ||
| | ||
9 | const DST_NOT_FROM_BYTES: NotZerocopy<AU16> = zerocopy::transmute!(AU16(0)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `DST_NOT_FROM_BYTES::transmute` | ||
= note: this error originates in the macro `zerocopy::transmute` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
| ^^^^^^^^^ could not find `transmute` in `zerocopy` |
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,26 @@ | ||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> tests/ui-msrv/transmute-size-decrease.rs:7:32 | ||
error[E0080]: evaluation of `<[u8; 1] as zerocopy::TransmuteFrom<[u8; 2]>>::IS_TRANSMUTABLE` failed | ||
--> src/lib.rs | ||
| | ||
7 | const SIZE_DECREASE: [u8; 1] = zerocopy::transmute!([0u8; 2]); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| assert!(mem::size_of::<Src>() == mem::size_of::<Dst>()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: mem::size_of::<Src>() == mem::size_of::<Dst>()', $DIR/src/lib.rs:1427:9 | ||
| | ||
= note: source type: `[u8; 2]` (16 bits) | ||
= note: target type: `[u8; 1]` (8 bits) | ||
= note: this error originates in the macro `zerocopy::transmute` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: any use of this value will cause an error | ||
--> src/lib.rs | ||
| | ||
| assert!(<Dst as TransmuteFrom<Src>>::IS_TRANSMUTABLE); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| referenced constant has errors | ||
| inside `zerocopy::transmute::<[u8; 2], [u8; 1]>` at $DIR/src/lib.rs:1452:13 | ||
| inside `SIZE_DECREASE` at $DIR/tests/ui-msrv/transmute-size-decrease.rs:7:32 | ||
| | ||
::: tests/ui-msrv/transmute-size-decrease.rs:7:1 | ||
| | ||
7 | const SIZE_DECREASE: [u8; 1] = zerocopy::transmute([0u8; 2]); | ||
| ---------------------------- | ||
| | ||
= note: `#[deny(const_err)]` on by default | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> |
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,26 @@ | ||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> tests/ui-msrv/transmute-size-increase.rs:7:32 | ||
error[E0080]: evaluation of `<[u8; 2] as zerocopy::TransmuteFrom<[u8; 1]>>::IS_TRANSMUTABLE` failed | ||
--> src/lib.rs | ||
| | ||
7 | const SIZE_INCREASE: [u8; 2] = zerocopy::transmute!([0u8; 1]); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| assert!(mem::size_of::<Src>() == mem::size_of::<Dst>()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: mem::size_of::<Src>() == mem::size_of::<Dst>()', $DIR/src/lib.rs:1427:9 | ||
| | ||
= note: source type: `[u8; 1]` (8 bits) | ||
= note: target type: `[u8; 2]` (16 bits) | ||
= note: this error originates in the macro `zerocopy::transmute` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: any use of this value will cause an error | ||
--> src/lib.rs | ||
| | ||
| assert!(<Dst as TransmuteFrom<Src>>::IS_TRANSMUTABLE); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| referenced constant has errors | ||
| inside `zerocopy::transmute::<[u8; 1], [u8; 2]>` at $DIR/src/lib.rs:1452:13 | ||
| inside `SIZE_INCREASE` at $DIR/tests/ui-msrv/transmute-size-increase.rs:7:32 | ||
| | ||
::: tests/ui-msrv/transmute-size-increase.rs:7:1 | ||
| | ||
7 | const SIZE_INCREASE: [u8; 2] = zerocopy::transmute([0u8; 1]); | ||
| ---------------------------- | ||
| | ||
= note: `#[deny(const_err)]` on by default | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> |
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,22 +1,11 @@ | ||
error[E0277]: the trait bound `NotZerocopy<AU16>: FromBytes` is not satisfied | ||
--> tests/ui-nightly/transmute-bound-dst-not-frombytes.rs:9:47 | ||
error[E0433]: failed to resolve: could not find `transmute` in `zerocopy` | ||
--> tests/ui-nightly/transmute-bound-dst-not-frombytes.rs:9:57 | ||
| | ||
9 | const DST_NOT_FROM_BYTES: NotZerocopy<AU16> = zerocopy::transmute!(AU16(0)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy<AU16>` | ||
| ^^^^^^^^^ could not find `transmute` in `zerocopy` | ||
| | ||
= help: the following other types implement trait `FromBytes`: | ||
() | ||
AU16 | ||
F32<O> | ||
F64<O> | ||
I128<O> | ||
I16<O> | ||
I32<O> | ||
I64<O> | ||
and $N others | ||
note: required by a bound in `DST_NOT_FROM_BYTES::transmute` | ||
--> tests/ui-nightly/transmute-bound-dst-not-frombytes.rs:9:47 | ||
help: zerocopy::transmute is not a macro, but a function, try to remove `!` | ||
| | ||
9 - const DST_NOT_FROM_BYTES: NotZerocopy<AU16> = zerocopy::transmute!(AU16(0)); | ||
9 + const DST_NOT_FROM_BYTES: NotZerocopy<AU16> = zerocopy::transmute(AU16(0)); | ||
| | ||
9 | const DST_NOT_FROM_BYTES: NotZerocopy<AU16> = zerocopy::transmute!(AU16(0)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `transmute` | ||
= note: this error originates in the macro `zerocopy::transmute` (in Nightly builds, run with -Z macro-backtrace for more info) |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This trait does not need to be (and shouldn't be)
pub
, because it has a blanket implementation onT: Sized
thattransmute
can use without declaring it in itswhere
bounds.