From c5b1f91b7acac755d958ab757f9569557ef7f820 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 12 Dec 2022 16:09:12 -0800 Subject: [PATCH] Fix the custom definition of `Timespec` to implement `Copy`. --- src/backend/libc/time/types.rs | 2 +- tests/time/timespec.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/backend/libc/time/types.rs b/src/backend/libc/time/types.rs index 080f64431..2d17e480c 100644 --- a/src/backend/libc/time/types.rs +++ b/src/backend/libc/time/types.rs @@ -16,7 +16,7 @@ pub type Timespec = c::timespec; any(target_arch = "arm", target_arch = "mips", target_arch = "x86"), target_env = "gnu", ))] -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] #[repr(C)] pub struct Timespec { /// Seconds. diff --git a/tests/time/timespec.rs b/tests/time/timespec.rs index 6d892dcfe..f889204a8 100644 --- a/tests/time/timespec.rs +++ b/tests/time/timespec.rs @@ -6,7 +6,12 @@ fn test_timespec_layout() { let tv_sec: Secs = 0; let tv_nsec: Nsecs = 0; - let _ = Timespec { tv_sec, tv_nsec }; + let x = Timespec { tv_sec, tv_nsec }; + + // Test that `Timespec` implements `Copy` and `Debug`. + let _y = Timespec { tv_sec, tv_nsec }; + let _z = Timespec { tv_sec, tv_nsec }; + dbg!(&x); #[cfg(not(target_os = "redox"))] let _ = Timespec {