From 79f42d72e2a93ab39b57794942a90d9f143a1d8f Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Fri, 13 May 2022 18:03:51 +0200 Subject: [PATCH] Fix unused code warnings. --- lightning/src/util/fairrwlock.rs | 6 +----- lightning/src/util/mod.rs | 2 +- lightning/src/util/test_utils.rs | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lightning/src/util/fairrwlock.rs b/lightning/src/util/fairrwlock.rs index 8dd74f2b5..c9b3866be 100644 --- a/lightning/src/util/fairrwlock.rs +++ b/lightning/src/util/fairrwlock.rs @@ -1,4 +1,4 @@ -use std::sync::{TryLockResult, LockResult, RwLock, RwLockReadGuard, RwLockWriteGuard}; +use std::sync::{LockResult, RwLock, RwLockReadGuard, RwLockWriteGuard}; use std::sync::atomic::{AtomicUsize, Ordering}; /// Rust libstd's RwLock does not provide any fairness guarantees (and, in fact, when used on @@ -32,10 +32,6 @@ impl FairRwLock { res } - pub fn try_write(&self) -> TryLockResult> { - self.lock.try_write() - } - pub fn read(&self) -> LockResult> { if self.waiting_writers.load(Ordering::Relaxed) != 0 { let _write_queue_lock = self.lock.write(); diff --git a/lightning/src/util/mod.rs b/lightning/src/util/mod.rs index 075798331..b7ee02d2c 100644 --- a/lightning/src/util/mod.rs +++ b/lightning/src/util/mod.rs @@ -25,7 +25,7 @@ pub mod persist; pub(crate) mod atomic_counter; pub(crate) mod byte_utils; pub(crate) mod chacha20; -#[cfg(feature = "std")] +#[cfg(all(not(test), feature = "std"))] pub(crate) mod fairrwlock; #[cfg(fuzzing)] pub mod zbase32; diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index b5953834c..5e9591d8e 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -267,12 +267,12 @@ impl TestChannelMessageHandler { expected_msgs.as_mut().unwrap().push(ev); } - fn received_msg(&self, ev: wire::Message<()>) { + fn received_msg(&self, _ev: wire::Message<()>) { let mut msgs = self.expected_recv_msgs.lock().unwrap(); if msgs.is_none() { return; } assert!(!msgs.as_ref().unwrap().is_empty(), "Received message when we weren't expecting one"); #[cfg(test)] - assert_eq!(msgs.as_ref().unwrap()[0], ev); + assert_eq!(msgs.as_ref().unwrap()[0], _ev); msgs.as_mut().unwrap().remove(0); } } -- 2.39.5