Skip to content

Commit 32ac269

Browse files
authored
chore: Clippy fixes for Rust 1.88 (#1939)
1 parent 235b69d commit 32ac269

File tree

42 files changed

+154
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+154
-231
lines changed

native/core/benches/bit_util.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn criterion_benchmark(c: &mut Criterion) {
9292
for num_bytes in (1..=size_of::<u8>()).step_by(3) {
9393
let x = num_bytes;
9494
group.bench_with_input(
95-
BenchmarkId::new("get_aligned", format!("u8_num_bytes_{}", x)),
95+
BenchmarkId::new("get_aligned", format!("u8_num_bytes_{x}")),
9696
&x,
9797
|b, &x| {
9898
let mut reader: BitReader = BitReader::new_all(buffer.slice(0));
@@ -103,7 +103,7 @@ fn criterion_benchmark(c: &mut Criterion) {
103103
for num_bytes in (1..=size_of::<u32>()).step_by(3) {
104104
let x = num_bytes;
105105
group.bench_with_input(
106-
BenchmarkId::new("get_aligned", format!("u32_num_bytes_{}", x)),
106+
BenchmarkId::new("get_aligned", format!("u32_num_bytes_{x}")),
107107
&x,
108108
|b, &x| {
109109
let mut reader: BitReader = BitReader::new_all(buffer.slice(0));
@@ -114,7 +114,7 @@ fn criterion_benchmark(c: &mut Criterion) {
114114
for num_bytes in (1..=size_of::<i32>()).step_by(3) {
115115
let x = num_bytes;
116116
group.bench_with_input(
117-
BenchmarkId::new("get_aligned", format!("i32_num_bytes_{}", x)),
117+
BenchmarkId::new("get_aligned", format!("i32_num_bytes_{x}")),
118118
&x,
119119
|b, &x| {
120120
let mut reader: BitReader = BitReader::new_all(buffer.slice(0));
@@ -127,7 +127,7 @@ fn criterion_benchmark(c: &mut Criterion) {
127127
for num_bytes in (1..=size_of::<i32>()).step_by(3) {
128128
let x = num_bytes * 8;
129129
group.bench_with_input(
130-
BenchmarkId::new("get_value", format!("i32_num_bits_{}", x)),
130+
BenchmarkId::new("get_value", format!("i32_num_bits_{x}")),
131131
&x,
132132
|b, &x| {
133133
let mut reader: BitReader = BitReader::new_all(buffer.slice(0));
@@ -140,7 +140,7 @@ fn criterion_benchmark(c: &mut Criterion) {
140140
for num_bytes in (1..=8).step_by(7) {
141141
let x = num_bytes;
142142
group.bench_with_input(
143-
BenchmarkId::new("read_num_bytes_u64", format!("num_bytes_{}", x)),
143+
BenchmarkId::new("read_num_bytes_u64", format!("num_bytes_{x}")),
144144
&x,
145145
|b, &x| {
146146
b.iter(|| read_num_bytes_u64(black_box(x), black_box(buffer.as_slice())));
@@ -152,7 +152,7 @@ fn criterion_benchmark(c: &mut Criterion) {
152152
for num_bytes in (1..=4).step_by(3) {
153153
let x = num_bytes;
154154
group.bench_with_input(
155-
BenchmarkId::new("read_num_bytes_u32", format!("num_bytes_{}", x)),
155+
BenchmarkId::new("read_num_bytes_u32", format!("num_bytes_{x}")),
156156
&x,
157157
|b, &x| {
158158
b.iter(|| read_num_bytes_u32(black_box(x), black_box(buffer.as_slice())));
@@ -164,7 +164,7 @@ fn criterion_benchmark(c: &mut Criterion) {
164164
for length in (0..=64).step_by(32) {
165165
let x = length;
166166
group.bench_with_input(
167-
BenchmarkId::new("trailing_bits", format!("num_bits_{}", x)),
167+
BenchmarkId::new("trailing_bits", format!("num_bits_{x}")),
168168
&x,
169169
|b, &x| {
170170
b.iter(|| trailing_bits(black_box(1234567890), black_box(x)));

native/core/src/common/bit.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -954,8 +954,7 @@ impl BitReader {
954954
shift += 7;
955955
debug_assert!(
956956
shift <= MAX_VLQ_BYTE_LEN * 7,
957-
"Num of bytes exceed MAX_VLQ_BYTE_LEN ({})",
958-
MAX_VLQ_BYTE_LEN
957+
"Num of bytes exceed MAX_VLQ_BYTE_LEN ({MAX_VLQ_BYTE_LEN})"
959958
);
960959
if likely(byte & 0x80 == 0) {
961960
return Some(v);
@@ -1326,8 +1325,7 @@ mod tests {
13261325
(0..total).for_each(|i| {
13271326
assert!(
13281327
writer.put_value(values[i], num_bits),
1329-
"[{}]: put_value() failed",
1330-
i
1328+
"[{i}]: put_value() failed"
13311329
);
13321330
});
13331331

@@ -1479,8 +1477,7 @@ mod tests {
14791477
for i in 0..batch.len() {
14801478
assert_eq!(
14811479
batch[i], expected_values[i],
1482-
"num_bits = {}, index = {}",
1483-
num_bits, i
1480+
"num_bits = {num_bits}, index = {i}"
14841481
);
14851482
}
14861483
}
@@ -1509,11 +1506,7 @@ mod tests {
15091506
reader.get_u32_batch(batch.as_mut_ptr(), *total, num_bits);
15101507
}
15111508
for i in 0..batch.len() {
1512-
assert_eq!(
1513-
batch[i], values[i],
1514-
"num_bits = {}, index = {}",
1515-
num_bits, i
1516-
);
1509+
assert_eq!(batch[i], values[i], "num_bits = {num_bits}, index = {i}");
15171510
}
15181511
}
15191512
}
@@ -1554,14 +1547,12 @@ mod tests {
15541547
if i % 2 == 0 {
15551548
assert!(
15561549
writer.put_value(values[j] as u64, num_bits),
1557-
"[{}]: put_value() failed",
1558-
i
1550+
"[{i}]: put_value() failed"
15591551
);
15601552
} else {
15611553
assert!(
15621554
writer.put_aligned::<T>(aligned_values[j], aligned_value_byte_width),
1563-
"[{}]: put_aligned() failed",
1564-
i
1555+
"[{i}]: put_aligned() failed"
15651556
);
15661557
}
15671558
}
@@ -1599,8 +1590,7 @@ mod tests {
15991590
(0..total).for_each(|i| {
16001591
assert!(
16011592
writer.put_vlq_int(values[i] as u64),
1602-
"[{}]; put_vlq_int() failed",
1603-
i
1593+
"[{i}]; put_vlq_int() failed"
16041594
);
16051595
});
16061596

@@ -1625,8 +1615,7 @@ mod tests {
16251615
(0..total).for_each(|i| {
16261616
assert!(
16271617
writer.put_zigzag_vlq_int(values[i] as i64),
1628-
"[{}]; put_zigzag_vlq_int() failed",
1629-
i
1618+
"[{i}]; put_zigzag_vlq_int() failed"
16301619
);
16311620
});
16321621

native/core/src/common/buffer.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@ impl CometBuffer {
7575
assert_eq!(
7676
capacity % ALIGNMENT,
7777
0,
78-
"input buffer is not aligned to {} bytes",
79-
ALIGNMENT
78+
"input buffer is not aligned to {ALIGNMENT} bytes"
8079
);
8180
Self {
8281
data: NonNull::new(ptr as *mut u8).unwrap_or_else(|| {
8382
panic!(
84-
"cannot create CometBuffer from (ptr: {:?}, len: {}, capacity: {}",
85-
ptr, len, capacity
83+
"cannot create CometBuffer from (ptr: {ptr:?}, len: {len}, capacity: {capacity}"
8684
)
8785
}),
8886
len,

native/core/src/errors.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ enum StacktraceError {
439439

440440
fn to_stacktrace_string(msg: String, backtrace_string: String) -> Result<String, StacktraceError> {
441441
let mut res = String::new();
442-
write!(&mut res, "{}", msg).map_err(|error| StacktraceError::Message(error.to_string()))?;
442+
write!(&mut res, "{msg}").map_err(|error| StacktraceError::Message(error.to_string()))?;
443443

444444
// Use multi-line mode and named capture groups to identify the following stacktrace fields:
445445
// - dc = declaredClass
@@ -547,9 +547,9 @@ mod tests {
547547
.option("-Xcheck:jni")
548548
.option(class_path.as_str())
549549
.build()
550-
.unwrap_or_else(|e| panic!("{:#?}", e));
550+
.unwrap_or_else(|e| panic!("{e:#?}"));
551551

552-
let jvm = JavaVM::new(jvm_args).unwrap_or_else(|e| panic!("{:#?}", e));
552+
let jvm = JavaVM::new(jvm_args).unwrap_or_else(|e| panic!("{e:#?}"));
553553

554554
#[allow(static_mut_refs)]
555555
unsafe {
@@ -769,7 +769,7 @@ mod tests {
769769
.into();
770770

771771
let output = env
772-
.new_string(format!("Hello, {}!", input))
772+
.new_string(format!("Hello, {input}!"))
773773
.expect("Couldn't create java string!");
774774

775775
Ok(output.into_raw())
@@ -869,7 +869,7 @@ mod tests {
869869
.unwrap();
870870
let message_string = message.into();
871871
let msg_rust: String = env.get_string(&message_string).unwrap().into();
872-
println!("{}", msg_rust);
872+
println!("{msg_rust}");
873873
// Since panics result in multi-line messages which include the backtrace, just use the
874874
// first line.
875875
assert_starts_with!(msg_rust, expected_message);

native/core/src/execution/memory_pools/config.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ pub(crate) fn parse_memory_pool_config(
7171
}
7272
_ => {
7373
return Err(CometError::Config(format!(
74-
"Unsupported memory pool type for off-heap mode: {}",
75-
memory_pool_type
74+
"Unsupported memory pool type for off-heap mode: {memory_pool_type}"
7675
)))
7776
}
7877
}
@@ -95,8 +94,7 @@ pub(crate) fn parse_memory_pool_config(
9594
"unbounded" => MemoryPoolConfig::new(MemoryPoolType::Unbounded, 0),
9695
_ => {
9796
return Err(CometError::Config(format!(
98-
"Unsupported memory pool type for on-heap mode: {}",
99-
memory_pool_type
97+
"Unsupported memory pool type for on-heap mode: {memory_pool_type}"
10098
)))
10199
}
102100
}

native/core/src/execution/memory_pools/fair_pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl MemoryPool for CometFairMemoryPool {
120120
panic!("Failed to release {subtractive} bytes where only {size} bytes reserved")
121121
}
122122
self.release(subtractive)
123-
.unwrap_or_else(|_| panic!("Failed to release {} bytes", subtractive));
123+
.unwrap_or_else(|_| panic!("Failed to release {subtractive} bytes"));
124124
state.used = state.used.checked_sub(subtractive).unwrap();
125125
}
126126
}

native/core/src/execution/memory_pools/unified_pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl Drop for CometMemoryPool {
8080
fn drop(&mut self) {
8181
let used = self.used.load(Relaxed);
8282
if used != 0 {
83-
log::warn!("CometMemoryPool dropped with {} bytes still reserved", used);
83+
log::warn!("CometMemoryPool dropped with {used} bytes still reserved");
8484
}
8585
}
8686
}
@@ -95,7 +95,7 @@ impl MemoryPool for CometMemoryPool {
9595

9696
fn shrink(&self, _: &MemoryReservation, size: usize) {
9797
self.release(size)
98-
.unwrap_or_else(|_| panic!("Failed to release {} bytes", size));
98+
.unwrap_or_else(|_| panic!("Failed to release {size} bytes"));
9999
self.used.fetch_sub(size, Relaxed);
100100
}
101101

native/core/src/execution/operators/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl DisplayAs for ExpandExec {
7777
for projection in &self.projections {
7878
write!(f, "[")?;
7979
for expr in projection {
80-
write!(f, "{}, ", expr)?;
80+
write!(f, "{expr}, ")?;
8181
}
8282
write!(f, "], ")?;
8383
}

native/core/src/execution/operators/scan.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ impl ScanExec {
210210

211211
if iter.is_null() {
212212
return Err(CometError::from(ExecutionError::GeneralError(format!(
213-
"Null batch iterator object. Plan id: {}",
214-
exec_context_id
213+
"Null batch iterator object. Plan id: {exec_context_id}"
215214
))));
216215
}
217216

@@ -303,14 +302,14 @@ fn scan_schema(input_batch: &InputBatch, data_types: &[DataType]) -> SchemaRef {
303302
.map(|(idx, c)| {
304303
let datatype = ScanExec::unpack_dictionary_type(c.data_type());
305304
// We don't use the field name. Put a placeholder.
306-
Field::new(format!("col_{}", idx), datatype, true)
305+
Field::new(format!("col_{idx}"), datatype, true)
307306
})
308307
.collect::<Vec<Field>>()
309308
}
310309
_ => data_types
311310
.iter()
312311
.enumerate()
313-
.map(|(idx, dt)| Field::new(format!("col_{}", idx), dt.clone(), true))
312+
.map(|(idx, dt)| Field::new(format!("col_{idx}"), dt.clone(), true))
314313
.collect(),
315314
};
316315

0 commit comments

Comments
 (0)