Skip to content

Commit 64064c0

Browse files
committed
Replace allow with expect where possible
If some check always (independent of configuration) triggers for some code, it is better to use expect because we will be notified when the check stops triggering. Some uses of "allow" remain. We could try to replace them with `cfg_attr` magic, but it would be compplicated in many cases and I feel that it won't bring much benefit.
1 parent db71122 commit 64064c0

File tree

29 files changed

+50
-50
lines changed

29 files changed

+50
-50
lines changed

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/result.rs

Lines changed: 1 addition & 1 deletion
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

scylla-cql/src/deserialize/row_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,9 +932,9 @@ fn metadata_does_not_bound_deserialized_rows() {
932932
#[derive(DeserializeRow)]
933933
#[scylla(crate=crate)]
934934
struct MyRow<'frame> {
935-
#[allow(dead_code)]
935+
#[expect(dead_code)]
936936
bytes: &'frame [u8],
937-
#[allow(dead_code)]
937+
#[expect(dead_code)]
938938
text: &'frame str,
939939
}
940940
let decoded_custom_struct_res = deserialize::<MyRow>(row_typ, &bytes);

scylla-cql/src/deserialize/value_tests.rs

Lines changed: 3 additions & 3 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))),
@@ -2781,9 +2781,9 @@ fn metadata_does_not_bound_deserialized_values() {
27812781
#[derive(DeserializeValue)]
27822782
#[scylla(crate=crate)]
27832783
struct Udt<'frame> {
2784-
#[allow(dead_code)]
2784+
#[expect(dead_code)]
27852785
bytes: &'frame [u8],
2786-
#[allow(dead_code)]
2786+
#[expect(dead_code)]
27872787
text: &'frame str,
27882788
}
27892789
let decoded_udt_res = deserialize::<Udt>(&udt_typ, &bytes);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Request<'_> {
162162
Request::Query(q) => Some(q.parameters.consistency),
163163
Request::Execute(e) => Some(e.parameters.consistency),
164164
Request::Batch(b) => Some(b.consistency),
165-
#[allow(unreachable_patterns)] // until other opcodes are supported
165+
#[expect(unreachable_patterns)] // until other opcodes are supported
166166
_ => None,
167167
}
168168
}
@@ -173,7 +173,7 @@ impl Request<'_> {
173173
Request::Query(q) => Some(q.parameters.serial_consistency),
174174
Request::Execute(e) => Some(e.parameters.serial_consistency),
175175
Request::Batch(b) => Some(b.serial_consistency),
176-
#[allow(unreachable_patterns)] // until other opcodes are supported
176+
#[expect(unreachable_patterns)] // until other opcodes are supported
177177
_ => None,
178178
}
179179
}

scylla-cql/src/frame/response/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl ColumnType<'_> {
260260
// Scylla's set of types supported for empty values as it's smaller;
261261
// with Cassandra, some rejects will just have to be rejected on the db side.
262262
pub(crate) fn supports_special_empty_value(&self) -> bool {
263-
#[allow(clippy::match_like_matches_macro)]
263+
#[expect(clippy::match_like_matches_macro)]
264264
match self {
265265
ColumnType::Native(NativeType::Counter)
266266
| ColumnType::Native(NativeType::Duration)

scylla-cql/src/serialize/row_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ struct TestRowWithSkippedFields {
669669
a: String,
670670
b: i32,
671671
#[scylla(skip)]
672-
#[allow(dead_code)]
672+
#[expect(dead_code)]
673673
skipped: Vec<String>,
674674
c: Vec<i64>,
675675
}

scylla-cql/src/serialize/value_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ fn test_cql_value_udt_errors() {
522522
// Do not remove. It's not used in tests but we keep it here to check that
523523
// we properly ignore warnings about unused variables, unnecessary `mut`s
524524
// etc. that usually pop up when generating code for empty structs.
525-
#[allow(unused)]
525+
#[expect(unused)]
526526
#[derive(SerializeValue)]
527527
#[scylla(crate = crate)]
528528
struct TestUdtWithNoFields {}
@@ -1162,7 +1162,7 @@ fn test_udt_serialization_with_field_rename_and_enforce_order() {
11621162
assert_eq!(reference, udt);
11631163
}
11641164

1165-
#[allow(unused)]
1165+
#[expect(unused)]
11661166
#[derive(SerializeValue, Debug)]
11671167
#[scylla(crate = crate, flavor = "enforce_order", skip_name_checks)]
11681168
struct TestUdtWithSkippedNameChecks {
@@ -1329,7 +1329,7 @@ struct TestUdtWithSkippedFields {
13291329
a: String,
13301330
b: i32,
13311331
#[scylla(skip)]
1332-
#[allow(dead_code)]
1332+
#[expect(dead_code)]
13331333
skipped: Vec<String>,
13341334
c: Vec<i64>,
13351335
}

scylla-macros/src/serialize/row.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ impl Generator for ColumnSortingGenerator<'_> {
396396
#partial_struct
397397
#partial_serialize
398398

399-
#[allow(non_local_definitions)]
399+
#[expect(non_local_definitions)]
400400
#serialize_by_name
401401

402402
#crate_path::ser::row::ByName::<Self>::serialize(#crate_path::ser::row::ByName(self), ctx, writer)
@@ -447,7 +447,7 @@ impl Generator for ColumnOrderedGenerator<'_> {
447447
ctx: &#crate_path::RowSerializationContext,
448448
writer: &mut #crate_path::RowWriter<'_scylla_ser_row_writer_buffer>,
449449
) -> ::std::result::Result<(), #crate_path::SerializationError> {
450-
#[allow(non_local_definitions)]
450+
#[expect(non_local_definitions)]
451451
impl #impl_generics #crate_path::SerializeRowInOrder for #struct_name #ty_generics #where_clause {
452452
fn serialize_in_order(
453453
&self,

scylla-proxy/src/actions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl Condition {
121121
}
122122

123123
/// A convenience function for creating [Condition::Not] variant.
124-
#[allow(clippy::should_implement_trait)]
124+
#[expect(clippy::should_implement_trait)]
125125
pub fn not(c: Self) -> Self {
126126
Condition::Not(Box::new(c))
127127
}

0 commit comments

Comments
 (0)