Skip to content

Commit f5e3a3a

Browse files
committed
Rust 1.84
1 parent 9281cab commit f5e3a3a

File tree

22 files changed

+30
-39
lines changed

22 files changed

+30
-39
lines changed

.bleep

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e7df08c79f6333db2821028ef00eb65ea6152a48
1+
68e54ed85ef028f1813154c46a67a2ebeb5c46ff

pingora-cache/src/eviction/lru.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ struct InsertToManager<'a, const N: usize> {
9393
lru: &'a Manager<N>,
9494
}
9595

96-
impl<'de, 'a, const N: usize> serde::de::Visitor<'de> for InsertToManager<'a, N> {
96+
impl<'de, const N: usize> serde::de::Visitor<'de> for InsertToManager<'_, N> {
9797
type Value = ();
9898

9999
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {

pingora-cache/src/eviction/simple_lru.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ struct InsertToManager<'a> {
142142
lru: &'a Manager,
143143
}
144144

145-
impl<'de, 'a> serde::de::Visitor<'de> for InsertToManager<'a> {
145+
impl<'de> serde::de::Visitor<'de> for InsertToManager<'_> {
146146
type Value = ();
147147

148148
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {

pingora-cache/src/filters.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn calculate_fresh_until(
9696

9797
let uncacheable = cache_control
9898
.as_ref()
99-
.map_or(false, |cc| cc.is_cacheable() == Cacheable::No);
99+
.is_some_and(|cc| cc.is_cacheable() == Cacheable::No);
100100
if uncacheable {
101101
return None;
102102
}

pingora-cache/src/predictor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ where
124124
return None;
125125
}
126126
// Skip certain NoCacheReason::Custom according to user
127-
Custom(reason) if self.skip_custom_reasons_fn.map_or(false, |f| f(reason)) => {
127+
Custom(reason) if self.skip_custom_reasons_fn.is_some_and(|f| f(reason)) => {
128128
return None;
129129
}
130130
Custom(_) | OriginNotCache | ResponseTooLarge => { /* mark uncacheable for these only */

pingora-core/src/connectors/http/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl Connector {
6161
}
6262
let h2_only = peer
6363
.get_peer_options()
64-
.map_or(false, |o| o.alpn.get_min_http_version() == 2)
64+
.is_some_and(|o| o.alpn.get_min_http_version() == 2)
6565
&& !self.h2.h1_is_preferred(peer);
6666
if !h2_only {
6767
// We next check the reuse pool for h1 before creating a new h2 connection.

pingora-core/src/connectors/http/v2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl Connector {
376376
self.transport
377377
.preferred_http_version
378378
.get(peer)
379-
.map_or(false, |v| matches!(v, ALPN::H1))
379+
.is_some_and(|v| matches!(v, ALPN::H1))
380380
}
381381
}
382382

pingora-core/src/protocols/http/v1/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub(super) fn is_upgrade_req(req: &RequestHeader) -> bool {
156156
pub(super) fn is_expect_continue_req(req: &RequestHeader) -> bool {
157157
req.version == http::Version::HTTP_11
158158
// https://www.rfc-editor.org/rfc/rfc9110#section-10.1.1
159-
&& req.headers.get(header::EXPECT).map_or(false, |v| {
159+
&& req.headers.get(header::EXPECT).is_some_and(|v| {
160160
v.as_bytes().eq_ignore_ascii_case(b"100-continue")
161161
})
162162
}
@@ -234,7 +234,7 @@ pub(super) fn populate_headers(
234234
if !header.name.is_empty() {
235235
header_ref.push(KVRef::new(
236236
header.name.as_ptr() as usize - base,
237-
header.name.as_bytes().len(),
237+
header.name.len(),
238238
header.value.as_ptr() as usize - base,
239239
header.value.len(),
240240
));

pingora-core/src/protocols/http/v2/client.rs

+5-15
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl Http2Session {
230230
// if response_body_reader doesn't exist, the response is not even read yet
231231
self.response_body_reader
232232
.as_ref()
233-
.map_or(false, |reader| reader.is_end_stream())
233+
.is_some_and(|reader| reader.is_end_stream())
234234
}
235235

236236
/// Check whether stream finished with error.
@@ -396,7 +396,7 @@ impl Http2Session {
396396
if let Some(err) = e.root_cause().downcast_ref::<h2::Error>() {
397397
if err.is_go_away()
398398
&& err.is_remote()
399-
&& err.reason().map_or(false, |r| r == h2::Reason::NO_ERROR)
399+
&& (err.reason() == Some(h2::Reason::NO_ERROR))
400400
{
401401
e.retry = true.into();
402402
}
@@ -416,26 +416,16 @@ impl Http2Session {
416416
5. All other errors will terminate the request
417417
*/
418418
fn handle_read_header_error(e: h2::Error) -> Box<Error> {
419-
if e.is_remote()
420-
&& e.reason()
421-
.map_or(false, |r| r == h2::Reason::HTTP_1_1_REQUIRED)
422-
{
419+
if e.is_remote() && (e.reason() == Some(h2::Reason::HTTP_1_1_REQUIRED)) {
423420
let mut err = Error::because(H2Downgrade, "while reading h2 header", e);
424421
err.retry = true.into();
425422
err
426-
} else if e.is_go_away()
427-
&& e.is_library()
428-
&& e.reason()
429-
.map_or(false, |r| r == h2::Reason::PROTOCOL_ERROR)
430-
{
423+
} else if e.is_go_away() && e.is_library() && (e.reason() == Some(h2::Reason::PROTOCOL_ERROR)) {
431424
// remote send invalid H2 responses
432425
let mut err = Error::because(InvalidH2, "while reading h2 header", e);
433426
err.retry = true.into();
434427
err
435-
} else if e.is_go_away()
436-
&& e.is_remote()
437-
&& e.reason().map_or(false, |r| r == h2::Reason::NO_ERROR)
438-
{
428+
} else if e.is_go_away() && e.is_remote() && (e.reason() == Some(h2::Reason::NO_ERROR)) {
439429
// is_go_away: retry via another connection, this connection is being teardown
440430
let mut err = Error::because(H2Error, "while reading h2 header", e);
441431
err.retry = true.into();

pingora-core/src/protocols/http/v2/server.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use std::pin::Pin;
6767
/// Calling `.await` in this object will not return until the client decides to close this stream.
6868
pub struct Idle<'a>(&'a mut HttpSession);
6969

70-
impl<'a> Future for Idle<'a> {
70+
impl Future for Idle<'_> {
7171
type Output = Result<h2::Reason>;
7272

7373
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
@@ -398,7 +398,7 @@ impl HttpSession {
398398
.request_header
399399
.headers
400400
.get(header::CONTENT_LENGTH)
401-
.map_or(false, |cl| cl.as_bytes() == b"0"))
401+
.is_some_and(|cl| cl.as_bytes() == b"0"))
402402
}
403403

404404
pub fn retry_buffer_truncated(&self) -> bool {

pingora-core/src/protocols/l4/ext.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ pub(crate) async fn connect_with<F: FnOnce(&TcpSocket) -> Result<()> + Clone>(
447447
bind_to: Option<&BindTo>,
448448
set_socket: F,
449449
) -> Result<TcpStream> {
450-
if bind_to.as_ref().map_or(false, |b| b.will_fallback()) {
450+
if bind_to.as_ref().is_some_and(|b| b.will_fallback()) {
451451
// if we see an EADDRNOTAVAIL error clear the port range and try again
452452
let connect_result = inner_connect_with(addr, bind_to, set_socket.clone()).await;
453453
if let Err(e) = connect_result.as_ref() {

pingora-core/src/server/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,14 @@ impl Server {
359359
#[cfg(all(not(debug_assertions), feature = "sentry"))]
360360
let _guard = self.sentry.as_ref().map(|opts| sentry::init(opts.clone()));
361361

362-
if self.options.as_ref().map_or(false, |o| o.test) {
362+
if self.options.as_ref().is_some_and(|o| o.test) {
363363
info!("Server Test passed, exiting");
364364
std::process::exit(0);
365365
}
366366

367367
// load fds
368368
#[cfg(unix)]
369-
match self.load_fds(self.options.as_ref().map_or(false, |o| o.upgrade)) {
369+
match self.load_fds(self.options.as_ref().is_some_and(|o| o.upgrade)) {
370370
Ok(_) => {
371371
info!("Bootstrap done");
372372
}

pingora-ketama/examples/health_aware_selector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct HealthAwareNodeSelector<'a> {
3131
node_health_repo: &'a NodeHealthRepository,
3232
}
3333

34-
impl<'a> HealthAwareNodeSelector<'a> {
34+
impl HealthAwareNodeSelector<'_> {
3535
fn new(r: Continuum, tries: usize, nhr: &NodeHealthRepository) -> HealthAwareNodeSelector {
3636
HealthAwareNodeSelector {
3737
ring: r,

pingora-load-balancing/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ pub struct LoadBalancer<S> {
322322
pub parallel_health_check: bool,
323323
}
324324

325-
impl<'a, S: BackendSelection> LoadBalancer<S>
325+
impl<S: BackendSelection> LoadBalancer<S>
326326
where
327327
S: BackendSelection + 'static,
328328
S::Iter: BackendIter,

pingora-lru/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl<'a, T> Iterator for LruUnitIter<'a, T> {
366366
}
367367
}
368368

369-
impl<'a, T> DoubleEndedIterator for LruUnitIter<'a, T> {
369+
impl<T> DoubleEndedIterator for LruUnitIter<'_, T> {
370370
fn next_back(&mut self) -> Option<Self::Item> {
371371
self.iter.next_back().map(|key| {
372372
// safe because we always items in table and list are always 1:1

pingora-lru/src/linked_list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl<'a> Iterator for LinkedListIter<'a> {
339339
}
340340
}
341341

342-
impl<'a> DoubleEndedIterator for LinkedListIter<'a> {
342+
impl DoubleEndedIterator for LinkedListIter<'_> {
343343
fn next_back(&mut self) -> Option<Self::Item> {
344344
let prev_index = self.list.prev(self.tail);
345345
if prev_index == HEAD || prev_index == NULL {

pingora-proxy/examples/grpc_web_module.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use pingora_core::{
2727
};
2828
use pingora_proxy::{ProxyHttp, Session};
2929

30-
/// This example shows how to use the gRPC-web bridge module
30+
// This example shows how to use the gRPC-web bridge module
3131

3232
pub struct GrpcWebBridgeProxy;
3333

pingora-proxy/examples/use_module.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use pingora_core::Result;
2323
use pingora_http::RequestHeader;
2424
use pingora_proxy::{ProxyHttp, Session};
2525

26-
/// This example shows how to build and import 3rd party modules
26+
// This example shows how to build and import 3rd party modules
2727

2828
/// A simple ACL to check "Authorization: basic $credential" header
2929
mod my_acl {

pingora-proxy/src/proxy_h1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl<SV> HttpProxy<SV> {
574574
* output anything yet.
575575
* Don't write 0 bytes to the network since it will be
576576
* treated as the terminating chunk */
577-
if !upstream_end_of_body && data.as_ref().map_or(false, |d| d.is_empty()) {
577+
if !upstream_end_of_body && data.as_ref().is_some_and(|d| d.is_empty()) {
578578
return Ok(false);
579579
}
580580

pingora-proxy/src/proxy_h2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ impl<SV> HttpProxy<SV> {
542542
/* it is normal to get 0 bytes because of multi-chunk parsing or request_body_filter.
543543
* Although there is no harm writing empty byte to h2, unlike h1, we ignore it
544544
* for consistency */
545-
if !end_of_body && data.as_ref().map_or(false, |d| d.is_empty()) {
545+
if !end_of_body && data.as_ref().is_some_and(|d| d.is_empty()) {
546546
return Ok(false);
547547
}
548548

pingora-proxy/src/proxy_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ pub trait ProxyHttp {
453453
// it is disconnected
454454
// or doing so is explicitly permitted by the client or origin server
455455
// (e.g. headers or an out-of-band contract)
456-
error.map_or(false, |e| e.esource() == &ErrorSource::Upstream)
456+
error.is_some_and(|e| e.esource() == &ErrorSource::Upstream)
457457
}
458458

459459
/// This filter is called when the request just established or reused a connection to the upstream

pingora-proxy/tests/utils/mock_origin.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ fn init() -> bool {
4646
process::Command::new("pkill")
4747
.args(["-F", "/tmp/pingora_mock_origin.pid"])
4848
.spawn()
49-
.unwrap();
49+
.unwrap()
50+
.wait();
5051
let _origin = thread::spawn(|| {
5152
process::Command::new("openresty")
5253
.args(["-p", &format!("{}/origin", super::conf_dir())])

0 commit comments

Comments
 (0)