Skip to content

Commit dff0d95

Browse files
fisherdarlingTheJokr
authored andcommitted
chore: upgrade to rust 2024
1 parent 08c4dab commit dff0d95

File tree

7 files changed

+31
-37
lines changed

7 files changed

+31
-37
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ jobs:
141141
# Workaround for rust-lang/cargo#7732
142142
# based on tokio's ci job
143143
run: |
144-
if ! rustfmt --check --edition 2021 $(git ls-files '*.rs'); then
145-
printf "Please run \`rustfmt --edition 2021 \$(git ls-files '*.rs')\` to fix rustfmt errors.\n" >&2
144+
if ! rustfmt --check --edition 2024 $(git ls-files '*.rs'); then
145+
printf "Please run \`rustfmt --edition 2024 \$(git ls-files '*.rs')\` to fix rustfmt errors.\n" >&2
146146
exit 1
147147
fi
148148

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ members = [
55
"examples",
66
"tools/gen-syscall-enum",
77
]
8-
resolver = "2"
8+
resolver = "3"
99

1010
[workspace.package]
1111
version = "5.4.0"
1212
repository = "https://github.com/cloudflare/foundations"
13-
edition = "2021"
13+
edition = "2024"
1414
authors = ["Cloudflare"]
1515
license = "BSD-3-Clause"
1616

foundations-macros/src/metrics/mod.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,12 @@ fn metric_init(foundations: &Path, fn_: &ItemFn) -> proc_macro2::TokenStream {
317317
);
318318

319319
// Validate histogram buckets at compile time if this is a HistogramBuilder
320-
if let Some(ctor) = ctor {
321-
if let Some(path) = ctor.path.get_ident() {
322-
if path == "HistogramBuilder" {
323-
// Validate the histogram buckets
324-
if let Err(err) = validation::validate_histogram_buckets(ctor) {
325-
return err.to_compile_error();
326-
}
327-
}
328-
}
320+
if let Some(ctor) = ctor
321+
&& let Some(path) = ctor.path.get_ident()
322+
&& path == "HistogramBuilder"
323+
&& let Err(err) = validation::validate_histogram_buckets(ctor)
324+
{
325+
return err.to_compile_error();
329326
}
330327

331328
let metric_init = match ctor {

foundations/src/telemetry/driver.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use futures_util::stream::FuturesUnordered;
77
use futures_util::{FutureExt, Stream};
88
use std::future::Future;
99
use std::pin::Pin;
10-
use std::task::{Context, Poll};
10+
use std::task::{Context, Poll, ready};
1111

1212
feature_use!(cfg(feature = "telemetry-server"), {
1313
use super::server::TelemetryServerFuture;
@@ -89,25 +89,23 @@ impl Future for TelemetryDriver {
8989
type Output = BootstrapResult<()>;
9090

9191
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
92-
let mut ready_res = vec![];
92+
#[cfg_attr(not(feature = "telemetry-server"), allow(unused_mut))]
93+
let mut server_res = Poll::Ready(Ok(()));
9394

9495
#[cfg(feature = "telemetry-server")]
9596
if let Some(server_fut) = &mut self.server_fut {
96-
if let Poll::Ready(res) = Pin::new(server_fut).poll(cx) {
97-
match res {}
98-
}
97+
// This future is always pending
98+
let Poll::Pending = Pin::new(server_fut).poll(cx);
99+
server_res = Poll::Pending;
99100
}
100101

101-
let tele_futures_poll = Pin::new(&mut self.tele_futures).poll_next(cx);
102-
103-
if let Poll::Ready(Some(res)) = tele_futures_poll {
104-
ready_res.push(res);
105-
}
106-
107-
if ready_res.is_empty() {
108-
Poll::Pending
109-
} else {
110-
Poll::Ready(ready_res.into_iter().collect())
102+
loop {
103+
// Keep polling tele_futures until it becomes pending, empty, or a future errors
104+
let tele_res = ready!(Pin::new(&mut self.tele_futures).poll_next(cx)?);
105+
if tele_res.is_none() {
106+
// tele_futures is done, but we may still need to poll server_fut
107+
return server_res;
108+
}
111109
}
112110
}
113111
}

foundations/src/telemetry/metrics/internal.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,9 @@ impl Registries {
102102
};
103103

104104
let mut prefix = Cow::Borrowed(subsystem);
105-
if with_service_prefix {
106-
if let MetricsServiceName::Prefix(service) = &registries.service_name {
107-
prefix = format!("{service}_{subsystem}").into();
108-
}
105+
if with_service_prefix && let MetricsServiceName::Prefix(service) = &registries.service_name
106+
{
107+
prefix = format!("{service}_{subsystem}").into();
109108
}
110109

111110
parking_lot::RwLockWriteGuard::map(registry.write(), move |mut reg| {

foundations/src/telemetry/server/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ impl TelemetryServerFuture {
170170
#[cfg(unix)]
171171
ListenAddr::Unix(path) => {
172172
// Remove existing socket file if it exists to avoid bind errors
173-
if path.exists() {
174-
if let Err(e) = std::fs::remove_file(path) {
175-
log::warn!("failed to remove existing Unix socket file"; "path" => %path.display(), "error" => e);
176-
}
173+
if path.exists()
174+
&& let Err(e) = std::fs::remove_file(path)
175+
{
176+
log::warn!("failed to remove existing Unix socket file"; "path" => %path.display(), "error" => e);
177177
}
178178

179179
let unix_listener = UnixListener::bind(path)

tools/gen-syscall-enum/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "gen-syscall-enum"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[package.metadata.release]

0 commit comments

Comments
 (0)