@@ -108,8 +108,8 @@ macro_rules! impl_serialize_row_for_unit {
108
108
if !ctx. columns( ) . is_empty( ) {
109
109
return Err ( mk_typck_err:: <Self >(
110
110
BuiltinTypeCheckErrorKind :: WrongColumnCount {
111
- actual : 0 ,
112
- asked_for : ctx. columns( ) . len( ) ,
111
+ rust_cols : 0 ,
112
+ cql_cols : ctx. columns( ) . len( ) ,
113
113
} ,
114
114
) ) ;
115
115
}
@@ -142,8 +142,8 @@ macro_rules! impl_serialize_row_for_slice {
142
142
if ctx. columns( ) . len( ) != self . len( ) {
143
143
return Err ( mk_typck_err:: <Self >(
144
144
BuiltinTypeCheckErrorKind :: WrongColumnCount {
145
- actual : self . len( ) ,
146
- asked_for : ctx. columns( ) . len( ) ,
145
+ rust_cols : self . len( ) ,
146
+ cql_cols : ctx. columns( ) . len( ) ,
147
147
} ,
148
148
) ) ;
149
149
}
@@ -289,8 +289,8 @@ macro_rules! impl_tuple {
289
289
[ $( $tidents) ,* ] => ( $( $tidents, ) * ) ,
290
290
_ => return Err ( mk_typck_err:: <Self >(
291
291
BuiltinTypeCheckErrorKind :: WrongColumnCount {
292
- actual : $length,
293
- asked_for : ctx. columns( ) . len( ) ,
292
+ rust_cols : $length,
293
+ cql_cols : ctx. columns( ) . len( ) ,
294
294
} ,
295
295
) ) ,
296
296
} ;
@@ -582,13 +582,13 @@ fn mk_ser_err_named(
582
582
#[ derive( Debug , Clone ) ]
583
583
#[ non_exhaustive]
584
584
pub enum BuiltinTypeCheckErrorKind {
585
- /// The Rust type expects `actual` column , but the statement requires `asked_for `.
585
+ /// The Rust type provides `rust_cols` columns , but the statement operates on `cql_cols `.
586
586
WrongColumnCount {
587
587
/// The number of values that the Rust type provides.
588
- actual : usize ,
588
+ rust_cols : usize ,
589
589
590
- /// The number of columns that the statement requires .
591
- asked_for : usize ,
590
+ /// The number of columns that the statement operates on .
591
+ cql_cols : usize ,
592
592
} ,
593
593
594
594
/// The Rust type provides a value for some column, but that column is not
@@ -618,8 +618,8 @@ pub enum BuiltinTypeCheckErrorKind {
618
618
impl Display for BuiltinTypeCheckErrorKind {
619
619
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
620
620
match self {
621
- BuiltinTypeCheckErrorKind :: WrongColumnCount { actual , asked_for } => {
622
- write ! ( f, "wrong column count: the query requires {asked_for } columns, but {actual} were provided " )
621
+ BuiltinTypeCheckErrorKind :: WrongColumnCount { rust_cols , cql_cols } => {
622
+ write ! ( f, "wrong column count: the statement operates on {cql_cols } columns, but the given rust type provides {rust_cols} " )
623
623
}
624
624
BuiltinTypeCheckErrorKind :: NoColumnWithName { name } => {
625
625
write ! (
@@ -865,6 +865,7 @@ mod tests {
865
865
} ;
866
866
867
867
use super :: SerializedValues ;
868
+ use assert_matches:: assert_matches;
868
869
use scylla_macros:: SerializeRow ;
869
870
870
871
fn col_spec ( name : & str , typ : ColumnType ) -> ColumnSpec {
@@ -1044,13 +1045,13 @@ mod tests {
1044
1045
let err = do_serialize_err ( v, & spec) ;
1045
1046
let err = get_typeck_err ( & err) ;
1046
1047
assert_eq ! ( err. rust_name, std:: any:: type_name:: <( ) >( ) ) ;
1047
- assert ! ( matches !(
1048
+ assert_matches ! (
1048
1049
err. kind,
1049
1050
BuiltinTypeCheckErrorKind :: WrongColumnCount {
1050
- actual : 0 ,
1051
- asked_for : 1 ,
1051
+ rust_cols : 0 ,
1052
+ cql_cols : 1 ,
1052
1053
}
1053
- ) ) ;
1054
+ ) ;
1054
1055
1055
1056
// Non-unit tuple
1056
1057
// Count mismatch
@@ -1059,13 +1060,13 @@ mod tests {
1059
1060
let err = do_serialize_err ( v, & spec) ;
1060
1061
let err = get_typeck_err ( & err) ;
1061
1062
assert_eq ! ( err. rust_name, std:: any:: type_name:: <( & str , ) >( ) ) ;
1062
- assert ! ( matches !(
1063
+ assert_matches ! (
1063
1064
err. kind,
1064
1065
BuiltinTypeCheckErrorKind :: WrongColumnCount {
1065
- actual : 1 ,
1066
- asked_for : 2 ,
1066
+ rust_cols : 1 ,
1067
+ cql_cols : 2 ,
1067
1068
}
1068
- ) ) ;
1069
+ ) ;
1069
1070
1070
1071
// Serialization of one of the element fails
1071
1072
let v = ( "Ala ma kota" , 123_i32 ) ;
@@ -1086,13 +1087,13 @@ mod tests {
1086
1087
let err = do_serialize_err ( v, & spec) ;
1087
1088
let err = get_typeck_err ( & err) ;
1088
1089
assert_eq ! ( err. rust_name, std:: any:: type_name:: <Vec <& str >>( ) ) ;
1089
- assert ! ( matches !(
1090
+ assert_matches ! (
1090
1091
err. kind,
1091
1092
BuiltinTypeCheckErrorKind :: WrongColumnCount {
1092
- actual : 1 ,
1093
- asked_for : 2 ,
1093
+ rust_cols : 1 ,
1094
+ cql_cols : 2 ,
1094
1095
}
1095
- ) ) ;
1096
+ ) ;
1096
1097
1097
1098
// Serialization of one of the element fails
1098
1099
let v = vec ! [ "Ala ma kota" , "Kot ma pchły" ] ;
@@ -1214,10 +1215,10 @@ mod tests {
1214
1215
} ;
1215
1216
let err = <_ as SerializeRow >:: serialize ( & row, & ctx, & mut row_writer) . unwrap_err ( ) ;
1216
1217
let err = err. 0 . downcast_ref :: < BuiltinTypeCheckError > ( ) . unwrap ( ) ;
1217
- assert ! ( matches !(
1218
+ assert_matches ! (
1218
1219
err. kind,
1219
1220
BuiltinTypeCheckErrorKind :: ValueMissingForColumn { .. }
1220
- ) ) ;
1221
+ ) ;
1221
1222
1222
1223
let spec_duplicate_column = [
1223
1224
col ( "a" , ColumnType :: Text ) ,
@@ -1232,10 +1233,7 @@ mod tests {
1232
1233
} ;
1233
1234
let err = <_ as SerializeRow >:: serialize ( & row, & ctx, & mut row_writer) . unwrap_err ( ) ;
1234
1235
let err = err. 0 . downcast_ref :: < BuiltinTypeCheckError > ( ) . unwrap ( ) ;
1235
- assert ! ( matches!(
1236
- err. kind,
1237
- BuiltinTypeCheckErrorKind :: NoColumnWithName { .. }
1238
- ) ) ;
1236
+ assert_matches ! ( err. kind, BuiltinTypeCheckErrorKind :: NoColumnWithName { .. } ) ;
1239
1237
1240
1238
let spec_wrong_type = [
1241
1239
col ( "a" , ColumnType :: Text ) ,
@@ -1248,10 +1246,10 @@ mod tests {
1248
1246
} ;
1249
1247
let err = <_ as SerializeRow >:: serialize ( & row, & ctx, & mut row_writer) . unwrap_err ( ) ;
1250
1248
let err = err. 0 . downcast_ref :: < BuiltinSerializationError > ( ) . unwrap ( ) ;
1251
- assert ! ( matches !(
1249
+ assert_matches ! (
1252
1250
err. kind,
1253
1251
BuiltinSerializationErrorKind :: ColumnSerializationFailed { .. }
1254
- ) ) ;
1252
+ ) ;
1255
1253
}
1256
1254
1257
1255
#[ derive( SerializeRow ) ]
@@ -1325,10 +1323,10 @@ mod tests {
1325
1323
let ctx = RowSerializationContext { columns : & spec } ;
1326
1324
let err = <_ as SerializeRow >:: serialize ( & row, & ctx, & mut writer) . unwrap_err ( ) ;
1327
1325
let err = err. 0 . downcast_ref :: < BuiltinTypeCheckError > ( ) . unwrap ( ) ;
1328
- assert ! ( matches !(
1326
+ assert_matches ! (
1329
1327
err. kind,
1330
1328
BuiltinTypeCheckErrorKind :: ColumnNameMismatch { .. }
1331
- ) ) ;
1329
+ ) ;
1332
1330
1333
1331
let spec_without_c = [
1334
1332
col ( "a" , ColumnType :: Text ) ,
@@ -1341,10 +1339,10 @@ mod tests {
1341
1339
} ;
1342
1340
let err = <_ as SerializeRow >:: serialize ( & row, & ctx, & mut writer) . unwrap_err ( ) ;
1343
1341
let err = err. 0 . downcast_ref :: < BuiltinTypeCheckError > ( ) . unwrap ( ) ;
1344
- assert ! ( matches !(
1342
+ assert_matches ! (
1345
1343
err. kind,
1346
1344
BuiltinTypeCheckErrorKind :: ValueMissingForColumn { .. }
1347
- ) ) ;
1345
+ ) ;
1348
1346
1349
1347
let spec_duplicate_column = [
1350
1348
col ( "a" , ColumnType :: Text ) ,
@@ -1359,10 +1357,7 @@ mod tests {
1359
1357
} ;
1360
1358
let err = <_ as SerializeRow >:: serialize ( & row, & ctx, & mut writer) . unwrap_err ( ) ;
1361
1359
let err = err. 0 . downcast_ref :: < BuiltinTypeCheckError > ( ) . unwrap ( ) ;
1362
- assert ! ( matches!(
1363
- err. kind,
1364
- BuiltinTypeCheckErrorKind :: NoColumnWithName { .. }
1365
- ) ) ;
1360
+ assert_matches ! ( err. kind, BuiltinTypeCheckErrorKind :: NoColumnWithName { .. } ) ;
1366
1361
1367
1362
let spec_wrong_type = [
1368
1363
col ( "a" , ColumnType :: Text ) ,
@@ -1375,10 +1370,10 @@ mod tests {
1375
1370
} ;
1376
1371
let err = <_ as SerializeRow >:: serialize ( & row, & ctx, & mut writer) . unwrap_err ( ) ;
1377
1372
let err = err. 0 . downcast_ref :: < BuiltinSerializationError > ( ) . unwrap ( ) ;
1378
- assert ! ( matches !(
1373
+ assert_matches ! (
1379
1374
err. kind,
1380
1375
BuiltinSerializationErrorKind :: ColumnSerializationFailed { .. }
1381
- ) ) ;
1376
+ ) ;
1382
1377
}
1383
1378
1384
1379
#[ test]
0 commit comments