Skip to content

Commit 65660d1

Browse files
authored
Merge pull request #274 from influxdata/crepererum/update-rust-and-fix-depr
chore: update rust, fix deprecations & lints
2 parents 64abc78 + 9bc39e6 commit 65660d1

File tree

15 files changed

+55
-39
lines changed

15 files changed

+55
-39
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rskafka"
33
version = "0.6.0"
44
edition = "2024"
5-
rust-version = "1.85"
5+
rust-version = "1.88"
66
license = "MIT OR Apache-2.0"
77
readme = "README.md"
88
keywords = [

fuzz/fuzz_targets/protocol_reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn driver(data: &[u8]) -> Result<(), Error> {
104104
api_key,
105105
api_version,
106106
),
107-
_ => Err(format!("Fuzzing not implemented for: {:?}", api_key).into()),
107+
_ => Err(format!("Fuzzing not implemented for: {api_key:?}").into()),
108108
}
109109
}
110110

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.85"
2+
channel = "1.88"
33
components = [ "rustfmt", "clippy" ]

src/backoff.rs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ impl Iterator for Backoff {
175175
#[cfg(test)]
176176
mod tests {
177177
use super::*;
178-
use rand::rngs::mock::StepRng;
179178

180179
#[test]
181180
fn test_backoff() {
@@ -190,18 +189,18 @@ mod tests {
190189
deadline: None,
191190
};
192191

193-
let assert_fuzzy_eq = |a: f64, b: f64| assert!((b - a).abs() < 0.0001, "{} != {}", a, b);
192+
let assert_fuzzy_eq = |a: f64, b: f64| assert!((b - a).abs() < 0.0001, "{a} != {b}");
194193

195194
// Create a static rng that takes the minimum of the range
196-
let rng = Box::new(StepRng::new(0, 0));
195+
let rng = Box::new(ConstantRng::new(0));
197196
let mut backoff = Backoff::new_with_rng(&config, Some(rng));
198197

199198
for _ in 0..20 {
200199
assert_eq!(backoff.next().unwrap().as_secs_f64(), init_backoff_secs);
201200
}
202201

203202
// Create a static rng that takes the maximum of the range
204-
let rng = Box::new(StepRng::new(u64::MAX, 0));
203+
let rng = Box::new(ConstantRng::new(u64::MAX));
205204
let mut backoff = Backoff::new_with_rng(&config, Some(rng));
206205

207206
for i in 0..20 {
@@ -210,7 +209,7 @@ mod tests {
210209
}
211210

212211
// Create a static rng that takes the mid point of the range
213-
let rng = Box::new(StepRng::new(u64::MAX / 2, 0));
212+
let rng = Box::new(ConstantRng::new(u64::MAX / 2));
214213
let mut backoff = Backoff::new_with_rng(&config, Some(rng));
215214

216215
let mut value = init_backoff_secs;
@@ -221,7 +220,7 @@ mod tests {
221220
}
222221

223222
// deadline
224-
let rng = Box::new(StepRng::new(u64::MAX, 0));
223+
let rng = Box::new(ConstantRng::new(u64::MAX));
225224
let deadline = Duration::from_secs_f64(init_backoff_secs);
226225
let mut backoff = Backoff::new_with_rng(
227226
&BackoffConfig {
@@ -232,4 +231,29 @@ mod tests {
232231
);
233232
assert_eq!(backoff.next(), None);
234233
}
234+
235+
/// A simple RNG that always returns the same value
236+
struct ConstantRng {
237+
value: u64,
238+
}
239+
240+
impl ConstantRng {
241+
fn new(value: u64) -> Self {
242+
Self { value }
243+
}
244+
}
245+
246+
impl RngCore for ConstantRng {
247+
fn next_u32(&mut self) -> u32 {
248+
(self.value >> 32) as u32
249+
}
250+
251+
fn next_u64(&mut self) -> u64 {
252+
self.value
253+
}
254+
255+
fn fill_bytes(&mut self, _dest: &mut [u8]) {
256+
unimplemented!()
257+
}
258+
}
235259
}

src/client/consumer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ mod tests {
448448
buffered += size;
449449
}
450450

451-
println!("Waiting up to {} ms for more data", max_wait_ms);
451+
println!("Waiting up to {max_wait_ms} ms for more data");
452452

453453
// Need to wait for more data
454454
let timeout = tokio::time::sleep(Duration::from_millis(max_wait_ms as u64)).fuse();

src/client/controller.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ impl BrokerCache for &ControllerClient {
186186
let controller_id = self.get_controller_id().await?;
187187
let broker = self.brokers.connect(controller_id).await?.ok_or_else(|| {
188188
Error::InvalidResponse(format!(
189-
"Controller {} not found in metadata response",
190-
controller_id
189+
"Controller {controller_id} not found in metadata response"
191190
))
192191
})?;
193192

src/client/partition.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,7 @@ impl BrokerCache for &PartitionClient {
450450
);
451451
}
452452
Err(Error::InvalidResponse(format!(
453-
"Partition leader {} not found in metadata response",
454-
leader
453+
"Partition leader {leader} not found in metadata response"
455454
)))
456455
}
457456
Err(e) => {
@@ -972,8 +971,7 @@ fn extract_offset(partition: ListOffsetsResponsePartition) -> Result<i64> {
972971
Some(offsets) => match offsets.len() {
973972
1 => Ok(offsets[0].0),
974973
n => Err(Error::InvalidResponse(format!(
975-
"Expected 1 offset to be returned but got {}",
976-
n
974+
"Expected 1 offset to be returned but got {n}"
977975
))),
978976
},
979977
None => Err(Error::InvalidResponse(

src/messenger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ fn sorted_ranges_repr(ranges: &HashMap<ApiKey, ApiVersionRange>) -> String {
633633
ranges.sort_by_key(|(key, _range)| *key);
634634
let ranges: Vec<_> = ranges
635635
.into_iter()
636-
.map(|(key, range)| format!("{:?}: {}", key, range))
636+
.map(|(key, range)| format!("{key:?}: {range}"))
637637
.collect();
638638
ranges.join(", ")
639639
}

src/protocol/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl From<Option<Error>> for Int16 {
357357

358358
impl std::fmt::Display for Error {
359359
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
360-
write!(f, "{:?}", self)
360+
write!(f, "{self:?}")
361361
}
362362
}
363363

src/protocol/messages/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ fn read_versioned_array<R: Read, T: ReadVersionedType<R>>(
140140
match len {
141141
-1 => Ok(None),
142142
l if l < -1 => Err(ReadVersionedError::ReadError(ReadError::Malformed(
143-
format!("Invalid negative length for array: {}", l).into(),
143+
format!("Invalid negative length for array: {l}").into(),
144144
))),
145145
_ => {
146146
let len = usize::try_from(len).map_err(ReadError::Overflow)?;

0 commit comments

Comments
 (0)