Skip to content

Commit 0a84008

Browse files
authored
[tests] add transmute! UI tests (#456)
These tests are split into distinct files, so that changes to `transmute!` can be more easily carefully and incrementally reviewed.
1 parent 1ed57ef commit 0a84008

36 files changed

+293
-46
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ jobs:
162162
--package ${{ matrix.crate }} \
163163
--target ${{ matrix.target }} \
164164
${{ matrix.features }} \
165-
--verbose
165+
--verbose \
166+
-- \
167+
${{ (matrix.features == '--no-default-features' || matrix.features == '') && '--skip ui' || '' }} \
168+
166169
# Only run tests when targetting x86 (32- or 64-bit) - we're executing on
167170
# x86_64, so we can't run tests for any non-x86 target.
168171
#
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../ui-nightly/transmute-dst-not-frombytes.rs
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied
2+
--> tests/ui-msrv/transmute-dst-not-frombytes.rs:14:41
3+
|
4+
14 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0));
5+
| ^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy`
6+
|
7+
note: required by a bound in `DST_NOT_FROM_BYTES::transmute`
8+
--> tests/ui-msrv/transmute-dst-not-frombytes.rs:14:41
9+
|
10+
14 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0));
11+
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `DST_NOT_FROM_BYTES::transmute`
12+
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)

tests/ui-msrv/transmute-illegal.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/ui-msrv/transmute-illegal.stderr

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../ui-nightly/transmute-ptr-to-usize.rs
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied
2+
--> tests/ui-msrv/transmute-ptr-to-usize.rs:16:30
3+
|
4+
16 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize`
6+
|
7+
= help: the following implementations were found:
8+
<usize as AsBytes>
9+
<f32 as AsBytes>
10+
<f64 as AsBytes>
11+
<i128 as AsBytes>
12+
and $N others
13+
note: required by a bound in `POINTER_VALUE::transmute`
14+
--> tests/ui-msrv/transmute-ptr-to-usize.rs:16:30
15+
|
16+
16 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `POINTER_VALUE::transmute`
18+
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../ui-nightly/transmute-size-decrease.rs
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
2+
--> tests/ui-msrv/transmute-size-decrease.rs:15:27
3+
|
4+
15 | const DECREASE_SIZE: u8 = transmute!(AU16(0));
5+
| ^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: source type: `AU16` (16 bits)
8+
= note: target type: `u8` (8 bits)
9+
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../ui-nightly/transmute-size-increase.rs

0 commit comments

Comments
 (0)