Skip to content

Commit bfa3090

Browse files
committed
Update hdf5-derive tests re: #[repr(transparent)]
1 parent 5c6255e commit bfa3090

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

hdf5-derive/tests/compile-fail/struct-no-repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use hdf5_derive::H5Type;
33

44
#[derive(H5Type)]
55
//~^ ERROR proc-macro derive
6-
//~^^ HELP H5Type requires #[repr(C)] or #[repr(packed)] for structs
6+
//~^^ HELP H5Type requires repr(C), repr(packed) or repr(transparent) for structs
77
struct Foo {
88
bar: i64,
99
}

hdf5-derive/tests/compile-fail/struct-no-repr.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ error: proc-macro derive panicked
44
4 | #[derive(H5Type)]
55
| ^^^^^^
66
|
7-
= help: message: H5Type requires #[repr(C)] or #[repr(packed)] for structs
7+
= help: message: H5Type requires repr(C), repr(packed) or repr(transparent) for structs

hdf5-derive/tests/compile-fail/tuple-struct-no-repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use hdf5_derive::H5Type;
33

44
#[derive(H5Type)]
55
//~^ ERROR proc-macro derive
6-
//~^^ HELP H5Type requires #[repr(C)] or #[repr(packed)] for structs
6+
//~^^ HELP H5Type requires repr(C), repr(packed) or repr(transparent) for tuple structs
77
struct Foo(i64);
88

99
fn main() {}

hdf5-derive/tests/compile-fail/tuple-struct-no-repr.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ error: proc-macro derive panicked
44
4 | #[derive(H5Type)]
55
| ^^^^^^
66
|
7-
= help: message: H5Type requires #[repr(C)] or #[repr(packed)] for structs
7+
= help: message: H5Type requires repr(C), repr(packed) or repr(transparent) for tuple structs

hdf5-derive/tests/test.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ struct P1 {
4444
#[repr(packed)]
4545
struct P2(i8, u32);
4646

47+
#[derive(H5Type)]
48+
#[repr(transparent)]
49+
struct T1 {
50+
_x: u64,
51+
}
52+
53+
#[derive(H5Type)]
54+
#[repr(transparent)]
55+
struct T2(i32);
56+
4757
#[test]
4858
fn test_compound_packed() {
4959
assert_eq!(
@@ -68,6 +78,12 @@ fn test_compound_packed() {
6878
);
6979
}
7080

81+
#[test]
82+
fn test_compound_transparent() {
83+
assert_eq!(T1::type_descriptor(), u64::type_descriptor(),);
84+
assert_eq!(T2::type_descriptor(), i32::type_descriptor(),);
85+
}
86+
7187
#[test]
7288
fn test_compound_simple() {
7389
assert_eq!(

0 commit comments

Comments
 (0)