Skip to content

Commit f679686

Browse files
committed
Rust 1.85: Use async closure syntax.
Note: This causes type inference failures, requiring us to specify the closures’ parameter types explicitly. I gather from reading issue <rust-lang/rust#127781> that this may be rectified by using native `AsyncFnOnce` syntax, but that currently cannot specify the `+ Send + 'static` bound without also using `return_type_notation`, which cannot yet be used upon `F: FnOnce()` bounds, as opposed to non-`Fn` trait bounds.
1 parent a67d968 commit f679686

File tree

9 files changed

+25
-27
lines changed

9 files changed

+25
-27
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ resolver = "2"
4343
# When changing any of these values, be sure to also update the non-workspace packages
4444
# as listed above, if applicable.
4545
edition = "2021"
46-
rust-version = "1.84"
46+
rust-version = "1.85"
4747
license = "MIT OR Apache-2.0"
4848
authors = ["Kevin Reid <[email protected]>"]
4949
# TODO: add homepage = "..." when we have one

all-is-cubes-desktop/src/session.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use all_is_cubes::universe::Universe;
99
use all_is_cubes::universe::UniverseStepInfo;
1010
use all_is_cubes::util::ErrorChain;
1111
use all_is_cubes_render::camera::Viewport;
12-
use all_is_cubes_ui::apps::ExitMainTask;
12+
use all_is_cubes_ui::apps::{ExitMainTask, MainTaskContext};
1313

1414
use crate::Session;
1515

@@ -145,25 +145,26 @@ impl<Ren, Win: crate::glue::Window> DesktopSession<Ren, Win> {
145145

146146
// TODO: Also make a way to do this that isn't replacing the main task,
147147
// or that defines a way for the existing main task to coordinate.
148-
self.session.set_main_task(move |mut ctx| async move {
149-
// TODO: Offer confirmation before replacing the current universe.
150-
// TODO: Then open a progress-bar UI page while we load.
151-
152-
match loader_task.await.unwrap() {
153-
Ok(universe) => {
154-
ctx.set_universe(universe);
155-
}
156-
Err(e) => {
157-
ctx.show_modal_message(arcstr::format!(
158-
"Failed to load file '{path}':\n{e}",
159-
path = path.display(),
160-
e = ErrorChain(&e),
161-
));
148+
self.session
149+
.set_main_task(async move |mut ctx: MainTaskContext| {
150+
// TODO: Offer confirmation before replacing the current universe.
151+
// TODO: Then open a progress-bar UI page while we load.
152+
153+
match loader_task.await.unwrap() {
154+
Ok(universe) => {
155+
ctx.set_universe(universe);
156+
}
157+
Err(e) => {
158+
ctx.show_modal_message(arcstr::format!(
159+
"Failed to load file '{path}':\n{e}",
160+
path = path.display(),
161+
e = ErrorChain(&e),
162+
));
163+
}
162164
}
163-
}
164165

165-
ExitMainTask
166-
})
166+
ExitMainTask
167+
})
167168
}
168169

169170
/// Set the “fixed” window title — the portion of the title not determined by the universe,

all-is-cubes-desktop/src/startup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub fn inner_main<Ren: Renderer, Win: Window>(
8888
match *options {}
8989
}
9090

91-
dsession.session.set_main_task(|mut ctx| async move {
91+
dsession.session.set_main_task(async move |mut ctx| {
9292
let universe_result: Result<Universe, anyhow::Error> = match universe_task_future.await {
9393
// nested Results because one is template failure and the other is tokio JoinHandle failure
9494
Ok(Ok(u)) => Ok(u),

all-is-cubes-server/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
4343
tower-http = { version = "0.6.2", features = ["fs"] }
4444

4545
[dev-dependencies]
46-
async_fn_traits = { workspace = true }
4746
# Note that with default features disabled, reqwest has no TLS/SSL support.
4847
# This is usable because we are only using it to talk to the local server.
4948
reqwest = { version = "0.12.2", default-features = false }

all-is-cubes-server/tests/http.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
33
use std::process::Stdio;
44

5-
use async_fn_traits::AsyncFnOnce1;
65
use reqwest::header::HeaderValue;
76
use reqwest::Url;
87
use tokio::io::AsyncBufReadExt;
98

10-
async fn with_server<F: AsyncFnOnce1<Url, Output = ()>>(client_source: &'static str, f: F) {
9+
async fn with_server<F: AsyncFnOnce(Url)>(client_source: &'static str, f: F) {
1110
let mut server = tokio::process::Command::new(env!("CARGO_BIN_EXE_aic-server"))
1211
.arg("--client-source")
1312
.arg(client_source)

all-is-cubes-ui/src/apps/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ mod tests {
13901390
let mut cameras = session.create_cameras(listen::constant(Viewport::ARBITRARY));
13911391
session.set_main_task({
13921392
let noticed_step = noticed_step.clone();
1393-
move |mut ctx| async move {
1393+
async move |mut ctx: MainTaskContext| {
13941394
eprintln!("main task: waiting for new universe");
13951395
let new_universe = recv.await.unwrap();
13961396
ctx.set_universe(new_universe);

all-is-cubes-wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name = "all-is-cubes-wasm"
66
version = "0.9.0"
77
authors = ["Kevin Reid <[email protected]>"]
88
edition = "2021"
9-
rust-version = "1.84"
9+
rust-version = "1.85"
1010
description = "Web client for the recursive voxel game All is Cubes."
1111
# TODO: add homepage = "..." when we have one
1212
repository = "https://github.com/kpreid/all-is-cubes"

test-renderers/tests/wgpu-render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async fn main() -> test_renderers::HarnessResult {
2929
RendererId::Wgpu,
3030
test_renderers::SuiteId::Renderers,
3131
test_renderers::test_cases::all_tests,
32-
move |label| async move { get_factory(label).await.unwrap() },
32+
async move |label| get_factory(label).await.unwrap(),
3333
parallelism,
3434
)
3535
.await

0 commit comments

Comments
 (0)