From 24b3c8ba34935f8fdde9130cd5130a36a7a2de51 Mon Sep 17 00:00:00 2001 From: Erin Power Date: Tue, 11 May 2021 10:53:35 +0200 Subject: [PATCH] Clippy fixes --- src/extensions/filter_manager.rs | 6 +++--- src/extensions/filter_registry.rs | 6 +++--- .../filters/local_rate_limit/mod.rs | 21 ++++++++++++------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/extensions/filter_manager.rs b/src/extensions/filter_manager.rs index 4eb1a1330b..9edd136945 100644 --- a/src/extensions/filter_manager.rs +++ b/src/extensions/filter_manager.rs @@ -34,8 +34,8 @@ pub struct FilterManager { /// ListenerManagerArgs contains arguments when invoking the LDS resource manager. pub(crate) struct ListenerManagerArgs { - pub filter_registry: Arc, pub filter_chain_updates_tx: mpsc::Sender>, + pub filter_registry: Arc, pub metrics_registry: Registry, } @@ -46,9 +46,9 @@ impl ListenerManagerArgs { filter_chain_updates_tx: mpsc::Sender>, ) -> ListenerManagerArgs { ListenerManagerArgs { - metrics_registry, - filter_registry, filter_chain_updates_tx, + filter_registry, + metrics_registry, } } } diff --git a/src/extensions/filter_registry.rs b/src/extensions/filter_registry.rs index 68b13ecf57..9b0e3872f8 100644 --- a/src/extensions/filter_registry.rs +++ b/src/extensions/filter_registry.rs @@ -237,9 +237,9 @@ impl fmt::Display for Error { } } -impl Into for Error { - fn into(self) -> ValidationError { - ValidationError::FilterInvalid(self) +impl From for ValidationError { + fn from(error: Error) -> Self { + Self::FilterInvalid(error) } } diff --git a/src/extensions/filters/local_rate_limit/mod.rs b/src/extensions/filters/local_rate_limit/mod.rs index e2b3225881..8ada54b777 100644 --- a/src/extensions/filters/local_rate_limit/mod.rs +++ b/src/extensions/filters/local_rate_limit/mod.rs @@ -135,10 +135,12 @@ impl RateLimitFilter { while !refilled { let remaining_tokens = available_tokens.load(Ordering::Relaxed); - refilled = available_tokens.compare_and_swap( + refilled = available_tokens.compare_exchange( remaining_tokens, max_tokens, - Ordering::Relaxed) == remaining_tokens; + Ordering::Relaxed, + Ordering::Relaxed, + ).unwrap_or_else(|b| b) == remaining_tokens; } }, _ = &mut shutdown_rx => { @@ -166,11 +168,16 @@ impl RateLimitFilter { return None; } - if self.available_tokens.compare_and_swap( - remaining_tokens, - remaining_tokens - 1, - Ordering::Relaxed, - ) == remaining_tokens + if self + .available_tokens + .compare_exchange( + remaining_tokens, + remaining_tokens - 1, + Ordering::Relaxed, + Ordering::Relaxed, + ) + .unwrap_or_else(|b| b) + == remaining_tokens { return Some(()); }