Skip to content

Commit 538c1be

Browse files
committed
chore: disallow e bindings
1 parent 70e3758 commit 538c1be

File tree

22 files changed

+96
-87
lines changed

22 files changed

+96
-87
lines changed

.clippy.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
disallowed-names = [
2+
"e", # no single letter error bindings
3+
]
4+
disallowed-methods = [
5+
"std::cell::RefCell::default()",
6+
"std::rc::Rc::default()",
7+
]

actix-files/src/service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl FilesService {
7979

8080
let (req, _) = req.into_parts();
8181

82-
(self.renderer)(&dir, &req).unwrap_or_else(|e| ServiceResponse::from_err(e, req))
82+
(self.renderer)(&dir, &req).unwrap_or_else(|err| ServiceResponse::from_err(err, req))
8383
}
8484
}
8585

actix-http-test/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub async fn test_server_with_addr<F: ServerServiceFactory<TcpStream>>(
106106
builder.set_verify(SslVerifyMode::NONE);
107107
let _ = builder
108108
.set_alpn_protos(b"\x02h2\x08http/1.1")
109-
.map_err(|e| log::error!("Can not set alpn protocol: {:?}", e));
109+
.map_err(|err| log::error!("Can not set ALPN protocol: {err}"));
110110

111111
Connector::new()
112112
.conn_lifetime(Duration::from_secs(0))

actix-http/src/h1/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl MessageType for RequestHeadType {
313313
_ => return Err(io::Error::new(io::ErrorKind::Other, "unsupported version")),
314314
}
315315
)
316-
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
316+
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))
317317
}
318318
}
319319

@@ -433,7 +433,7 @@ impl TransferEncoding {
433433
buf.extend_from_slice(b"0\r\n\r\n");
434434
} else {
435435
writeln!(helpers::MutWriter(buf), "{:X}\r", msg.len())
436-
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
436+
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
437437

438438
buf.reserve(msg.len() + 2);
439439
buf.extend_from_slice(msg);

actix-http/src/h1/service.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,23 +480,23 @@ where
480480
let cfg = self.cfg.clone();
481481

482482
Box::pin(async move {
483-
let expect = expect
484-
.await
485-
.map_err(|e| error!("Init http expect service error: {:?}", e))?;
483+
let expect = expect.await.map_err(|err| {
484+
tracing::error!("Initialization of HTTP expect service error: {err:?}");
485+
})?;
486486

487487
let upgrade = match upgrade {
488488
Some(upgrade) => {
489-
let upgrade = upgrade
490-
.await
491-
.map_err(|e| error!("Init http upgrade service error: {:?}", e))?;
489+
let upgrade = upgrade.await.map_err(|err| {
490+
tracing::error!("Initialization of HTTP upgrade service error: {err:?}");
491+
})?;
492492
Some(upgrade)
493493
}
494494
None => None,
495495
};
496496

497497
let service = service
498498
.await
499-
.map_err(|e| error!("Init http service error: {:?}", e))?;
499+
.map_err(|err| error!("Initialization of HTTP service error: {err:?}"))?;
500500

501501
Ok(H1ServiceHandler::new(
502502
cfg,

actix-http/src/service.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -775,23 +775,23 @@ where
775775
let cfg = self.cfg.clone();
776776

777777
Box::pin(async move {
778-
let expect = expect
779-
.await
780-
.map_err(|e| error!("Init http expect service error: {:?}", e))?;
778+
let expect = expect.await.map_err(|err| {
779+
tracing::error!("Initialization of HTTP expect service error: {err:?}");
780+
})?;
781781

782782
let upgrade = match upgrade {
783783
Some(upgrade) => {
784-
let upgrade = upgrade
785-
.await
786-
.map_err(|e| error!("Init http upgrade service error: {:?}", e))?;
784+
let upgrade = upgrade.await.map_err(|err| {
785+
tracing::error!("Initialization of HTTP upgrade service error: {err:?}");
786+
})?;
787787
Some(upgrade)
788788
}
789789
None => None,
790790
};
791791

792-
let service = service
793-
.await
794-
.map_err(|e| error!("Init http service error: {:?}", e))?;
792+
let service = service.await.map_err(|err| {
793+
tracing::error!("Initialization of HTTP service error: {err:?}");
794+
})?;
795795

796796
Ok(HttpServiceHandler::new(
797797
cfg,

actix-http/src/ws/dispatcher.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ mod inner {
114114
{
115115
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
116116
match *self {
117-
DispatcherError::Service(ref e) => {
118-
write!(fmt, "DispatcherError::Service({:?})", e)
117+
DispatcherError::Service(ref err) => {
118+
write!(fmt, "DispatcherError::Service({err:?})")
119119
}
120-
DispatcherError::Encoder(ref e) => {
121-
write!(fmt, "DispatcherError::Encoder({:?})", e)
120+
DispatcherError::Encoder(ref err) => {
121+
write!(fmt, "DispatcherError::Encoder({err:?})")
122122
}
123-
DispatcherError::Decoder(ref e) => {
124-
write!(fmt, "DispatcherError::Decoder({:?})", e)
123+
DispatcherError::Decoder(ref err) => {
124+
write!(fmt, "DispatcherError::Decoder({err:?})")
125125
}
126126
}
127127
}
@@ -136,9 +136,9 @@ mod inner {
136136
{
137137
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
138138
match *self {
139-
DispatcherError::Service(ref e) => write!(fmt, "{}", e),
140-
DispatcherError::Encoder(ref e) => write!(fmt, "{:?}", e),
141-
DispatcherError::Decoder(ref e) => write!(fmt, "{:?}", e),
139+
DispatcherError::Service(ref err) => write!(fmt, "{err}"),
140+
DispatcherError::Encoder(ref err) => write!(fmt, "{err:?}"),
141+
DispatcherError::Decoder(ref err) => write!(fmt, "{err:?}"),
142142
}
143143
}
144144
}

actix-multipart-derive/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
66
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
77
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
8+
#![allow(clippy::disallowed_names)] // false positives in some macro expansions
89

910
use std::collections::HashSet;
1011

@@ -35,6 +36,7 @@ struct MultipartFormAttrs {
3536
duplicate_field: DuplicateField,
3637
}
3738

39+
#[allow(clippy::disallowed_names)] // false positive in macro expansion
3840
#[derive(FromField, Default)]
3941
#[darling(attributes(multipart), default)]
4042
struct FieldAttrs {

actix-router/src/path.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ impl<T: ResourcePath> Path<T> {
143143
for (seg_name, val) in self.segments.iter() {
144144
if name == seg_name {
145145
return match val {
146-
PathItem::Static(ref s) => Some(s),
147-
PathItem::Segment(s, e) => {
148-
Some(&self.path.path()[(*s as usize)..(*e as usize)])
146+
PathItem::Static(ref seg) => Some(seg),
147+
PathItem::Segment(start, end) => {
148+
Some(&self.path.path()[(*start as usize)..(*end as usize)])
149149
}
150150
};
151151
}
@@ -193,8 +193,10 @@ impl<'a, T: ResourcePath> Iterator for PathIter<'a, T> {
193193
if self.idx < self.params.segment_count() {
194194
let idx = self.idx;
195195
let res = match self.params.segments[idx].1 {
196-
PathItem::Static(ref s) => s,
197-
PathItem::Segment(s, e) => &self.params.path.path()[(s as usize)..(e as usize)],
196+
PathItem::Static(ref seg) => seg,
197+
PathItem::Segment(start, end) => {
198+
&self.params.path.path()[(start as usize)..(end as usize)]
199+
}
198200
};
199201
self.idx += 1;
200202
return Some((&self.params.segments[idx].0, res));
@@ -217,8 +219,8 @@ impl<T: ResourcePath> Index<usize> for Path<T> {
217219

218220
fn index(&self, idx: usize) -> &str {
219221
match self.segments[idx].1 {
220-
PathItem::Static(ref s) => s,
221-
PathItem::Segment(s, e) => &self.path.path()[(s as usize)..(e as usize)],
222+
PathItem::Static(ref seg) => seg,
223+
PathItem::Segment(start, end) => &self.path.path()[(start as usize)..(end as usize)],
222224
}
223225
}
224226
}

actix-web-actors/src/ws.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -796,11 +796,8 @@ where
796796
Some(frm) => {
797797
let msg = match frm {
798798
Frame::Text(data) => {
799-
Message::Text(ByteString::try_from(data).map_err(|e| {
800-
ProtocolError::Io(io::Error::new(
801-
io::ErrorKind::Other,
802-
format!("{}", e),
803-
))
799+
Message::Text(ByteString::try_from(data).map_err(|err| {
800+
ProtocolError::Io(io::Error::new(io::ErrorKind::Other, err))
804801
})?)
805802
}
806803
Frame::Binary(data) => Message::Binary(data),

0 commit comments

Comments
 (0)