Skip to content

Commit faab5ff

Browse files
author
Tamir Duberstein
committed
Suppress time_t musl "deprecation"
See rust-lang/libc#1848 in which this type is changing from i32 to i64; the change is being announced via this deprecation.
1 parent 1da3c3b commit faab5ff

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/sys/time.rs

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::{cmp, fmt, ops};
22
use std::time::Duration;
33
use std::convert::From;
44
use libc::{c_long, timespec, timeval};
5+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
56
pub use libc::{time_t, suseconds_t};
67

78
pub trait TimeValLike: Sized {
@@ -70,6 +71,7 @@ impl From<timespec> for TimeSpec {
7071
impl From<Duration> for TimeSpec {
7172
fn from(duration: Duration) -> Self {
7273
TimeSpec(timespec {
74+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
7375
tv_sec: duration.as_secs() as time_t,
7476
tv_nsec: duration.subsec_nanos() as c_long
7577
})
@@ -117,6 +119,7 @@ impl TimeValLike for TimeSpec {
117119
fn seconds(seconds: i64) -> TimeSpec {
118120
assert!(seconds >= TS_MIN_SECONDS && seconds <= TS_MAX_SECONDS,
119121
"TimeSpec out of bounds; seconds={}", seconds);
122+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
120123
TimeSpec(timespec {tv_sec: seconds as time_t, tv_nsec: 0 })
121124
}
122125

@@ -143,6 +146,7 @@ impl TimeValLike for TimeSpec {
143146
let (secs, nanos) = div_mod_floor_64(nanoseconds, NANOS_PER_SEC);
144147
assert!(secs >= TS_MIN_SECONDS && secs <= TS_MAX_SECONDS,
145148
"TimeSpec out of bounds");
149+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
146150
TimeSpec(timespec {tv_sec: secs as time_t,
147151
tv_nsec: nanos as c_long })
148152
}
@@ -179,6 +183,7 @@ impl TimeSpec {
179183
}
180184
}
181185

186+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
182187
pub fn tv_sec(&self) -> time_t {
183188
self.0.tv_sec
184189
}
@@ -315,6 +320,7 @@ impl TimeValLike for TimeVal {
315320
fn seconds(seconds: i64) -> TimeVal {
316321
assert!(seconds >= TV_MIN_SECONDS && seconds <= TV_MAX_SECONDS,
317322
"TimeVal out of bounds; seconds={}", seconds);
323+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
318324
TimeVal(timeval {tv_sec: seconds as time_t, tv_usec: 0 })
319325
}
320326

@@ -332,6 +338,7 @@ impl TimeValLike for TimeVal {
332338
let (secs, micros) = div_mod_floor_64(microseconds, MICROS_PER_SEC);
333339
assert!(secs >= TV_MIN_SECONDS && secs <= TV_MAX_SECONDS,
334340
"TimeVal out of bounds");
341+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
335342
TimeVal(timeval {tv_sec: secs as time_t,
336343
tv_usec: micros as suseconds_t })
337344
}
@@ -344,6 +351,7 @@ impl TimeValLike for TimeVal {
344351
let (secs, micros) = div_mod_floor_64(microseconds, MICROS_PER_SEC);
345352
assert!(secs >= TV_MIN_SECONDS && secs <= TV_MAX_SECONDS,
346353
"TimeVal out of bounds");
354+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
347355
TimeVal(timeval {tv_sec: secs as time_t,
348356
tv_usec: micros as suseconds_t })
349357
}
@@ -380,6 +388,7 @@ impl TimeVal {
380388
}
381389
}
382390

391+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
383392
pub fn tv_sec(&self) -> time_t {
384393
self.0.tv_sec
385394
}

0 commit comments

Comments
 (0)