Skip to content

Commit 4f67e55

Browse files
committed
Prepare for Rust 1.86
- repeat(...).take(...) -> repeat_n(...) - x + 7 / 8 -> div_ceil - match on Foo { .. } -> Foo when Foo has unit type - don't reimplement Result::ok Change-Id: Iba80316faa0524c7c26ee160abc97fa41896499e Reviewed-on: https://gerrit.readyset.name/c/readyset/+/8899 Reviewed-by: Jason Brown <[email protected]> Tested-by: Buildkite CI
1 parent 3b26ff7 commit 4f67e55

File tree

23 files changed

+77
-63
lines changed

23 files changed

+77
-63
lines changed

dataflow-expression/src/eval/builtins.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -2483,28 +2483,24 @@ mod tests {
24832483

24842484
#[test]
24852485
fn deeply_nested_array() {
2486-
use std::iter::repeat;
2487-
24882486
// Recursion limit for parsing.
24892487
let depth = 127;
24902488

2491-
let json: String = (repeat('[').take(depth))
2492-
.chain(repeat(']').take(depth))
2489+
let json: String = std::iter::repeat_n('[', depth)
2490+
.chain(std::iter::repeat_n(']', depth))
24932491
.collect();
24942492

24952493
test(&json, depth);
24962494
}
24972495

24982496
#[test]
24992497
fn deeply_nested_object() {
2500-
use std::iter::repeat;
2501-
25022498
// Recursion limit for parsing.
25032499
let depth = 127;
25042500

2505-
let json: String = (repeat("{\"a\": ").take(depth - 1))
2501+
let json: String = std::iter::repeat_n("{\"a\": ", depth - 1)
25062502
.chain(Some("{")) // innermost
2507-
.chain(repeat("}").take(depth))
2503+
.chain(std::iter::repeat_n("}", depth))
25082504
.collect();
25092505

25102506
test(&json, depth);

dataflow-expression/src/utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ pub fn normalize_json(json: &str) -> String {
6363
/// Not intended for use outside of tests.
6464
#[cfg(test)]
6565
pub fn empty_array_expr(dimensions: usize) -> String {
66-
(std::iter::repeat("array[").take(dimensions))
67-
.chain(std::iter::repeat("]").take(dimensions))
66+
std::iter::repeat_n("array[", dimensions)
67+
.chain(std::iter::repeat_n("]", dimensions))
6868
.collect()
6969
}
7070

dataflow-state/src/persistent_state/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ impl State for PersistentState {
669669
// Streamline the records by eliminating pairs that would negate each other.
670670
records.remove_deleted();
671671

672-
if records.len() == 0 && replication_offset.is_none() {
672+
if records.is_empty() && replication_offset.is_none() {
673673
return Ok(());
674674
}
675675

mysql-srv/src/params.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'a> Iterator for Params<'a> {
6363
type Item = Result<ParamValue<'a>, MsqlSrvError>;
6464
fn next(&mut self) -> Option<Self::Item> {
6565
if self.nullmap.is_none() {
66-
let nullmap_len = (self.params as usize + 7) / 8;
66+
let nullmap_len = (self.params as usize).div_ceil(8);
6767
let (nullmap, rest) = self.input.split_at(nullmap_len);
6868
self.nullmap = Some(nullmap);
6969
self.input = rest;

reader-map/src/values.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,14 @@ where
331331

332332
*cache = if insert {
333333
Some(i.unwrap_or_else(|x| x))
334-
} else if let Ok(x) = i {
335-
Some(x)
336334
} else {
337335
// Option<usize> doesn't permit us to encode for the second side "we searched for
338336
// this the first time, but didn't find it," so if the workload deletes non-
339337
// existent keys, we will repeat the search in vain the second time. But since
340338
// that's not the workload, we're okay here. (But proptests do generate deletions
341339
// of non-existent values.)
342-
None
343-
}
340+
i.ok()
341+
};
344342
}
345343

346344
/// Checks if the value is present. Used in tests only.
@@ -496,7 +494,7 @@ where
496494
{
497495
Arc::new(
498496
map.iter()
499-
.flat_map(|(wrapped, count)| std::iter::repeat(wrapped.value.clone()).take(*count))
497+
.flat_map(|(wrapped, count)| std::iter::repeat_n(wrapped.value.clone(), *count))
500498
.collect(),
501499
)
502500
}

readyset-adapter/src/utils.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::collections::{HashMap, HashSet};
22
use std::convert::{TryFrom, TryInto};
3-
use std::iter;
43

54
use itertools::Itertools;
65
use readyset_client::{ColumnSchema, Modification, Operation};
@@ -221,7 +220,7 @@ impl<'ast> Visitor<'ast> for BinopsParameterColumnsVisitor<'ast> {
221220
BinaryOperator::Equal
222221
};
223222
self.parameter_cols
224-
.extend(iter::repeat((c, op)).take(exprs.len()));
223+
.extend(std::iter::repeat_n((c, op), exprs.len()));
225224
return Ok(());
226225
}
227226
}

readyset-common/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl SizeOf for DfValue {
3535
fn deep_size_of(&self) -> usize {
3636
let inner = match self {
3737
DfValue::Text(t) => size_of_val(t) + t.as_bytes().len(),
38-
DfValue::BitVector(t) => size_of_val(t) + (t.len() + 7) / 8,
38+
DfValue::BitVector(t) => size_of_val(t) + t.len().div_ceil(8),
3939
DfValue::ByteArray(t) => size_of_val(t) + t.len(),
4040
_ => 0,
4141
};

readyset-data/src/enum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(crate) fn coerce_enum(
2727
// Char, but len is greater than current string, have to pad with whitespace
2828
let mut new_string = String::with_capacity(*l as usize);
2929
new_string += s;
30-
new_string.extend(std::iter::repeat(' ').take(*l as usize - s.len()));
30+
new_string.extend(std::iter::repeat_n(' ', *l as usize - s.len()));
3131
Ok(DfValue::from(new_string))
3232
}
3333
DfType::Char(l, ..) | DfType::VarChar(l, ..) if (*l as usize) < s.len() => {

readyset-data/src/float.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ pub(crate) fn coerce_f64(val: f64, to_ty: &DfType, from_ty: &DfType) -> ReadySet
119119
DfType::Char(l, ..) => {
120120
let mut val = val.to_string();
121121
val.truncate(l as usize);
122-
val.extend(std::iter::repeat(' ').take((l as usize).saturating_sub(val.len())));
122+
val.extend(std::iter::repeat_n(
123+
' ',
124+
(l as usize).saturating_sub(val.len()),
125+
));
123126
Ok(val.into())
124127
}
125128

@@ -134,7 +137,10 @@ pub(crate) fn coerce_f64(val: f64, to_ty: &DfType, from_ty: &DfType) -> ReadySet
134137
DfType::Binary(l) => {
135138
let mut val = val.to_string();
136139
val.truncate(l as usize);
137-
val.extend(std::iter::repeat(' ').take((l as usize).saturating_sub(val.len())));
140+
val.extend(std::iter::repeat_n(
141+
' ',
142+
(l as usize).saturating_sub(val.len()),
143+
));
138144
Ok(val.into_bytes().into())
139145
}
140146

@@ -233,7 +239,10 @@ pub(crate) fn coerce_decimal(
233239
DfType::Char(l, ..) => {
234240
let mut val = val.to_string();
235241
val.truncate(l as usize);
236-
val.extend(std::iter::repeat(' ').take((l as usize).saturating_sub(val.len())));
242+
val.extend(std::iter::repeat_n(
243+
' ',
244+
(l as usize).saturating_sub(val.len()),
245+
));
237246
Ok(val.into())
238247
}
239248

@@ -248,7 +257,10 @@ pub(crate) fn coerce_decimal(
248257
DfType::Binary(l) => {
249258
let mut val = val.to_string();
250259
val.truncate(l as usize);
251-
val.extend(std::iter::repeat(' ').take((l as usize).saturating_sub(val.len())));
260+
val.extend(std::iter::repeat_n(
261+
' ',
262+
(l as usize).saturating_sub(val.len()),
263+
));
252264
Ok(val.into_bytes().into())
253265
}
254266

readyset-data/src/integer.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ where
103103
DfType::Char(l, ..) => {
104104
let mut val = val.to_string();
105105
val.truncate(l as usize);
106-
val.extend(std::iter::repeat(' ').take((l as usize).saturating_sub(val.len())));
106+
val.extend(std::iter::repeat_n(
107+
' ',
108+
(l as usize).saturating_sub(val.len()),
109+
));
107110
Ok(val.into())
108111
}
109112

@@ -118,7 +121,10 @@ where
118121
DfType::Binary(l) => {
119122
let mut val = val.to_string();
120123
val.truncate(l as usize);
121-
val.extend(std::iter::repeat(' ').take((l as usize).saturating_sub(val.len())));
124+
val.extend(std::iter::repeat_n(
125+
' ',
126+
(l as usize).saturating_sub(val.len()),
127+
));
122128
Ok(val.into_bytes().into())
123129
}
124130

readyset-data/src/text.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ pub(crate) trait TextCoerce: Sized + Clone + Into<DfValue> {
418418
// Char, but length is greater than the current string, have to pad with whitespace
419419
let mut new_string = String::with_capacity(l as usize);
420420
new_string += str;
421-
new_string.extend(std::iter::repeat(' ').take(l as usize - str.chars().count()));
421+
new_string.extend(std::iter::repeat_n(' ', l as usize - str.chars().count()));
422422
Ok(DfValue::from_str_and_collation(
423423
new_string.as_str(),
424424
collation,
@@ -448,7 +448,7 @@ pub(crate) trait TextCoerce: Sized + Clone + Into<DfValue> {
448448
// Binary is longer than string, pad with zero bytes
449449
let mut new_vec = Vec::with_capacity(l as usize);
450450
new_vec.extend_from_slice(str.as_bytes());
451-
new_vec.extend(std::iter::repeat(0).take(l as usize - str.len()));
451+
new_vec.extend(std::iter::repeat_n(0, l as usize - str.len()));
452452
Ok(DfValue::ByteArray(new_vec.into()))
453453
}
454454

readyset-dataflow/src/node/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ impl Node {
690690
}
691691

692692
pub fn is_source(&self) -> bool {
693-
matches!(self.inner, NodeType::Source { .. })
693+
matches!(self.inner, NodeType::Source)
694694
}
695695

696696
pub fn is_sharder(&self) -> bool {

readyset-dataflow/src/ops/grouped/aggregate.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Aggregation {
4747
dialect: &Dialect,
4848
) -> ReadySetResult<GroupedOperator<Aggregator>> {
4949
let out_ty = match &self {
50-
Aggregation::Count { .. } => DfType::BigInt,
50+
Aggregation::Count => DfType::BigInt,
5151
Aggregation::Sum => match dialect.engine() {
5252
SqlEngine::MySQL => {
5353
if over_col_ty.is_any_float() {
@@ -299,7 +299,7 @@ impl GroupedOperation for Aggregator {
299299
}
300300

301301
match self.op {
302-
Aggregation::Count { .. } => apply_count(curr?, diff),
302+
Aggregation::Count => apply_count(curr?, diff),
303303
Aggregation::Sum => apply_sum(curr?, diff),
304304
Aggregation::Avg => apply_avg(curr?, diff),
305305
Aggregation::GroupConcat { separator: _ } => internal!(
@@ -319,7 +319,7 @@ impl GroupedOperation for Aggregator {
319319
fn description(&self, detailed: bool) -> String {
320320
if !detailed {
321321
return match self.op {
322-
Aggregation::Count { .. } => "+".to_owned(),
322+
Aggregation::Count => "+".to_owned(),
323323
Aggregation::Sum => "𝛴".to_owned(),
324324
Aggregation::Avg => "Avg".to_owned(),
325325
Aggregation::GroupConcat { separator: ref s } => {
@@ -338,7 +338,7 @@ impl GroupedOperation for Aggregator {
338338
}
339339

340340
let op_string = match self.op {
341-
Aggregation::Count { .. } => "|*|".to_owned(),
341+
Aggregation::Count => "|*|".to_owned(),
342342
Aggregation::Sum => format!("𝛴({})", self.over),
343343
Aggregation::Avg => format!("Avg({})", self.over),
344344
Aggregation::GroupConcat { separator: ref s } => format!("||({}, {})", s, self.over),
@@ -371,16 +371,14 @@ impl GroupedOperation for Aggregator {
371371

372372
fn empty_value(&self) -> Option<DfValue> {
373373
match self.op {
374-
Aggregation::Count { .. } => Some(0.into()),
374+
Aggregation::Count => Some(0.into()),
375375
_ => None,
376376
}
377377
}
378378

379379
fn emit_empty(&self) -> bool {
380380
match self.op {
381-
Aggregation::Count { .. } | Aggregation::GroupConcat { .. } => {
382-
self.group_by().is_empty()
383-
}
381+
Aggregation::Count | Aggregation::GroupConcat { .. } => self.group_by().is_empty(),
384382
_ => false,
385383
}
386384
}

readyset-e2e-tests/tests/mysql_long_data.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ async fn mysql_send_long_data_inner() {
3636
rs_conn
3737
.exec_drop(
3838
"INSERT INTO t VALUES (?)",
39-
vec![Value::Bytes(Vec::from_iter(
40-
std::iter::repeat(0).take(MAX_PAYLOAD_LEN * 2),
41-
))],
39+
vec![Value::Bytes(Vec::from_iter(std::iter::repeat_n(
40+
0,
41+
MAX_PAYLOAD_LEN * 2,
42+
)))],
4243
)
4344
.await
4445
.unwrap();

readyset-mir/src/node/node_inner.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl MirNodeInner {
413413
..
414414
} => {
415415
let op_string = match *kind {
416-
Aggregation::Count { .. } => format!("|*|({})", on.name.as_str()),
416+
Aggregation::Count => format!("|*|({})", on.name.as_str()),
417417
Aggregation::Sum => format!("𝛴({})", on.name.as_str()),
418418
Aggregation::Avg => format!("AVG({})", on.name.as_str()),
419419
Aggregation::GroupConcat { separator: ref s } => {

readyset-mir/src/visualize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl GraphViz for MirNodeInner {
158158
..
159159
} => {
160160
let op_string = match kind {
161-
AggregationKind::Count { .. } => format!("\\|*\\|({})", on),
161+
AggregationKind::Count => format!("\\|*\\|({})", on),
162162
AggregationKind::Sum => format!("𝛴({})", on),
163163
AggregationKind::Avg => format!("AVG({})", on),
164164
AggregationKind::GroupConcat { separator: s } => {

readyset-psql/tests/fallback.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2713,7 +2713,7 @@ async fn drop_all_proxied_queries() {
27132713
.await
27142714
.unwrap()
27152715
.into_iter()
2716-
.last()
2716+
.next_back()
27172717
.unwrap();
27182718
assert!(matches!(
27192719
command,
@@ -2727,7 +2727,7 @@ async fn drop_all_proxied_queries() {
27272727
.await
27282728
.unwrap()
27292729
.into_iter()
2730-
.last()
2730+
.next_back()
27312731
.unwrap();
27322732
assert!(matches!(
27332733
command,
@@ -2765,7 +2765,7 @@ async fn numeric_inf_nan() {
27652765
.await
27662766
.unwrap()
27672767
.into_iter()
2768-
.last()
2768+
.next_back()
27692769
.unwrap();
27702770

27712771
// We expect to see all rows because the table was dropped since we don't support NaN/Infinity
@@ -2825,7 +2825,7 @@ async fn numeric_snapshot_nan() {
28252825
None
28262826
}
28272827
})
2828-
.last()
2828+
.next_back()
28292829
.unwrap().1;
28302830
AssertUnwindSafe(|| result)
28312831
}, then_assert: |result| {

readyset-server/src/controller/sql/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,8 @@ impl SqlToMirConverter {
15721572
/// Returns Ok if:
15731573
/// - there are no OR nodes;
15741574
/// - all comparisons are:
1575-
/// - local columns = outer column;
1576-
/// - local column = constant;
1575+
/// - local columns = outer column;
1576+
/// - local column = constant;
15771577
/// - if there is at least one comparison of the above format, then
15781578
/// the rest of the WHERE expression can be anything.
15791579
///

readyset-sql-passes/src/adapter_rewrites/autoparameterize.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{iter, mem};
1+
use std::mem;
22

33
use readyset_sql::analysis::visit_mut::{self, VisitorMut};
44
use readyset_sql::ast::{BinaryOperator, Expr, InValue, ItemPlaceholder, Literal, SelectStatement};
@@ -116,10 +116,12 @@ impl<'ast> VisitorMut<'ast> for AutoParameterizeVisitor {
116116
if self.autoparameterize_equals {
117117
let exprs = mem::replace(
118118
exprs,
119-
iter::repeat(Expr::Literal(Literal::Placeholder(
120-
ItemPlaceholder::QuestionMark,
121-
)))
122-
.take(exprs.len())
119+
std::iter::repeat_n(
120+
Expr::Literal(Literal::Placeholder(
121+
ItemPlaceholder::QuestionMark,
122+
)),
123+
exprs.len(),
124+
)
123125
.collect(),
124126
);
125127
let num_exprs = exprs.len();

replicators/src/mysql_connector/connector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ impl MySqlBinlogConnector {
874874
}
875875
Err(err) => return Err(err),
876876
Ok(action) => match action {
877-
ReplicationAction::LogPosition { .. } => {
877+
ReplicationAction::LogPosition => {
878878
continue;
879879
}
880880
_ => {

0 commit comments

Comments
 (0)