Skip to content

Commit 5a14ffe

Browse files
authored
clippy fixes (actix#2296)
1 parent 7ae132c commit 5a14ffe

File tree

7 files changed

+23
-13
lines changed

7 files changed

+23
-13
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[alias]
22
chk = "check --workspace --all-features --tests --examples --bins"
3-
lint = "clippy --workspace --tests --examples"
3+
lint = "clippy --workspace --all-features --tests --examples --bins"
44
ci-min = "hack check --workspace --no-default-features"
55
ci-min-test = "hack check --workspace --no-default-features --tests --examples"
66
ci-default = "check --workspace --bins --tests --examples"

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PR_TYPE
88

99

1010
## PR Checklist
11-
<!-- Check your PR fulfills the following items. ->>
11+
<!-- Check your PR fulfills the following items. -->
1212
<!-- For draft PRs check the boxes as you complete them. -->
1313

1414
- [ ] Tests for the changes have been added / updated.

actix-http/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ impl ServiceConfig {
104104
}
105105

106106
/// Returns the local address that this server is bound to.
107+
///
108+
/// Returns `None` for connections via UDS (Unix Domain Socket).
107109
#[inline]
108110
pub fn local_addr(&self) -> Option<net::SocketAddr> {
109111
self.0.local_addr

actix-http/src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ impl Error {
5555
Self::new(Kind::Io)
5656
}
5757

58+
// used in encoder behind feature flag so ignore unused warning
59+
#[allow(unused)]
5860
pub(crate) fn new_encoder() -> Self {
5961
Self::new(Kind::Encoder)
6062
}

src/info.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ fn first_header_value<'a>(req: &'a RequestHead, name: &'_ HeaderName) -> Option<
6565
/// [rfc7239-63]: https://datatracker.ietf.org/doc/html/rfc7239#section-6.3
6666
#[derive(Debug, Clone, Default)]
6767
pub struct ConnectionInfo {
68-
scheme: String,
6968
host: String,
70-
realip_remote_addr: Option<String>,
69+
scheme: String,
7170
remote_addr: Option<String>,
71+
realip_remote_addr: Option<String>,
7272
}
7373

7474
impl ConnectionInfo {
@@ -135,7 +135,7 @@ impl ConnectionInfo {
135135
.or_else(|| first_header_value(req, &*X_FORWARDED_HOST))
136136
.or_else(|| req.headers.get(&header::HOST)?.to_str().ok())
137137
.or_else(|| req.uri.authority().map(Authority::as_str))
138-
.unwrap_or(cfg.host())
138+
.unwrap_or_else(|| cfg.host())
139139
.to_owned();
140140

141141
let realip_remote_addr = realip_remote_addr
@@ -145,9 +145,9 @@ impl ConnectionInfo {
145145
let remote_addr = req.peer_addr.map(|addr| addr.to_string());
146146

147147
ConnectionInfo {
148-
remote_addr,
149-
scheme,
150148
host,
149+
scheme,
150+
remote_addr,
151151
realip_remote_addr,
152152
}
153153
}

src/server.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ where
295295
let mut svc = HttpService::build()
296296
.keep_alive(c.keep_alive)
297297
.client_timeout(c.client_timeout)
298+
.client_disconnect(c.client_shutdown)
298299
.local_addr(addr);
299300

300301
if let Some(handler) = on_connect_fn.clone() {
@@ -352,7 +353,8 @@ where
352353
let svc = HttpService::build()
353354
.keep_alive(c.keep_alive)
354355
.client_timeout(c.client_timeout)
355-
.client_disconnect(c.client_shutdown);
356+
.client_disconnect(c.client_shutdown)
357+
.local_addr(addr);
356358

357359
let svc = if let Some(handler) = on_connect_fn.clone() {
358360
svc.on_connect_ext(move |io: &_, ext: _| {
@@ -523,10 +525,11 @@ where
523525
addr: socket_addr,
524526
});
525527

526-
let addr = format!("actix-web-service-{:?}", lst.local_addr()?);
528+
let addr = lst.local_addr()?;
529+
let name = format!("actix-web-service-{:?}", addr);
527530
let on_connect_fn = self.on_connect_fn.clone();
528531

529-
self.builder = self.builder.listen_uds(addr, lst, move || {
532+
self.builder = self.builder.listen_uds(name, lst, move || {
530533
let c = cfg.lock().unwrap();
531534
let config = AppConfig::new(
532535
false,
@@ -537,7 +540,8 @@ where
537540
fn_service(|io: UnixStream| async { Ok((io, Protocol::Http1, None)) }).and_then({
538541
let mut svc = HttpService::build()
539542
.keep_alive(c.keep_alive)
540-
.client_timeout(c.client_timeout);
543+
.client_timeout(c.client_timeout)
544+
.client_disconnect(c.client_shutdown);
541545

542546
if let Some(handler) = on_connect_fn.clone() {
543547
svc = svc
@@ -554,8 +558,8 @@ where
554558
Ok(self)
555559
}
556560

557-
#[cfg(unix)]
558561
/// Start listening for incoming unix domain connections.
562+
#[cfg(unix)]
559563
pub fn bind_uds<A>(mut self, addr: A) -> io::Result<Self>
560564
where
561565
A: AsRef<std::path::Path>,
@@ -568,6 +572,7 @@ where
568572
let factory = self.factory.clone();
569573
let socket_addr =
570574
net::SocketAddr::new(net::IpAddr::V4(net::Ipv4Addr::new(127, 0, 0, 1)), 8080);
575+
571576
self.sockets.push(Socket {
572577
scheme: "http",
573578
addr: socket_addr,
@@ -592,6 +597,7 @@ where
592597
HttpService::build()
593598
.keep_alive(c.keep_alive)
594599
.client_timeout(c.client_timeout)
600+
.client_disconnect(c.client_shutdown)
595601
.finish(map_config(fac, move |_| config.clone())),
596602
)
597603
},

tests/test_error_propagation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl std::fmt::Display for MyError {
2323

2424
#[get("/test")]
2525
async fn test() -> Result<actix_web::HttpResponse, actix_web::error::Error> {
26-
return Err(MyError.into());
26+
Err(MyError.into())
2727
}
2828

2929
#[derive(Clone)]

0 commit comments

Comments
 (0)