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.
Implement
try_transmute!
(google#1018)
Closes google#1013. Makes progress towards #5.
- Loading branch information
Showing
30 changed files
with
611 additions
and
4 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
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/try_transmute-dst-not-tryfrombytes.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,37 @@ | ||
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied | ||
--> tests/ui-msrv/try_transmute-dst-not-tryfrombytes.rs:17:58 | ||
| | ||
17 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy` | ||
| | ||
note: required by a bound in `try_transmute` | ||
--> src/macro_util.rs | ||
| | ||
| Dst: TryFromBytes, | ||
| ^^^^^^^^^^^^ required by this bound in `try_transmute` | ||
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied | ||
--> tests/ui-msrv/try_transmute-dst-not-tryfrombytes.rs:17:33 | ||
| | ||
17 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy` | ||
| | ||
note: required by a bound in `ValidityError` | ||
--> src/error.rs | ||
| | ||
| pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> { | ||
| ^^^^^^^^^^^^ required by this bound in `ValidityError` | ||
|
||
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied | ||
--> tests/ui-msrv/try_transmute-dst-not-tryfrombytes.rs:17:58 | ||
| | ||
17 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy` | ||
| | ||
note: required by a bound in `ValidityError` | ||
--> src/error.rs | ||
| | ||
| pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> { | ||
| ^^^^^^^^^^^^ required by this bound in `ValidityError` | ||
= note: this error originates in the macro `try_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../ui-nightly/try_transmute-size-decrease.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,17 @@ | ||
warning: unused variable: `decrease_size` | ||
--> tests/ui-msrv/try_transmute-size-decrease.rs:19:9 | ||
| | ||
19 | let decrease_size: Result<u8, _> = try_transmute!(AU16(0)); | ||
| ^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_decrease_size` | ||
| | ||
= note: `#[warn(unused_variables)]` on by default | ||
|
||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> tests/ui-msrv/try_transmute-size-decrease.rs:19:40 | ||
| | ||
19 | let decrease_size: Result<u8, _> = try_transmute!(AU16(0)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `AU16` (16 bits) | ||
= note: target type: `u8` (8 bits) | ||
= note: this error originates in the macro `try_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../ui-nightly/try_transmute-size-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,17 @@ | ||
warning: unused variable: `increase_size` | ||
--> tests/ui-msrv/try_transmute-size-increase.rs:19:9 | ||
| | ||
19 | let increase_size: Result<AU16, _> = try_transmute!(0u8); | ||
| ^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_increase_size` | ||
| | ||
= note: `#[warn(unused_variables)]` on by default | ||
|
||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> tests/ui-msrv/try_transmute-size-increase.rs:19:42 | ||
| | ||
19 | let increase_size: Result<AU16, _> = try_transmute!(0u8); | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `u8` (8 bits) | ||
= note: target type: `AU16` (16 bits) | ||
= note: this error originates in the macro `try_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../ui-nightly/try_transmute-src-not-intobytes.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,12 @@ | ||
error[E0277]: the trait bound `NotZerocopy<AU16>: zerocopy::IntoBytes` is not satisfied | ||
--> tests/ui-msrv/try_transmute-src-not-intobytes.rs:18:47 | ||
| | ||
18 | let src_not_into_bytes: Result<AU16, _> = try_transmute!(NotZerocopy(AU16(0))); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::IntoBytes` is not implemented for `NotZerocopy<AU16>` | ||
| | ||
note: required by a bound in `try_transmute` | ||
--> src/macro_util.rs | ||
| | ||
| Src: IntoBytes, | ||
| ^^^^^^^^^ required by this bound in `try_transmute` | ||
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info) |
Oops, something went wrong.