Skip to content

Commit

Permalink
Merge pull request #1136 from muzarski/clippy-1.83
Browse files Browse the repository at this point in the history
rust: appease compiler, formatter and linter from toolchain 1.83
  • Loading branch information
wprzytula authored Dec 2, 2024
2 parents 64647f9 + 9639b99 commit 49c342e
Show file tree
Hide file tree
Showing 29 changed files with 112 additions and 65 deletions.
5 changes: 4 additions & 1 deletion examples/cqlsh-rs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ fn print_result(result: QueryResult) -> Result<(), IntoRowsResultError> {
}
Ok(())
}
Err(IntoRowsResultError::ResultNotRows(_)) => Ok(println!("OK")),
Err(IntoRowsResultError::ResultNotRows(_)) => {
println!("OK");
Ok(())
}
Err(e) => Err(e),
}
}
Expand Down
3 changes: 3 additions & 0 deletions scylla-cql/src/frame/request/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ impl BatchStatement<'_> {
}
}

// Disable the lint, if there is more than one lifetime included.
// Can be removed once https://github.com/rust-lang/rust-clippy/issues/12495 is fixed.
#[allow(clippy::needless_lifetimes)]
impl<'s, 'b> From<&'s BatchStatement<'b>> for BatchStatement<'s> {
fn from(value: &'s BatchStatement) -> Self {
match value {
Expand Down
2 changes: 1 addition & 1 deletion scylla-cql/src/frame/request/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl SerializableRequest for Execute<'_> {
}
}

impl<'e> DeserializableRequest for Execute<'e> {
impl DeserializableRequest for Execute<'_> {
fn deserialize(buf: &mut &[u8]) -> Result<Self, RequestDeserializationError> {
let id = types::read_short_bytes(buf)?.to_vec().into();
let parameters = QueryParameters::deserialize(buf)?;
Expand Down
2 changes: 1 addition & 1 deletion scylla-cql/src/frame/request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub enum Request<'r> {
Batch(Batch<'r, BatchStatement<'r>, Vec<SerializedValues>>),
}

impl<'r> Request<'r> {
impl Request<'_> {
pub fn deserialize(
buf: &mut &[u8],
opcode: RequestOpcode,
Expand Down
2 changes: 1 addition & 1 deletion scylla-cql/src/frame/request/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct Prepare<'a> {
pub query: &'a str,
}

impl<'a> SerializableRequest for Prepare<'a> {
impl SerializableRequest for Prepare<'_> {
const OPCODE: RequestOpcode = RequestOpcode::Prepare;

fn serialize(&self, buf: &mut Vec<u8>) -> Result<(), CqlRequestSerializationError> {
Expand Down
4 changes: 2 additions & 2 deletions scylla-cql/src/frame/request/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl SerializableRequest for Query<'_> {
}
}

impl<'q> DeserializableRequest for Query<'q> {
impl DeserializableRequest for Query<'_> {
fn deserialize(buf: &mut &[u8]) -> Result<Self, RequestDeserializationError> {
let contents = Cow::Owned(types::read_long_string(buf)?.to_owned());
let parameters = QueryParameters::deserialize(buf)?;
Expand Down Expand Up @@ -146,7 +146,7 @@ impl QueryParameters<'_> {
}
}

impl<'q> QueryParameters<'q> {
impl QueryParameters<'_> {
pub fn deserialize(buf: &mut &[u8]) -> Result<Self, RequestDeserializationError> {
let consistency = types::read_consistency(buf)?;

Expand Down
2 changes: 1 addition & 1 deletion scylla-cql/src/frame/response/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub enum ColumnType<'frame> {
Varint,
}

impl<'frame> ColumnType<'frame> {
impl ColumnType<'_> {
pub fn into_owned(self) -> ColumnType<'static> {
match self {
ColumnType::Custom(cow) => ColumnType::Custom(cow.into_owned().into()),
Expand Down
35 changes: 26 additions & 9 deletions scylla-cql/src/frame/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ impl ValueList for LegacySerializedValues {
}
}

impl<'b> ValueList for Cow<'b, LegacySerializedValues> {
impl ValueList for Cow<'_, LegacySerializedValues> {
fn serialized(&self) -> SerializedResult<'_> {
Ok(Cow::Borrowed(self.as_ref()))
}
Expand Down Expand Up @@ -1662,23 +1662,32 @@ where
IT: Iterator<Item = &'a VL> + Clone,
VL: ValueList + 'a,
{
type LegacyBatchValuesIter<'r> = LegacyBatchValuesIteratorFromIterator<IT> where Self: 'r;
type LegacyBatchValuesIter<'r>
= LegacyBatchValuesIteratorFromIterator<IT>
where
Self: 'r;
fn batch_values_iter(&self) -> Self::LegacyBatchValuesIter<'_> {
self.it.clone().into()
}
}

// Implement BatchValues for slices of ValueList types
impl<T: ValueList> LegacyBatchValues for [T] {
type LegacyBatchValuesIter<'r> = LegacyBatchValuesIteratorFromIterator<std::slice::Iter<'r, T>> where Self: 'r;
type LegacyBatchValuesIter<'r>
= LegacyBatchValuesIteratorFromIterator<std::slice::Iter<'r, T>>
where
Self: 'r;
fn batch_values_iter(&self) -> Self::LegacyBatchValuesIter<'_> {
self.iter().into()
}
}

// Implement BatchValues for Vec<ValueList>
impl<T: ValueList> LegacyBatchValues for Vec<T> {
type LegacyBatchValuesIter<'r> = LegacyBatchValuesIteratorFromIterator<std::slice::Iter<'r, T>> where Self: 'r;
type LegacyBatchValuesIter<'r>
= LegacyBatchValuesIteratorFromIterator<std::slice::Iter<'r, T>>
where
Self: 'r;
fn batch_values_iter(&self) -> Self::LegacyBatchValuesIter<'_> {
LegacyBatchValues::batch_values_iter(self.as_slice())
}
Expand All @@ -1687,7 +1696,10 @@ impl<T: ValueList> LegacyBatchValues for Vec<T> {
// Here is an example implementation for (T0, )
// Further variants are done using a macro
impl<T0: ValueList> LegacyBatchValues for (T0,) {
type LegacyBatchValuesIter<'r> = LegacyBatchValuesIteratorFromIterator<std::iter::Once<&'r T0>> where Self: 'r;
type LegacyBatchValuesIter<'r>
= LegacyBatchValuesIteratorFromIterator<std::iter::Once<&'r T0>>
where
Self: 'r;
fn batch_values_iter(&self) -> Self::LegacyBatchValuesIter<'_> {
std::iter::once(&self.0).into()
}
Expand Down Expand Up @@ -1775,8 +1787,11 @@ impl_batch_values_for_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15; 16);

// Every &impl BatchValues should also implement BatchValues
impl<'a, T: LegacyBatchValues + ?Sized> LegacyBatchValues for &'a T {
type LegacyBatchValuesIter<'r> = <T as LegacyBatchValues>::LegacyBatchValuesIter<'r> where Self: 'r;
impl<T: LegacyBatchValues + ?Sized> LegacyBatchValues for &T {
type LegacyBatchValuesIter<'r>
= <T as LegacyBatchValues>::LegacyBatchValuesIter<'r>
where
Self: 'r;
fn batch_values_iter(&self) -> Self::LegacyBatchValuesIter<'_> {
<T as LegacyBatchValues>::batch_values_iter(*self)
}
Expand Down Expand Up @@ -1806,8 +1821,10 @@ impl<'f, T: LegacyBatchValues> LegacyBatchValuesFirstSerialized<'f, T> {
}

impl<'f, BV: LegacyBatchValues> LegacyBatchValues for LegacyBatchValuesFirstSerialized<'f, BV> {
type LegacyBatchValuesIter<'r> =
LegacyBatchValuesFirstSerialized<'f, <BV as LegacyBatchValues>::LegacyBatchValuesIter<'r>> where Self: 'r;
type LegacyBatchValuesIter<'r>
= LegacyBatchValuesFirstSerialized<'f, <BV as LegacyBatchValues>::LegacyBatchValuesIter<'r>>
where
Self: 'r;
fn batch_values_iter(&self) -> Self::LegacyBatchValuesIter<'_> {
LegacyBatchValuesFirstSerialized {
first: self.first,
Expand Down
6 changes: 5 additions & 1 deletion scylla-cql/src/types/deserialize/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,12 @@ mod tests {
fn lend_next(&mut self) -> Option<Result<Self::Item<'_>, DeserializationError>>;
}

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

Expand Down
30 changes: 23 additions & 7 deletions scylla-cql/src/types/serialize/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ where
IT: Iterator<Item = &'sr SR> + Clone,
SR: SerializeRow + 'sr,
{
type BatchValuesIter<'r> = BatchValuesIteratorFromIterator<IT> where Self: 'r;
type BatchValuesIter<'r>
= BatchValuesIteratorFromIterator<IT>
where
Self: 'r;

#[inline]
fn batch_values_iter(&self) -> Self::BatchValuesIter<'_> {
Expand All @@ -176,7 +179,10 @@ where

// Implement BatchValues for slices of SerializeRow types
impl<T: SerializeRow> BatchValues for [T] {
type BatchValuesIter<'r> = BatchValuesIteratorFromIterator<std::slice::Iter<'r, T>> where Self: 'r;
type BatchValuesIter<'r>
= BatchValuesIteratorFromIterator<std::slice::Iter<'r, T>>
where
Self: 'r;

#[inline]
fn batch_values_iter(&self) -> Self::BatchValuesIter<'_> {
Expand All @@ -186,7 +192,10 @@ impl<T: SerializeRow> BatchValues for [T] {

// Implement BatchValues for Vec<SerializeRow>
impl<T: SerializeRow> BatchValues for Vec<T> {
type BatchValuesIter<'r> = BatchValuesIteratorFromIterator<std::slice::Iter<'r, T>> where Self: 'r;
type BatchValuesIter<'r>
= BatchValuesIteratorFromIterator<std::slice::Iter<'r, T>>
where
Self: 'r;

#[inline]
fn batch_values_iter(&self) -> Self::BatchValuesIter<'_> {
Expand All @@ -197,7 +206,10 @@ impl<T: SerializeRow> BatchValues for Vec<T> {
// Here is an example implementation for (T0, )
// Further variants are done using a macro
impl<T0: SerializeRow> BatchValues for (T0,) {
type BatchValuesIter<'r> = BatchValuesIteratorFromIterator<std::iter::Once<&'r T0>> where Self: 'r;
type BatchValuesIter<'r>
= BatchValuesIteratorFromIterator<std::iter::Once<&'r T0>>
where
Self: 'r;

#[inline]
fn batch_values_iter(&self) -> Self::BatchValuesIter<'_> {
Expand Down Expand Up @@ -302,8 +314,11 @@ impl_batch_values_for_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15; 16);

// Every &impl BatchValues should also implement BatchValues
impl<'a, T: BatchValues + ?Sized> BatchValues for &'a T {
type BatchValuesIter<'r> = <T as BatchValues>::BatchValuesIter<'r> where Self: 'r;
impl<T: BatchValues + ?Sized> BatchValues for &T {
type BatchValuesIter<'r>
= <T as BatchValues>::BatchValuesIter<'r>
where
Self: 'r;

#[inline]
fn batch_values_iter(&self) -> Self::BatchValuesIter<'_> {
Expand All @@ -323,7 +338,8 @@ impl<T> BatchValues for LegacyBatchValuesAdapter<T>
where
T: LegacyBatchValues,
{
type BatchValuesIter<'r> = LegacyBatchValuesIteratorAdapter<T::LegacyBatchValuesIter<'r>>
type BatchValuesIter<'r>
= LegacyBatchValuesIteratorAdapter<T::LegacyBatchValuesIter<'r>>
where
Self: 'r;

Expand Down
6 changes: 4 additions & 2 deletions scylla-cql/src/types/serialize/raw_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ pub trait RawBatchValuesIterator<'a> {

// An implementation used by `scylla-proxy`
impl RawBatchValues for Vec<SerializedValues> {
type RawBatchValuesIter<'r> = std::slice::Iter<'r, SerializedValues>
type RawBatchValuesIter<'r>
= std::slice::Iter<'r, SerializedValues>
where
Self: 'r;

Expand Down Expand Up @@ -117,7 +118,8 @@ where
BV: BatchValues,
CTX: Iterator<Item = RowSerializationContext<'ctx>> + Clone,
{
type RawBatchValuesIter<'r> = RawBatchValuesIteratorAdapter<BV::BatchValuesIter<'r>, CTX>
type RawBatchValuesIter<'r>
= RawBatchValuesIteratorAdapter<BV::BatchValuesIter<'r>, CTX>
where
Self: 'r;

Expand Down
2 changes: 1 addition & 1 deletion scylla-cql/src/types/serialize/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl SerializeRow for LegacySerializedValues {
fallback_impl_contents!();
}

impl<'b> SerializeRow for Cow<'b, LegacySerializedValues> {
impl SerializeRow for Cow<'_, LegacySerializedValues> {
fallback_impl_contents!();
}

Expand Down
2 changes: 1 addition & 1 deletion scylla-cql/src/types/serialize/writers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub struct WrittenCellProof<'buf> {
_phantom: std::marker::PhantomData<*mut &'buf ()>,
}

impl<'buf> WrittenCellProof<'buf> {
impl WrittenCellProof<'_> {
/// A shorthand for creating the proof.
///
/// Do not make it public! It's important that only the row writer defined
Expand Down
8 changes: 4 additions & 4 deletions scylla-macros/src/deserialize/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl StructDesc {

struct TypeCheckAssumeOrderGenerator<'sd>(&'sd StructDesc);

impl<'sd> TypeCheckAssumeOrderGenerator<'sd> {
impl TypeCheckAssumeOrderGenerator<'_> {
fn generate_name_verification(
&self,
field_index: usize, // These two indices can be different because of `skip` attribute
Expand Down Expand Up @@ -267,7 +267,7 @@ impl<'sd> TypeCheckAssumeOrderGenerator<'sd> {

struct DeserializeAssumeOrderGenerator<'sd>(&'sd StructDesc);

impl<'sd> DeserializeAssumeOrderGenerator<'sd> {
impl DeserializeAssumeOrderGenerator<'_> {
fn generate_finalize_field(&self, field_index: usize, field: &Field) -> syn::Expr {
if field.skip {
// Skipped fields are initialized with Default::default()
Expand Down Expand Up @@ -335,7 +335,7 @@ impl<'sd> DeserializeAssumeOrderGenerator<'sd> {

struct TypeCheckUnorderedGenerator<'sd>(&'sd StructDesc);

impl<'sd> TypeCheckUnorderedGenerator<'sd> {
impl TypeCheckUnorderedGenerator<'_> {
// An identifier for a bool variable that represents whether given
// field was already visited during type check
fn visited_flag_variable(field: &Field) -> syn::Ident {
Expand Down Expand Up @@ -480,7 +480,7 @@ impl<'sd> TypeCheckUnorderedGenerator<'sd> {

struct DeserializeUnorderedGenerator<'sd>(&'sd StructDesc);

impl<'sd> DeserializeUnorderedGenerator<'sd> {
impl DeserializeUnorderedGenerator<'_> {
// An identifier for a variable that is meant to store the parsed variable
// before being ultimately moved to the struct on deserialize
fn deserialize_field_variable(field: &Field) -> syn::Ident {
Expand Down
8 changes: 4 additions & 4 deletions scylla-macros/src/deserialize/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl StructDesc {

struct TypeCheckAssumeOrderGenerator<'sd>(&'sd StructDesc);

impl<'sd> TypeCheckAssumeOrderGenerator<'sd> {
impl TypeCheckAssumeOrderGenerator<'_> {
// Generates name and type validation for given Rust struct's field.
fn generate_field_validation(&self, rust_field_idx: usize, field: &Field) -> syn::Expr {
let macro_internal = self.0.struct_attrs().macro_internal_path();
Expand Down Expand Up @@ -398,7 +398,7 @@ impl<'sd> TypeCheckAssumeOrderGenerator<'sd> {

struct DeserializeAssumeOrderGenerator<'sd>(&'sd StructDesc);

impl<'sd> DeserializeAssumeOrderGenerator<'sd> {
impl DeserializeAssumeOrderGenerator<'_> {
fn generate_finalize_field(&self, field: &Field) -> syn::Expr {
if field.skip {
// Skipped fields are initialized with Default::default()
Expand Down Expand Up @@ -566,7 +566,7 @@ impl<'sd> DeserializeAssumeOrderGenerator<'sd> {

struct TypeCheckUnorderedGenerator<'sd>(&'sd StructDesc);

impl<'sd> TypeCheckUnorderedGenerator<'sd> {
impl TypeCheckUnorderedGenerator<'_> {
// An identifier for a bool variable that represents whether given
// field was already visited during type check
fn visited_flag_variable(field: &Field) -> syn::Ident {
Expand Down Expand Up @@ -730,7 +730,7 @@ impl<'sd> TypeCheckUnorderedGenerator<'sd> {

struct DeserializeUnorderedGenerator<'sd>(&'sd StructDesc);

impl<'sd> DeserializeUnorderedGenerator<'sd> {
impl DeserializeUnorderedGenerator<'_> {
/// An identifier for a variable that is meant to store the parsed variable
/// before being ultimately moved to the struct on deserialize.
fn deserialize_field_variable(field: &Field) -> syn::Ident {
Expand Down
4 changes: 2 additions & 2 deletions scylla-macros/src/serialize/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ struct ColumnSortingGenerator<'a> {
ctx: &'a Context,
}

impl<'a> Generator for ColumnSortingGenerator<'a> {
impl Generator for ColumnSortingGenerator<'_> {
fn generate_serialize(&self) -> syn::TraitItemFn {
// Need to:
// - Check that all required columns are there and no more
Expand Down Expand Up @@ -317,7 +317,7 @@ struct ColumnOrderedGenerator<'a> {
ctx: &'a Context,
}

impl<'a> Generator for ColumnOrderedGenerator<'a> {
impl Generator for ColumnOrderedGenerator<'_> {
fn generate_serialize(&self) -> syn::TraitItemFn {
let mut statements: Vec<syn::Stmt> = Vec::new();

Expand Down
4 changes: 2 additions & 2 deletions scylla-macros/src/serialize/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ struct FieldSortingGenerator<'a> {
ctx: &'a Context,
}

impl<'a> Generator for FieldSortingGenerator<'a> {
impl Generator for FieldSortingGenerator<'_> {
fn generate_serialize(&self) -> syn::TraitItemFn {
// Need to:
// - Check that all required fields are there and no more
Expand Down Expand Up @@ -449,7 +449,7 @@ struct FieldOrderedGenerator<'a> {
ctx: &'a Context,
}

impl<'a> Generator for FieldOrderedGenerator<'a> {
impl Generator for FieldOrderedGenerator<'_> {
fn generate_serialize(&self) -> syn::TraitItemFn {
let mut statements: Vec<syn::Stmt> = Vec::new();

Expand Down
Loading

0 comments on commit 49c342e

Please sign in to comment.