Skip to content

Commit 8be26af

Browse files
committed
Clippy fixes
Fixes came from new rust version and not from the changes in this branch
1 parent 1b56dff commit 8be26af

4 files changed

Lines changed: 21 additions & 17 deletions

File tree

‎crates/app/src/session/service/export.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ impl SessionService {
246246
if len == 0 {
247247
Ok(Vec::new())
248248
} else {
249-
Ok(vec![0..=(len as u64 - 1)])
249+
let rng: RangeInclusive<_> = 0..=(len as u64 - 1);
250+
Ok(vec![rng])
250251
}
251252
}
252253
ExportTarget::Indexed => {

‎crates/core/dlt_tools/src/lib.rs‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ mod tests {
153153
assert_eq!("test3.txt", files.get(2).unwrap().name);
154154
}
155155
Err(error) => {
156-
panic!("{}", format!("{error}"));
156+
panic!("{error}");
157157
}
158158
}
159159
}
@@ -170,7 +170,7 @@ mod tests {
170170
assert_eq!(files.len(), 0);
171171
}
172172
Err(error) => {
173-
panic!("{}", format!("{error}"));
173+
panic!("{error}");
174174
}
175175
}
176176
}
@@ -195,7 +195,7 @@ mod tests {
195195
assert_eq!("test2.txt", files.first().unwrap().name);
196196
}
197197
Err(error) => {
198-
panic!("{}", format!("{error}"));
198+
panic!("{error}");
199199
}
200200
}
201201
}
@@ -217,12 +217,12 @@ mod tests {
217217
assert_eq!(size, 18);
218218
}
219219
Err(error) => {
220-
panic!("{}", format!("{error}"));
220+
panic!("{error}");
221221
}
222222
}
223223
}
224224
Err(error) => {
225-
panic!("{}", format!("{error}"));
225+
panic!("{error}");
226226
}
227227
}
228228

@@ -246,12 +246,12 @@ mod tests {
246246
assert_eq!(size, 0);
247247
}
248248
Err(error) => {
249-
panic!("{}", format!("{error}"));
249+
panic!("{error}");
250250
}
251251
}
252252
}
253253
Err(error) => {
254-
panic!("{}", format!("{error}"));
254+
panic!("{error}");
255255
}
256256
}
257257
}
@@ -279,12 +279,12 @@ mod tests {
279279
assert_eq!(size, 6);
280280
}
281281
Err(error) => {
282-
panic!("{}", format!("{error}"));
282+
panic!("{error}");
283283
}
284284
}
285285
}
286286
Err(error) => {
287-
panic!("{}", format!("{error}"));
287+
panic!("{error}");
288288
}
289289
}
290290

@@ -309,12 +309,12 @@ mod tests {
309309
assert_eq!(size, 6);
310310
}
311311
Err(error) => {
312-
panic!("{}", format!("{error}"));
312+
panic!("{error}");
313313
}
314314
}
315315
}
316316
Err(error) => {
317-
panic!("{}", format!("{error}"));
317+
panic!("{error}");
318318
}
319319
}
320320

@@ -344,12 +344,12 @@ mod tests {
344344
assert_eq!(size, 6);
345345
}
346346
Err(error) => {
347-
panic!("{}", format!("{error}"));
347+
panic!("{error}");
348348
}
349349
}
350350
}
351351
Err(error) => {
352-
panic!("{}", format!("{error}"));
352+
panic!("{error}");
353353
}
354354
}
355355

‎crates/core/processor/src/map.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl FiltersStats {
2525
}
2626

2727
pub fn increment(&mut self, alias: impl Into<String>, value: Option<u64>) {
28-
*self.stats.entry(alias.into()).or_insert(0) += value.map_or(1, |v| v);
28+
*self.stats.entry(alias.into()).or_insert(0) += value.unwrap_or(1);
2929
}
3030
}
3131

@@ -201,8 +201,8 @@ impl SearchMap {
201201
}
202202

203203
pub fn set(&mut self, matches: Option<Vec<stypes::FilterMatch>>, stats: Option<FiltersStats>) {
204-
self.matches = matches.map_or(vec![], |m| m);
205-
self.stats = stats.map_or(FiltersStats::default(), |s| s);
204+
self.matches = matches.unwrap_or_default();
205+
self.stats = stats.unwrap_or_default();
206206
}
207207

208208
pub fn append(&mut self, matches: &mut Vec<stypes::FilterMatch>) -> usize {

‎crates/core/session/src/handlers/observing/logs_writer.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ impl LogsWriter {
5656
}
5757
if !self.attachments.is_empty() {
5858
// Draining into a new vector preserves the capacity of the internal buffer.
59+
// `mem::take` would hand the allocation away and force the buffer to regrow
60+
// on each iteration.
61+
#[allow(clippy::drain_collect)]
5962
let attachments = self.attachments.drain(..).collect();
6063
self.state.add_attachments(attachments)?;
6164
}

0 commit comments

Comments
 (0)