Skip to content

Commit

Permalink
serialize: polish TupleTypeCheckErrorKind::WrongElementCount
Browse files Browse the repository at this point in the history
- a bunch of typos are fixed,
- some names are changed to be more explicit.
  • Loading branch information
wprzytula committed May 21, 2024
1 parent 5c71314 commit 406128c
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions scylla-cql/src/types/serialize/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub trait SerializeCql {
/// The [`CellWriter`] provided to the method ensures that the value produced
/// will be properly framed (i.e. incorrectly written value should not
/// cause the rest of the request to be misinterpreted), but otherwise
/// the implementor of the trait is responsible for producing the a value
/// the implementor of the trait is responsible for producing the value
/// in a correct format.
fn serialize<'b>(
&self,
Expand Down Expand Up @@ -548,8 +548,8 @@ fn serialize_cql_value<'b>(
return Err(mk_typck_err::<CqlValue>(
typ,
TupleTypeCheckErrorKind::WrongElementCount {
actual: t.len(),
asked_for: fields.len(),
rust_type_el_count: t.len(),
cql_type_el_count: fields.len(),
},
));
}
Expand Down Expand Up @@ -586,7 +586,7 @@ fn fix_cql_value_name_in_err(mut err: SerializationError) -> SerializationError
}
}
None => {
// The `None` case shouldn't happen consisdering how we are using
// The `None` case shouldn't happen considering how we are using
// the function in the code now, but let's provide it here anyway
// for correctness.
if let Some(err) = err.0.downcast_ref::<BuiltinTypeCheckError>() {
Expand Down Expand Up @@ -729,8 +729,8 @@ macro_rules! impl_tuple {
_ => return Err(mk_typck_err::<Self>(
typ,
TupleTypeCheckErrorKind::WrongElementCount {
actual: $length,
asked_for: typs.len(),
rust_type_el_count: $length,
cql_type_el_count: typs.len(),
}
))
}
Expand Down Expand Up @@ -1352,10 +1352,10 @@ pub enum TupleTypeCheckErrorKind {
/// elements will be set to null.
WrongElementCount {
/// The number of elements that the Rust tuple has.
actual: usize,
rust_type_el_count: usize,

/// The number of elements that the CQL tuple type has.
asked_for: usize,
cql_type_el_count: usize,
},
}

Expand All @@ -1366,9 +1366,12 @@ impl Display for TupleTypeCheckErrorKind {
f,
"the CQL type the tuple was attempted to be serialized to is not a tuple"
),
TupleTypeCheckErrorKind::WrongElementCount { actual, asked_for } => write!(
TupleTypeCheckErrorKind::WrongElementCount {
rust_type_el_count,
cql_type_el_count,
} => write!(
f,
"wrong tuple element count: CQL type has {asked_for}, the Rust tuple has {actual}"
"wrong tuple element count: CQL type has {cql_type_el_count}, the Rust tuple has {rust_type_el_count}"
),
}
}
Expand Down Expand Up @@ -1807,8 +1810,8 @@ mod tests {
assert_matches!(
err.kind,
BuiltinTypeCheckErrorKind::TupleError(TupleTypeCheckErrorKind::WrongElementCount {
actual: 3,
asked_for: 2,
rust_type_el_count: 3,
cql_type_el_count: 2,
})
);

Expand Down Expand Up @@ -1879,8 +1882,8 @@ mod tests {
assert_matches!(
err.kind,
BuiltinTypeCheckErrorKind::TupleError(TupleTypeCheckErrorKind::WrongElementCount {
actual: 3,
asked_for: 2,
rust_type_el_count: 3,
cql_type_el_count: 2,
})
);

Expand Down

0 comments on commit 406128c

Please sign in to comment.