Skip to content

Commit 8766094

Browse files
authored
Merge pull request #1359 from Lorak-mmk/clippy-expect
Clippy overhaul
2 parents 3da5d8b + 15448c4 commit 8766094

File tree

44 files changed

+107
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+107
-87
lines changed

clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
avoid-breaking-exported-api = false

examples/basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async fn main() -> Result<()> {
6161
}
6262

6363
// Or as custom structs that derive DeserializeRow
64-
#[allow(unused)]
64+
#[expect(unused)]
6565
#[derive(Debug, DeserializeRow)]
6666
struct RowData {
6767
a: i32,

scylla-cql/src/deserialize/frame_slice.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ impl<'frame> FrameSlice<'frame> {
121121
/// Returns a new Bytes object which is a subslice of the original Bytes
122122
/// frame slice object.
123123
#[inline]
124+
// Check triggers because `self` is `Copy`, so `to_` should take it by value.
125+
// TODO(2.0): Take self by value.
126+
#[expect(clippy::wrong_self_convention)]
124127
pub fn to_bytes(&self) -> Bytes {
125128
if self.original_frame.is_empty() {
126129
// For the borrowed, deficient version of FrameSlice - the one created with

scylla-cql/src/deserialize/result.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl RawRowLendingIterator {
175175
/// The column iterator must be consumed before the rows iterator can
176176
/// continue.
177177
#[inline]
178-
#[allow(clippy::should_implement_trait)] // https://github.com/rust-lang/rust-clippy/issues/5004
178+
#[expect(clippy::should_implement_trait)] // https://github.com/rust-lang/rust-clippy/issues/5004
179179
pub fn next(&mut self) -> Option<Result<ColumnIterator, DeserializationError>> {
180180
self.remaining = self.remaining.checked_sub(1)?;
181181

@@ -256,9 +256,6 @@ mod tests {
256256
fn lend_next(&mut self) -> Option<Result<Self::Item<'_>, DeserializationError>>;
257257
}
258258

259-
// Disable the lint, if there is more than one lifetime included.
260-
// Can be removed once https://github.com/rust-lang/rust-clippy/issues/12495 is fixed.
261-
#[allow(clippy::needless_lifetimes)]
262259
impl<'frame, 'metadata> LendingIterator for RawRowIterator<'frame, 'metadata> {
263260
type Item<'borrow>
264261
= ColumnIterator<'borrow, 'borrow>

scylla-cql/src/deserialize/row_tests.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,10 @@ fn test_deserialization_as_column_iterator() {
8484
// Do not remove. It's not used in tests but we keep it here to check that
8585
// we properly ignore warnings about unused variables, unnecessary `mut`s
8686
// etc. that usually pop up when generating code for empty structs.
87-
#[allow(unused)]
8887
#[derive(DeserializeRow)]
8988
#[scylla(crate = crate)]
9089
struct TestUdtWithNoFieldsUnordered {}
9190

92-
#[allow(unused)]
9391
#[derive(DeserializeRow)]
9492
#[scylla(crate = crate, flavor = "enforce_order")]
9593
struct TestUdtWithNoFieldsOrdered {}
@@ -934,9 +932,9 @@ fn metadata_does_not_bound_deserialized_rows() {
934932
#[derive(DeserializeRow)]
935933
#[scylla(crate=crate)]
936934
struct MyRow<'frame> {
937-
#[allow(dead_code)]
935+
#[expect(dead_code)]
938936
bytes: &'frame [u8],
939-
#[allow(dead_code)]
937+
#[expect(dead_code)]
940938
text: &'frame str,
941939
}
942940
let decoded_custom_struct_res = deserialize::<MyRow>(row_typ, &bytes);

scylla-cql/src/deserialize/value.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,6 +2167,9 @@ impl From<VectorDeserializationErrorKind> for BuiltinDeserializationErrorKind {
21672167
/// Describes why deserialization of a map type failed.
21682168
#[derive(Debug)]
21692169
#[non_exhaustive]
2170+
// Check triggers because all variants end with "DeserializationFailed".
2171+
// TODO(2.0): Remove the "DeserializationFailed" postfix from variants.
2172+
#[expect(clippy::enum_variant_names)]
21702173
pub enum MapDeserializationErrorKind {
21712174
/// Failed to deserialize map's length.
21722175
LengthDeserializationFailed(DeserializationError),

scylla-cql/src/deserialize/value_tests.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn test_custom_cassandra_type_parser() {
4242
dimensions: 5,
4343
},
4444
),
45-
( "636f6c756d6e:org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.Int32Type)",
45+
( "636f6c756d6e:org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.Int32Type)",
4646
ColumnType::Collection {
4747
frozen: false,
4848
typ: CollectionType::List(Box::new(ColumnType::Native(NativeType::Int))),
@@ -1200,12 +1200,10 @@ impl UdtSerializer {
12001200
// Do not remove. It's not used in tests but we keep it here to check that
12011201
// we properly ignore warnings about unused variables, unnecessary `mut`s
12021202
// etc. that usually pop up when generating code for empty structs.
1203-
#[allow(unused)]
12041203
#[derive(scylla_macros::DeserializeValue)]
12051204
#[scylla(crate = crate)]
12061205
struct TestUdtWithNoFieldsUnordered {}
12071206

1208-
#[allow(unused)]
12091207
#[derive(scylla_macros::DeserializeValue)]
12101208
#[scylla(crate = crate, flavor = "enforce_order")]
12111209
struct TestUdtWithNoFieldsOrdered {}
@@ -2783,9 +2781,9 @@ fn metadata_does_not_bound_deserialized_values() {
27832781
#[derive(DeserializeValue)]
27842782
#[scylla(crate=crate)]
27852783
struct Udt<'frame> {
2786-
#[allow(dead_code)]
2784+
#[expect(dead_code)]
27872785
bytes: &'frame [u8],
2788-
#[allow(dead_code)]
2786+
#[expect(dead_code)]
27892787
text: &'frame str,
27902788
}
27912789
let decoded_udt_res = deserialize::<Udt>(&udt_typ, &bytes);

scylla-cql/src/frame/frame_errors.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ pub enum CqlRequestSerializationError {
130130
/// server response fails.
131131
#[non_exhaustive]
132132
#[derive(Error, Debug, Clone)]
133+
// Check triggers because all variants begin with "Cql".
134+
// TODO(2.0): Remove the "Cql" prefix from variants.
135+
#[expect(clippy::enum_variant_names)]
133136
pub enum CqlResponseParseError {
134137
#[error("Failed to deserialize ERROR response: {0}")]
135138
CqlErrorParseError(#[from] CqlErrorParseError),
@@ -313,6 +316,9 @@ pub enum PreparedParseError {
313316
/// - paging state response
314317
#[non_exhaustive]
315318
#[derive(Debug, Error, Clone)]
319+
// Check triggers because all variants end with "ParseError".
320+
// TODO(2.0): Remove the "ParseError" postfix from variants.
321+
#[expect(clippy::enum_variant_names)]
316322
pub enum RawRowsAndPagingStateResponseParseError {
317323
/// Failed to parse metadata flags.
318324
#[error("Malformed metadata flags: {0}")]
@@ -331,6 +337,9 @@ pub enum RawRowsAndPagingStateResponseParseError {
331337
/// of statement's prepared metadata failed.
332338
#[non_exhaustive]
333339
#[derive(Error, Debug, Clone)]
340+
// Check triggers because all variants end with "ParseError".
341+
// TODO(2.0): Remove the "ParseError" postfix from variants.
342+
#[expect(clippy::enum_variant_names)]
334343
pub enum PreparedMetadataParseError {
335344
/// Failed to parse metadata flags.
336345
#[error("Malformed metadata flags: {0}")]
@@ -375,6 +384,9 @@ pub enum ResultMetadataAndRowsCountParseError {
375384
/// of result metadata failed.
376385
#[non_exhaustive]
377386
#[derive(Error, Debug, Clone)]
387+
// Check triggers because all variants end with "ParseError".
388+
// TODO(2.0): Remove the "ParseError" postfix from variants.
389+
#[expect(clippy::enum_variant_names)]
378390
pub enum ResultMetadataParseError {
379391
/// Failed to parse metadata flags.
380392
#[error("Malformed metadata flags: {0}")]
@@ -422,6 +434,9 @@ pub struct ColumnSpecParseError {
422434
/// of a column specification.
423435
#[non_exhaustive]
424436
#[derive(Error, Debug, Clone)]
437+
// Check triggers because all variants end with "ParseError".
438+
// TODO(2.0): Remove the "ParseError" postfix from variants.
439+
#[expect(clippy::enum_variant_names)]
425440
pub enum ColumnSpecParseErrorKind {
426441
#[error("Invalid table spec: {0}")]
427442
TableSpecParseError(#[from] TableSpecParseError),

scylla-cql/src/frame/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ pub mod flag {
3131
pub const WARNING: u8 = 0x08;
3232
}
3333

34-
// All of the Authenticators supported by Scylla
34+
/// All of the Authenticators supported by Scylla
3535
#[derive(Debug, PartialEq, Eq, Clone)]
36+
// Check triggers because all variants end with "Authenticator".
37+
// TODO(2.0): Remove the "Authenticator" postfix from variants.
38+
#[expect(clippy::enum_variant_names)]
3639
pub enum Authenticator {
3740
AllowAllAuthenticator,
3841
PasswordAuthenticator,

scylla-cql/src/frame/request/batch.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,6 @@ impl BatchStatement<'_> {
226226
}
227227
}
228228

229-
// Disable the lint, if there is more than one lifetime included.
230-
// Can be removed once https://github.com/rust-lang/rust-clippy/issues/12495 is fixed.
231-
#[allow(clippy::needless_lifetimes)]
232229
impl<'s, 'b> From<&'s BatchStatement<'b>> for BatchStatement<'s> {
233230
fn from(value: &'s BatchStatement) -> Self {
234231
match value {

0 commit comments

Comments
 (0)