Skip to content

Commit b8ff2a4

Browse files
committed
refactor: inline format args
1 parent 160fdc5 commit b8ff2a4

File tree

19 files changed

+89
-48
lines changed

19 files changed

+89
-48
lines changed

.clippy.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
disallowed-names = [
2+
"..", # defaults
3+
"e", # prefer `err`
4+
]

.cspell.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ words:
33
- actix
44
- addrs
55
- clippy
6+
- deque
7+
- itertools
68
- mptcp
79
- MSRV
810
- nonblocking
911
- oneshot
12+
- pemfile
13+
- rcgen
14+
- Rustls
1015
- rustup
16+
- spki
17+
- uring
18+
- webpki

.vscode/settings.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"rust-analyzer.cargo.features": [
3+
"accept",
4+
"actix-macros",
5+
"connect",
6+
"default",
7+
"macros",
8+
"native-tls",
9+
"openssl",
10+
"rustls",
11+
"rustls-021",
12+
"rustls-0_20",
13+
"rustls-0_20-native-roots",
14+
"rustls-0_20-webpki-roots",
15+
"rustls-0_21",
16+
"rustls-0_21-native-roots",
17+
"rustls-0_21-webpki-roots",
18+
"rustls-0_22",
19+
"rustls-0_22-native-roots",
20+
"rustls-0_22-webpki-roots",
21+
"rustls-0_23",
22+
"rustls-0_23-native-roots",
23+
"rustls-0_23-webpki-roots",
24+
"rustls-webpki-0101",
25+
"serde",
26+
"tokio-rustls-023",
27+
"tokio-rustls-024",
28+
"uri",
29+
"webpki-roots-022",
30+
"webpki-roots-025",
31+
]
32+
}

Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ opt-level = 3
3838
codegen-units = 1
3939

4040
[workspace.lints.rust]
41-
rust_2018_idioms = "deny"
41+
rust-2018-idioms = "deny"
4242
nonstandard-style = "deny"
43-
future_incompatible = "deny"
44-
missing_docs = { level = "warn", priority = -1 }
43+
future-incompatible = "deny"
44+
missing-docs = { level = "warn", priority = -1 }
45+
46+
[workspace.lints.clippy]
47+
uninlined-format-args = "warn"
48+
disallowed-names = "warn"

actix-codec/tests/test_framed_sink.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Write for Bilateral {
5757
Ok(data.len())
5858
}
5959
Some(Err(err)) => Err(err),
60-
None => panic!("unexpected write; {:?}", src),
60+
None => panic!("unexpected write; {src:?}"),
6161
}
6262
}
6363

actix-rt/src/arbiter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl Arbiter {
115115
let system_id = sys.id();
116116
let arb_id = COUNT.fetch_add(1, Ordering::Relaxed);
117117

118-
let name = format!("actix-rt|system:{}|arbiter:{}", system_id, arb_id);
118+
let name = format!("actix-rt|system:{system_id}|arbiter:{arb_id}");
119119
let (tx, rx) = mpsc::unbounded_channel();
120120

121121
let (ready_tx, ready_rx) = std::sync::mpsc::channel::<()>();

actix-rt/src/system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl SystemRunner {
187187

188188
match exit_code {
189189
0 => Ok(()),
190-
nonzero => Err(io::Error::other(format!("Non-zero exit code: {}", nonzero))),
190+
nonzero => Err(io::Error::other(format!("Non-zero exit code: {nonzero}"))),
191191
}
192192
}
193193

actix-server/src/accept.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl Accept {
130130
if let Err(err) = self.poll.poll(&mut events, self.timeout) {
131131
match err.kind() {
132132
io::ErrorKind::Interrupted => {}
133-
_ => panic!("Poll error: {}", err),
133+
_ => panic!("Poll error: {err}"),
134134
}
135135
}
136136

@@ -165,7 +165,6 @@ impl Accept {
165165
// task is done. Take care not to take the guard again inside this loop.
166166
let mut guard = self.waker_queue.guard();
167167

168-
#[allow(clippy::significant_drop_in_scrutinee)]
169168
match guard.pop_front() {
170169
// Worker notified it became available.
171170
Some(WakerInterest::WorkerAvailable(idx)) => {
@@ -455,8 +454,8 @@ impl Accept {
455454
/// All other errors will incur a timeout before next `accept()` call is attempted. The timeout is
456455
/// useful to handle resource exhaustion errors like `ENFILE` and `EMFILE`. Otherwise, it could
457456
/// enter into a temporary spin loop.
458-
fn connection_error(e: &io::Error) -> bool {
459-
e.kind() == io::ErrorKind::ConnectionRefused
460-
|| e.kind() == io::ErrorKind::ConnectionAborted
461-
|| e.kind() == io::ErrorKind::ConnectionReset
457+
fn connection_error(err: &io::Error) -> bool {
458+
err.kind() == io::ErrorKind::ConnectionRefused
459+
|| err.kind() == io::ErrorKind::ConnectionAborted
460+
|| err.kind() == io::ErrorKind::ConnectionReset
462461
}

actix-server/src/signals.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,9 @@ impl OsSignals {
9292
.filter_map(|(kind, sig)| {
9393
unix::signal(*kind)
9494
.map(|tokio_sig| (*sig, tokio_sig))
95-
.map_err(|e| {
95+
.map_err(|err| {
9696
tracing::error!(
97-
"can not initialize stream handler for {:?} err: {}",
98-
sig,
99-
e
97+
"can not initialize stream handler for {sig:?} err: {err}",
10098
)
10199
})
102100
.ok()

actix-server/src/socket.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,19 @@ impl From<StdUnixListener> for MioListener {
105105
impl fmt::Debug for MioListener {
106106
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
107107
match *self {
108-
MioListener::Tcp(ref lst) => write!(f, "{:?}", lst),
108+
MioListener::Tcp(ref lst) => write!(f, "{lst:?}"),
109109
#[cfg(unix)]
110-
MioListener::Uds(ref lst) => write!(f, "{:?}", lst),
110+
MioListener::Uds(ref lst) => write!(f, "{lst:?}"),
111111
}
112112
}
113113
}
114114

115115
impl fmt::Display for MioListener {
116116
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
117117
match *self {
118-
MioListener::Tcp(ref lst) => write!(f, "{:?}", lst),
118+
MioListener::Tcp(ref lst) => write!(f, "{lst:?}"),
119119
#[cfg(unix)]
120-
MioListener::Uds(ref lst) => write!(f, "{:?}", lst),
120+
MioListener::Uds(ref lst) => write!(f, "{lst:?}"),
121121
}
122122
}
123123
}
@@ -133,9 +133,9 @@ impl fmt::Display for SocketAddr {
133133
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
134134
match *self {
135135
Self::Unknown => write!(f, "Unknown SocketAddr"),
136-
Self::Tcp(ref addr) => write!(f, "{}", addr),
136+
Self::Tcp(ref addr) => write!(f, "{addr}"),
137137
#[cfg(unix)]
138-
Self::Uds(ref addr) => write!(f, "{:?}", addr),
138+
Self::Uds(ref addr) => write!(f, "{addr:?}"),
139139
}
140140
}
141141
}
@@ -144,9 +144,9 @@ impl fmt::Debug for SocketAddr {
144144
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
145145
match *self {
146146
Self::Unknown => write!(f, "Unknown SocketAddr"),
147-
Self::Tcp(ref addr) => write!(f, "{:?}", addr),
147+
Self::Tcp(ref addr) => write!(f, "{addr:?}"),
148148
#[cfg(unix)]
149-
Self::Uds(ref addr) => write!(f, "{:?}", addr),
149+
Self::Uds(ref addr) => write!(f, "{addr:?}"),
150150
}
151151
}
152152
}
@@ -266,14 +266,14 @@ mod tests {
266266
#[test]
267267
fn socket_addr() {
268268
let addr = SocketAddr::Tcp("127.0.0.1:8080".parse().unwrap());
269-
assert!(format!("{:?}", addr).contains("127.0.0.1:8080"));
270-
assert_eq!(format!("{}", addr), "127.0.0.1:8080");
269+
assert!(format!("{addr:?}").contains("127.0.0.1:8080"));
270+
assert_eq!(format!("{addr}"), "127.0.0.1:8080");
271271

272272
let addr: StdSocketAddr = "127.0.0.1:0".parse().unwrap();
273273
let lst = create_mio_tcp_listener(addr, 128, &MpTcp::Disabled).unwrap();
274274
let lst = MioListener::Tcp(lst);
275-
assert!(format!("{:?}", lst).contains("TcpListener"));
276-
assert!(format!("{}", lst).contains("127.0.0.1"));
275+
assert!(format!("{lst:?}").contains("TcpListener"));
276+
assert!(format!("{lst}").contains("127.0.0.1"));
277277
}
278278

279279
#[test]
@@ -283,12 +283,12 @@ mod tests {
283283
if let Ok(socket) = MioUnixListener::bind("/tmp/sock.xxxxx") {
284284
let addr = socket.local_addr().expect("Couldn't get local address");
285285
let a = SocketAddr::Uds(addr);
286-
assert!(format!("{:?}", a).contains("/tmp/sock.xxxxx"));
287-
assert!(format!("{}", a).contains("/tmp/sock.xxxxx"));
286+
assert!(format!("{a:?}").contains("/tmp/sock.xxxxx"));
287+
assert!(format!("{a}").contains("/tmp/sock.xxxxx"));
288288

289289
let lst = MioListener::Uds(socket);
290-
assert!(format!("{:?}", lst).contains("/tmp/sock.xxxxx"));
291-
assert!(format!("{}", lst).contains("/tmp/sock.xxxxx"));
290+
assert!(format!("{lst:?}").contains("/tmp/sock.xxxxx"));
291+
assert!(format!("{lst}").contains("/tmp/sock.xxxxx"));
292292
}
293293
}
294294
}

0 commit comments

Comments
 (0)