From 59cbe58acd4c0c84e3da43fd3ef6f692096ec1bb Mon Sep 17 00:00:00 2001 From: Bhuwan Pandit Date: Sat, 26 Oct 2024 13:30:39 +0100 Subject: [PATCH 1/4] fix: fix dead code warning for 'Sealed' trait and 'sample_floyd2' function using conditional compilation --- tower/src/lib.rs | 1 + tower/src/util/rng.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/tower/src/lib.rs b/tower/src/lib.rs index 179edfbec..39b947574 100644 --- a/tower/src/lib.rs +++ b/tower/src/lib.rs @@ -219,6 +219,7 @@ pub use tower_layer::Layer; pub use tower_service::Service; #[allow(unreachable_pub)] +#[cfg(any(feature = "balance", feature = "discover", feature = "full", feature = "make"))] mod sealed { pub trait Sealed {} } diff --git a/tower/src/util/rng.rs b/tower/src/util/rng.rs index 9b6d307d9..4156cf191 100644 --- a/tower/src/util/rng.rs +++ b/tower/src/util/rng.rs @@ -116,6 +116,7 @@ where /// /// ref: This was borrowed and modified from the following Rand implementation /// https://github.com/rust-random/rand/blob/b73640705d6714509f8ceccc49e8df996fa19f51/src/seq/index.rs#L375-L411 +#[cfg(not(any(feature = "hedge", feature = "retry", feature = "spawn-ready", feature = "util")))] pub(crate) fn sample_floyd2(rng: &mut R, length: u64) -> [u64; 2] { debug_assert!(2 <= length); let aidx = rng.next_range(0..length - 1); From ec318148b4f97453a06fdc3b297835d13090749b Mon Sep 17 00:00:00 2001 From: Bhuwan Pandit Date: Sat, 26 Oct 2024 13:43:55 +0100 Subject: [PATCH 2/4] fix: add full feature flag to sample_floyd2 --- tower/src/util/rng.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tower/src/util/rng.rs b/tower/src/util/rng.rs index 4156cf191..435d6a9e4 100644 --- a/tower/src/util/rng.rs +++ b/tower/src/util/rng.rs @@ -116,7 +116,7 @@ where /// /// ref: This was borrowed and modified from the following Rand implementation /// https://github.com/rust-random/rand/blob/b73640705d6714509f8ceccc49e8df996fa19f51/src/seq/index.rs#L375-L411 -#[cfg(not(any(feature = "hedge", feature = "retry", feature = "spawn-ready", feature = "util")))] +#[cfg(any(features = "full", not(any(feature = "hedge", feature = "retry", feature = "spawn-ready", feature = "util"))))] pub(crate) fn sample_floyd2(rng: &mut R, length: u64) -> [u64; 2] { debug_assert!(2 <= length); let aidx = rng.next_range(0..length - 1); From 1adac806ed04a8d38d05f351ac107b99d6917386 Mon Sep 17 00:00:00 2001 From: Bhuwan Pandit Date: Sat, 26 Oct 2024 13:46:48 +0100 Subject: [PATCH 3/4] fix: typo --- tower/src/util/rng.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tower/src/util/rng.rs b/tower/src/util/rng.rs index 435d6a9e4..c04a44433 100644 --- a/tower/src/util/rng.rs +++ b/tower/src/util/rng.rs @@ -116,7 +116,7 @@ where /// /// ref: This was borrowed and modified from the following Rand implementation /// https://github.com/rust-random/rand/blob/b73640705d6714509f8ceccc49e8df996fa19f51/src/seq/index.rs#L375-L411 -#[cfg(any(features = "full", not(any(feature = "hedge", feature = "retry", feature = "spawn-ready", feature = "util"))))] +#[cfg(any(feature = "full", not(any(feature = "hedge", feature = "retry", feature = "spawn-ready", feature = "util"))))] pub(crate) fn sample_floyd2(rng: &mut R, length: u64) -> [u64; 2] { debug_assert!(2 <= length); let aidx = rng.next_range(0..length - 1); From c0c127f8f83ab99585642081b2e8ef858318f6f8 Mon Sep 17 00:00:00 2001 From: Bhuwan Pandit Date: Sat, 26 Oct 2024 19:04:07 +0100 Subject: [PATCH 4/4] fix: remove unwanted feature flags --- tower/src/lib.rs | 2 +- tower/src/util/rng.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tower/src/lib.rs b/tower/src/lib.rs index 39b947574..ce911e9d8 100644 --- a/tower/src/lib.rs +++ b/tower/src/lib.rs @@ -219,7 +219,7 @@ pub use tower_layer::Layer; pub use tower_service::Service; #[allow(unreachable_pub)] -#[cfg(any(feature = "balance", feature = "discover", feature = "full", feature = "make"))] +#[cfg(any(feature = "balance", feature = "discover", feature = "make"))] mod sealed { pub trait Sealed {} } diff --git a/tower/src/util/rng.rs b/tower/src/util/rng.rs index c04a44433..5b2f9fce7 100644 --- a/tower/src/util/rng.rs +++ b/tower/src/util/rng.rs @@ -116,7 +116,7 @@ where /// /// ref: This was borrowed and modified from the following Rand implementation /// https://github.com/rust-random/rand/blob/b73640705d6714509f8ceccc49e8df996fa19f51/src/seq/index.rs#L375-L411 -#[cfg(any(feature = "full", not(any(feature = "hedge", feature = "retry", feature = "spawn-ready", feature = "util"))))] +#[cfg(feature = "balance")] pub(crate) fn sample_floyd2(rng: &mut R, length: u64) -> [u64; 2] { debug_assert!(2 <= length); let aidx = rng.next_range(0..length - 1);