Skip to content

Commit

Permalink
fix: multiple clippy warnings (#296)
Browse files Browse the repository at this point in the history
* fix: feature is misspelled as features
* fix feature flags
* fix deprecation warning

Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun authored Sep 11, 2023
1 parent b030ef9 commit b2b5436
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ jobs:
- name: Build
run: cargo build --features protobuf-src
- name: Check Clippy
run: cargo clippy --tests --all-features -- -D warnings
run: |
cargo clippy --tests --features telemetry,protobuf-src -- -D warnings
cargo clippy --tests --no-default-features --features compression,tokio-rustls-runtime,async-std-rustls-runtime,auth-oauth2,telemetry,protobuf-src -- -D warnings
- name: Install nightly rustfmt
run: rustup toolchain install nightly --component rustfmt
- name: Check format
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bit-vec = "^0.6.3"
futures = "^0.3.28"
futures-io = "^0.3.28"
native-tls = { version = "^0.2.11", optional = true }
rustls = { version = "^0.21.5", optional = true }
rustls = { version = "^0.21.6", optional = true }
webpki-roots = { version = "^0.25.1", optional = true }
pem = "^3.0.0"
tokio = { version = "^1.29.1", features = ["rt", "net", "time"], optional = true }
Expand Down Expand Up @@ -66,7 +66,7 @@ prost-build = "^0.11.9"
protobuf-src = { version = "1.1.0", optional = true }

[features]
default = [ "compression", "tokio-runtime", "async-std-runtime", "auth-oauth2"]
default = [ "compression", "tokio-runtime", "async-std-runtime", "auth-oauth2" ]
compression = [ "lz4", "flate2", "zstd", "snap" ]
tokio-runtime = [ "tokio", "tokio-util", "native-tls", "tokio-native-tls" ]
tokio-rustls-runtime = ["tokio", "tokio-util", "tokio-rustls", "rustls", "webpki-roots" ]
Expand Down
5 changes: 3 additions & 2 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@ impl<Exe: Executor> Connection<Exe> {
}

#[cfg_attr(feature = "telemetry", tracing::instrument(skip_all))]
#[allow(unused_variables)] // allow_insecure_connection and tls_hostname_verification_enabled are native-tls only
async fn prepare_stream(
connection_id: Uuid,
address: SocketAddr,
Expand Down Expand Up @@ -964,7 +965,7 @@ impl<Exe: Executor> Connection<Exe> {
},
);

root_store.add_server_trust_anchors(trust_anchors.into_iter());
root_store.add_trust_anchors(trust_anchors.into_iter());
let config = rustls::ClientConfig::builder()
.with_safe_default_cipher_suites()
.with_safe_default_kx_groups()
Expand Down Expand Up @@ -1075,7 +1076,7 @@ impl<Exe: Executor> Connection<Exe> {
},
);

root_store.add_server_trust_anchors(trust_anchors.into_iter());
root_store.add_trust_anchors(trust_anchors.into_iter());
let config = rustls::ClientConfig::builder()
.with_safe_default_cipher_suites()
.with_safe_default_kx_groups()
Expand Down
16 changes: 8 additions & 8 deletions src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ impl Executor for TokioExecutor {
}

/// Wrapper for the async-std executor
#[cfg(any(feature = "async-std-runtime", features = "async-std-rustls-runtime"))]
#[cfg(any(feature = "async-std-runtime", feature = "async-std-rustls-runtime"))]
#[derive(Clone, Debug)]
pub struct AsyncStdExecutor;

#[cfg(any(feature = "async-std-runtime", features = "async-std-rustls-runtime"))]
#[cfg(any(feature = "async-std-runtime", feature = "async-std-rustls-runtime"))]
impl Executor for AsyncStdExecutor {
#[cfg_attr(feature = "telemetry", tracing::instrument(skip_all))]
fn spawn(&self, f: Pin<Box<dyn Future<Output = ()> + Send>>) -> Result<(), ()> {
Expand Down Expand Up @@ -153,7 +153,7 @@ pub enum JoinHandle<T> {
#[cfg(any(feature = "tokio-runtime", feature = "tokio-rustls-runtime"))]
Tokio(tokio::task::JoinHandle<T>),
/// wrapper for async-std's `JoinHandle`
#[cfg(any(feature = "async-std-runtime", features = "async-std-rustls-runtime"))]
#[cfg(any(feature = "async-std-runtime", feature = "async-std-rustls-runtime"))]
AsyncStd(async_std::task::JoinHandle<T>),
// here to avoid a compilation error since T is not used
#[cfg(all(
Expand All @@ -176,7 +176,7 @@ impl<T> Future for JoinHandle<T> {
Poll::Pending => Poll::Pending,
Poll::Ready(v) => Poll::Ready(v.ok()),
},
#[cfg(any(feature = "async-std-runtime", features = "async-std-rustls-runtime"))]
#[cfg(any(feature = "async-std-runtime", feature = "async-std-rustls-runtime"))]
JoinHandle::AsyncStd(j) => match Pin::new(j).poll(cx) {
Poll::Pending => Poll::Pending,
Poll::Ready(v) => Poll::Ready(Some(v)),
Expand All @@ -200,7 +200,7 @@ pub enum Interval {
#[cfg(any(feature = "tokio-runtime", feature = "tokio-rustls-runtime"))]
Tokio(tokio::time::Interval),
/// wrapper for async-std's interval
#[cfg(any(feature = "async-std-runtime", features = "async-std-rustls-runtime"))]
#[cfg(any(feature = "async-std-runtime", feature = "async-std-rustls-runtime"))]
AsyncStd(async_std::stream::Interval),
#[cfg(all(
not(feature = "tokio-runtime"),
Expand All @@ -226,7 +226,7 @@ impl Stream for Interval {
Poll::Pending => Poll::Pending,
Poll::Ready(_) => Poll::Ready(Some(())),
},
#[cfg(any(feature = "async-std-runtime", features = "async-std-rustls-runtime"))]
#[cfg(any(feature = "async-std-runtime", feature = "async-std-rustls-runtime"))]
Interval::AsyncStd(j) => match Pin::new_unchecked(j).poll_next(cx) {
Poll::Pending => Poll::Pending,
Poll::Ready(v) => Poll::Ready(v),
Expand All @@ -251,7 +251,7 @@ pub enum Delay {
#[cfg(any(feature = "tokio-runtime", feature = "tokio-rustls-runtime"))]
Tokio(tokio::time::Sleep),
/// wrapper around async-std's `Delay`
#[cfg(any(feature = "async-std-runtime", features = "async-std-rustls-runtime"))]
#[cfg(any(feature = "async-std-runtime", feature = "async-std-rustls-runtime"))]
AsyncStd(Pin<Box<dyn Future<Output = ()> + Send + Sync>>),
}

Expand All @@ -267,7 +267,7 @@ impl Future for Delay {
Poll::Pending => Poll::Pending,
Poll::Ready(_) => Poll::Ready(()),
},
#[cfg(any(feature = "async-std-runtime", features = "async-std-rustls-runtime"))]
#[cfg(any(feature = "async-std-runtime", feature = "async-std-rustls-runtime"))]
Delay::AsyncStd(j) => match Pin::new_unchecked(j).poll(cx) {
Poll::Pending => Poll::Pending,
Poll::Ready(_) => Poll::Ready(()),
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ extern crate prost_derive;
#[macro_use]
extern crate serde;

#[cfg(all(features = "tokio-rustls-runtime", features = "tokio-runtime"))]
#[cfg(all(feature = "tokio-rustls-runtime", feature = "tokio-runtime"))]
compile_error!("You have selected both features \"tokio-rustls-runtime\" and \"tokio-runtime\" which are exclusive, please choose one of them");
#[cfg(all(features = "async-std-rustls-runtime", features = "async-std-runtime"))]
#[cfg(all(feature = "async-std-rustls-runtime", feature = "async-std-runtime"))]
compile_error!("You have selected both features \"async-std-rustls-runtime\" and \"async-std-runtime\" which are exclusive, please choose one of them");

pub use client::{DeserializeMessage, Pulsar, PulsarBuilder, SerializeMessage};
Expand All @@ -172,7 +172,7 @@ pub use connection_manager::{
};
pub use consumer::{Consumer, ConsumerBuilder, ConsumerOptions};
pub use error::Error;
#[cfg(any(feature = "async-std-runtime", features = "async-std-rustls-runtime"))]
#[cfg(any(feature = "async-std-runtime", feature = "async-std-rustls-runtime"))]
pub use executor::AsyncStdExecutor;
pub use executor::Executor;
#[cfg(any(feature = "tokio-runtime", feature = "tokio-rustls-runtime"))]
Expand Down

0 comments on commit b2b5436

Please sign in to comment.