From 2dffd54014b4abe06de564bb4f612cc95108095f Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Sat, 28 Jun 2025 00:14:08 +0000 Subject: [PATCH] unix: make `struct timespec` non-exhaustive. time64 changes on both GNU and Musl libcs add padding fields to timespec. This can cause compilation failures when using time64 when regular 64-bit compiles fine. Add non_exhaustive to force people to use e.g. `..Default::default()` when initializing to prevent this when the target changes. --- src/unix/linux_like/linux/gnu/mod.rs | 1 + src/unix/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 06c6fe6714d35..736272ea70791 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -338,6 +338,7 @@ s! { // linux x32 compatibility // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 + #[non_exhaustive] pub struct timespec { pub tv_sec: time_t, #[cfg(all(gnu_time_bits64, target_endian = "big"))] diff --git a/src/unix/mod.rs b/src/unix/mod.rs index c9415554b2c1b..8093a04cb91ba 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -68,6 +68,7 @@ s! { // linux x32 compatibility // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 + #[non_exhaustive] #[cfg(not(target_env = "gnu"))] pub struct timespec { pub tv_sec: time_t,