From 6a6487f4c58731fe578f97d2a4b9c11c5dee28dc Mon Sep 17 00:00:00 2001 From: Julian Eager Date: Fri, 22 Dec 2023 14:43:28 +0800 Subject: [PATCH] set msrv to 1.63 --- latches/Cargo.toml | 1 + latches/build.rs | 43 ---------------------------------------- latches/src/lock/stds.rs | 14 ------------- latches/src/sync/mod.rs | 12 ----------- latches/src/task/mod.rs | 11 ---------- 5 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 latches/build.rs diff --git a/latches/Cargo.toml b/latches/Cargo.toml index d2afb7e..aa467f3 100644 --- a/latches/Cargo.toml +++ b/latches/Cargo.toml @@ -8,6 +8,7 @@ repository = "https://github.com/mirromutth/latches" license = "MIT OR Apache-2.0" readme = "../README.md" description = "A downward counter (CountDownLatch) which can be used to synchronize threads or coordinate tasks" +rust-version = "1.63" # keep in sync with docs [package.metadata.docs.rs] all-features = true diff --git a/latches/build.rs b/latches/build.rs deleted file mode 100644 index c4a61ca..0000000 --- a/latches/build.rs +++ /dev/null @@ -1,43 +0,0 @@ -fn main() { - let rustc = std::env::var_os("RUSTC").unwrap_or("rustc".into()); - let output = std::process::Command::new(rustc) - .arg("-vV") - .output() - .expect("Failed to execute `rustc -vV`"); - - if !output.status.success() { - return println!( - "cargo:warning=latches: Failed `rustc -vV`: {}", - String::from_utf8_lossy(&output.stderr) - ); - } - - let output = String::from_utf8_lossy(&output.stdout); - - for line in output.lines() { - if let Some(version) = line.strip_prefix("release: ") { - if let Some(v) = version_tuple(version) { - if v < (1, 63) { - println!("cargo:rustc-cfg=latches_no_const_sync"); - } - return; - } else { - println!("cargo:warning=latches: Unexpected version: {line}"); - } - } - } - - println!("cargo:warning=latches: No version line in `rustc -vV` output"); -} - -fn version_tuple(version: &str) -> Option<(u16, u16)> { - let mut v = version.splitn(3, '.'); - - if let (Some(f), Some(s)) = (v.next(), v.next()) { - if let (Ok(major), Ok(minor)) = (f.parse(), s.parse()) { - return Some((major, minor)); - } - } - - None -} diff --git a/latches/src/lock/stds.rs b/latches/src/lock/stds.rs index 4200c02..114460c 100644 --- a/latches/src/lock/stds.rs +++ b/latches/src/lock/stds.rs @@ -15,18 +15,11 @@ pub(crate) struct EmptyCondvar(Mutex<()>, StdCondvar); pub(crate) type CondvarGuard<'a> = MutexGuard<'a, ()>; impl Mutex { - #[cfg(not(latches_no_const_sync))] #[must_use] #[inline] pub(crate) const fn new(t: T) -> Self { Self(StdMutex::new(t)) } - #[cfg(latches_no_const_sync)] - #[must_use] - #[inline] - pub(crate) fn new(t: T) -> Self { - Self(StdMutex::new(t)) - } pub(crate) fn lock(&self) -> MutexGuard<'_, T> { match self.0.lock() { @@ -38,18 +31,11 @@ impl Mutex { #[cfg(feature = "sync")] impl EmptyCondvar { - #[cfg(not(latches_no_const_sync))] #[must_use] #[inline] pub(crate) const fn new() -> Self { Self(Mutex::new(()), StdCondvar::new()) } - #[cfg(latches_no_const_sync)] - #[must_use] - #[inline] - pub(crate) fn new() -> Self { - Self(Mutex::new(()), StdCondvar::new()) - } /// Notifies all threads waiting on this condition variable. /// diff --git a/latches/src/sync/mod.rs b/latches/src/sync/mod.rs index fb127ef..254b3e3 100644 --- a/latches/src/sync/mod.rs +++ b/latches/src/sync/mod.rs @@ -114,7 +114,6 @@ impl Latch { /// let latch = Latch::new(10); /// # drop(latch); /// ``` - #[cfg(not(latches_no_const_sync))] #[must_use] #[inline] pub const fn new(count: usize) -> Self { @@ -123,17 +122,6 @@ impl Latch { cvar: EmptyCondvar::new(), } } - /// Creates a new latch initialized with the given count. - #[cfg(latches_no_const_sync)] - #[must_use] - #[inline] - pub fn new(count: usize) -> Self { - Self { - stat: AtomicUsize::new(count), - lock: Mutex::new(()), - cvar: Condvar::new(), - } - } /// Decrements the latch count, re-enable all waiting threads if the /// counter reaches 0 after decrement. diff --git a/latches/src/task/mod.rs b/latches/src/task/mod.rs index bacc478..3cef130 100644 --- a/latches/src/task/mod.rs +++ b/latches/src/task/mod.rs @@ -113,7 +113,6 @@ impl Latch { /// let latch = Latch::new(10); /// # drop(latch); /// ``` - #[cfg(not(latches_no_const_sync))] #[must_use] #[inline] pub const fn new(count: usize) -> Self { @@ -122,16 +121,6 @@ impl Latch { lock: Mutex::new(Waiters::new()), } } - /// Creates a new latch initialized with the given count. - #[cfg(latches_no_const_sync)] - #[must_use] - #[inline] - pub fn new(count: usize) -> Self { - Self { - stat: AtomicUsize::new(count), - lock: Mutex::new(Waiters::new()), - } - } /// Decrements the latch count, wake up all pending tasks if the counter /// reaches 0 after decrement.