Skip to content

Commit 85fed48

Browse files
committed
Address Clippy's lints introduced in Rust 1.87
New Rust version, new Clippy lints enabled by default. I decided to silence the lints about too large errors. Those are our standard error types, it would not be ergonomical to Box them. In some cases the Ok variant is larger, so it would make no sense to Box errors. If it ever becomes an issue, we can reconsider.
1 parent 7846462 commit 85fed48

File tree

8 files changed

+25
-22
lines changed

8 files changed

+25
-22
lines changed

examples/cqlsh-rs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ impl Completer for CqlHelper {
177177
}
178178
}
179179

180+
#[allow(clippy::result_large_err)]
180181
fn print_result(result: QueryResult) -> Result<(), IntoRowsResultError> {
181182
match result.into_rows_result() {
182183
Ok(rows_result) => {

scylla-proxy/src/frame.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ pub(crate) async fn write_frame(
243243
) -> Result<(), tokio::io::Error> {
244244
let compressed_body = compression
245245
.maybe_compress_body(params.flags, body)
246-
.map_err(|e| tokio::io::Error::new(std::io::ErrorKind::Other, e))?;
246+
.map_err(tokio::io::Error::other)?;
247247

248248
let body = compressed_body.as_deref().unwrap_or(body);
249249

scylla/src/cluster/node.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ pub(crate) async fn resolve_hostname(hostname: &str) -> Result<SocketAddr, io::E
301301
addrs
302302
.find_or_last(|addr| matches!(addr, SocketAddr::V4(_)))
303303
.ok_or_else(|| {
304-
io::Error::new(
305-
io::ErrorKind::Other,
306-
format!("Empty address list returned by DNS for {}", hostname),
307-
)
304+
io::Error::other(format!(
305+
"Empty address list returned by DNS for {}",
306+
hostname
307+
))
308308
})
309309
}
310310

scylla/src/network/connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ impl Connection {
13461346
std::pin::Pin::new(&mut stream)
13471347
.connect()
13481348
.await
1349-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
1349+
.map_err(std::io::Error::other)?;
13501350
return Ok(spawn_router_and_get_handle(
13511351
config,
13521352
stream,

scylla/src/network/tls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ impl From<TlsError> for io::Error {
145145
#[cfg(feature = "openssl-010")]
146146
TlsError::OpenSsl010(e) => e.into(),
147147
#[cfg(feature = "rustls-023")]
148-
TlsError::InvalidName(e) => io::Error::new(io::ErrorKind::Other, e),
148+
TlsError::InvalidName(e) => io::Error::other(e),
149149
#[cfg(feature = "rustls-023")]
150-
TlsError::PemParse(e) => io::Error::new(io::ErrorKind::Other, e),
150+
TlsError::PemParse(e) => io::Error::other(e),
151151
#[cfg(feature = "rustls-023")]
152-
TlsError::Rustls023(e) => io::Error::new(io::ErrorKind::Other, e),
152+
TlsError::Rustls023(e) => io::Error::other(e),
153153
}
154154
}
155155
}

scylla/src/response/query_result.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ impl QueryResult {
207207
/// Ok(())
208208
/// # }
209209
/// ```
210+
// `allow(clippy::result_large_err)` is fine. `QueryRowsResult` is larger than `IntoRowsResultError`.
211+
#[allow(clippy::result_large_err)]
210212
pub fn into_rows_result(self) -> Result<QueryRowsResult, IntoRowsResultError> {
211213
let Some(raw_metadata_and_rows) = self.raw_metadata_and_rows else {
212214
return Err(IntoRowsResultError::ResultNotRows(self));

scylla/src/statement/batch.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,18 @@ pub(crate) mod batch_values {
248248

249249
use super::BatchStatement;
250250

251-
// Takes an optional reference to the first statement in the batch and
252-
// the batch values, and tries to compute the token for the statement.
253-
// Returns the (optional) token and batch values. If the function needed
254-
// to serialize values for the first statement, the returned batch values
255-
// will cache the results of the serialization.
256-
//
257-
// NOTE: Batch values returned by this function might not type check
258-
// the first statement when it is serialized! However, if they don't,
259-
// then the first row was already checked by the function. It is assumed
260-
// that `statement` holds the first prepared statement of the batch (if
261-
// there is one), and that it will be used later to serialize the values.
251+
/// Takes an optional reference to the first statement in the batch and
252+
/// the batch values, and tries to compute the token for the statement.
253+
/// Returns the (optional) token and batch values. If the function needed
254+
/// to serialize values for the first statement, the returned batch values
255+
/// will cache the results of the serialization.
256+
///
257+
/// NOTE: Batch values returned by this function might not type check
258+
/// the first statement when it is serialized! However, if they don't,
259+
/// then the first row was already checked by the function. It is assumed
260+
/// that `statement` holds the first prepared statement of the batch (if
261+
/// there is one), and that it will be used later to serialize the values.
262+
#[allow(clippy::result_large_err)]
262263
pub(crate) fn peek_first_token<'bv>(
263264
values: impl BatchValues + 'bv,
264265
statement: Option<&BatchStatement>,

scylla/src/utils/test_utils.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use scylla_cql::frame::response::error::DbError;
22
use tracing::{error, warn};
33

44
use crate::client::caching_session::CachingSession;
5-
use crate::client::execution_profile::ExecutionProfile;
65
use crate::client::session::Session;
76
use crate::client::session_builder::{GenericSessionBuilder, SessionBuilderKind};
87
use crate::cluster::ClusterState;
@@ -214,7 +213,7 @@ fn apply_ddl_lbp(query: &mut Statement) {
214213
let policy = query
215214
.get_execution_profile_handle()
216215
.map(|profile| profile.pointee_to_builder())
217-
.unwrap_or(ExecutionProfile::builder())
216+
.unwrap_or_default()
218217
.load_balancing_policy(Arc::new(SchemaQueriesLBP))
219218
.retry_policy(Arc::new(SchemaQueriesRetryPolicy))
220219
.build();

0 commit comments

Comments
 (0)