summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/pid.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /vendor/rustix/src/pid.rs
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/pid.rs')
-rw-r--r--vendor/rustix/src/pid.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/vendor/rustix/src/pid.rs b/vendor/rustix/src/pid.rs
index bebc1f00c..1b1da6521 100644
--- a/vendor/rustix/src/pid.rs
+++ b/vendor/rustix/src/pid.rs
@@ -86,8 +86,18 @@ impl Pid {
#[test]
fn test_sizes() {
- use core::mem::size_of;
+ use core::mem::transmute;
- assert_eq!(size_of::<RawPid>(), size_of::<NonZeroI32>());
- assert_eq!(size_of::<RawPid>(), size_of::<Pid>());
+ assert_eq_size!(RawPid, NonZeroI32);
+ assert_eq_size!(RawPid, Pid);
+ assert_eq_size!(RawPid, Option<Pid>);
+
+ // Rustix doesn't depend on `Option<Pid>` matching the ABI of a raw integer
+ // for correctness, but it should work nonetheless.
+ const_assert_eq!(0 as RawPid, unsafe {
+ transmute::<Option<Pid>, RawPid>(None)
+ });
+ const_assert_eq!(4567 as RawPid, unsafe {
+ transmute::<Option<Pid>, RawPid>(Some(Pid::from_raw_unchecked(4567)))
+ });
}