Skip to content

Commit 5befbcc

Browse files
chore(clippy): add workspace lints string_slice, await_holding_lock, let_underscore_must_use (#25669)
Co-authored-by: Thomas <thomas.schneider@datadoghq.com>
1 parent 5397fe8 commit 5befbcc

98 files changed

Lines changed: 409 additions & 202 deletions

File tree

Some content is hidden

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

Cargo.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ default-run = "vector"
1212
autobenches = false # our benchmarks are not runnable on their own either way
1313
# Minimum supported rust version
1414
# See docs/DEVELOPING.md for policy
15-
rust-version = "1.92"
15+
rust-version = "1.95"
1616

1717
[[bin]]
1818
name = "vector"
@@ -47,8 +47,8 @@ lto = "fat"
4747
[profile.bench]
4848
debug = true
4949

50-
[lints.rust]
51-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] }
50+
[lints]
51+
workspace = true
5252

5353
[package.metadata.deb]
5454
name = "vector"
@@ -136,6 +136,15 @@ members = [
136136
"vdev",
137137
]
138138

139+
[workspace.lints.rust]
140+
# 'cfg(tokio_unstable)' used in vector; 'cfg(ddsketch_extended)' used in vector-core
141+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)', 'cfg(ddsketch_extended)'] }
142+
143+
[workspace.lints.clippy]
144+
string_slice = "warn"
145+
await_holding_lock = "warn"
146+
let_underscore_must_use = "warn"
147+
139148
[workspace.dependencies]
140149
antithesis-instrumentation = { version = "0.1", default-features = false, features = [] }
141150
antithesis_sdk = { version = "0.2", default-features = false, features = [] }

lib/codecs/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ authors = ["Vector Contributors <vector@datadoghq.com>"]
55
edition = "2024"
66
publish = false
77

8-
[lints.clippy]
9-
unwrap-used = "deny"
8+
[lints]
9+
workspace = true
1010

1111
[[bin]]
1212
name = "generate-avro-fixtures"

lib/codecs/src/encoding/format/parquet.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Derivative's Debug impl generates 'let _ = field.fmt(f)' which triggers this lint.
2+
#![allow(clippy::let_underscore_must_use)]
3+
14
//! Parquet batch format codec for batched event encoding
25
//!
36
//! Provides Apache Parquet format encoding with schema file support and auto-inference.

lib/codecs/src/encoding/format/syslog.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use lookup::lookup_v2::ConfigTargetPath;
44
use serde_json;
55
use std::borrow::Cow;
66
use std::collections::BTreeMap;
7-
use std::fmt::Write;
87
use std::str::FromStr;
98
use strum::{EnumString, FromRepr, VariantNames};
109
use tokio_util::codec::Encoder;
@@ -235,8 +234,9 @@ where
235234
None => Cow::Borrowed(s), // All valid, zero allocation
236235
Some((first_invalid_idx, _)) => {
237236
let mut result = String::with_capacity(s.len());
238-
result.push_str(&s[..first_invalid_idx]); // Copy valid prefix
239-
for c in s[first_invalid_idx..].chars() {
237+
let (valid_prefix, remainder) = s.split_at(first_invalid_idx);
238+
result.push_str(valid_prefix);
239+
for c in remainder.chars() {
240240
result.push(if is_valid(c) { c } else { '_' });
241241
}
242242

@@ -320,7 +320,7 @@ impl SyslogMessage {
320320
fn encode(&self, rfc: &SyslogRFC) -> String {
321321
let mut result = String::with_capacity(256);
322322

323-
let _ = write!(result, "{}", self.pri.encode());
323+
result.push_str(&self.pri.encode().to_string());
324324

325325
if *rfc == SyslogRFC::Rfc5424 {
326326
result.push_str(SYSLOG_V1);
@@ -329,7 +329,7 @@ impl SyslogMessage {
329329

330330
match rfc {
331331
SyslogRFC::Rfc3164 => {
332-
let _ = write!(result, "{} ", self.timestamp.format("%b %e %H:%M:%S"));
332+
result.push_str(&format!("{} ", self.timestamp.format("%b %e %H:%M:%S")));
333333
}
334334
SyslogRFC::Rfc5424 => {
335335
result.push_str(
@@ -435,12 +435,12 @@ impl StructuredData {
435435
self.elements
436436
.iter()
437437
.fold(String::new(), |mut acc, (sd_id, sd_params)| {
438-
let _ = write!(acc, "[{sd_id}");
438+
acc.push_str(&format!("[{sd_id}"));
439439
for (key, value) in sd_params {
440440
let esc_val = escape_sd_value(value);
441-
let _ = write!(acc, " {key}=\"{esc_val}\"");
441+
acc.push_str(&format!(" {key}=\"{esc_val}\""));
442442
}
443-
let _ = write!(acc, "]");
443+
acc.push(']');
444444
acc
445445
})
446446
}

lib/codecs/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
#![deny(missing_docs)]
55
#![deny(warnings)]
6+
#![deny(clippy::unwrap_used)]
67

78
mod common;
89
mod decoder_framed_read;

lib/dnsmsg-parser/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ edition = "2024"
66
publish = false
77
license = "MIT"
88

9-
[lints.clippy]
10-
unwrap-used = "forbid"
9+
[lints]
10+
workspace = true
1111

1212
[dependencies]
1313
data-encoding = "2.10"

lib/dnsmsg-parser/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![deny(warnings)]
2+
#![deny(clippy::unwrap_used)]
23
#![warn(
34
missing_debug_implementations,
45
rust_2018_idioms,

lib/docs-renderer/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ authors = ["Vector Contributors <vector@datadoghq.com>"]
55
edition = "2024"
66
publish = false
77

8+
[lints]
9+
workspace = true
10+
811
[dependencies]
912
anyhow.workspace = true
1013
serde.workspace = true

lib/fakedata/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ edition = "2024"
66
publish = false
77
license = "MPL-2.0"
88

9+
[lints]
10+
workspace = true
11+
912
[dependencies]
1013
chrono.workspace = true
1114
rand.workspace = true

lib/file-source-common/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ edition = "2024"
66
publish = false
77
license = "MIT"
88

9+
[lints]
10+
workspace = true
11+
912
[target.'cfg(windows)'.dependencies]
1013
libc.workspace = true
1114
winapi = { version = "0.3", features = ["winioctl"] }

0 commit comments

Comments
 (0)