Move "async move" a few characters to the left in cx.spawn() (#26758)

This is the core change:
https://github.com/zed-industries/zed/pull/26758/files#diff-044302c0d57147af17e68a0009fee3e8dcdfb4f32c27a915e70cfa80e987f765R1052

TODO:
- [x] Use AsyncFn instead of Fn() -> Future in GPUI spawn methods
- [x] Implement it in the whole app
- [x] Implement it in the debugger 
- [x] Glance at the RPC crate, and see if those box future methods can
be switched over. Answer: It can't directly, as you can't make an
AsyncFn* into a trait object. There's ways around that, but they're all
more complex than just keeping the code as is.
- [ ] Fix platform specific code

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2025-03-18 19:09:02 -07:00 committed by GitHub
parent 7f2e3fb5bd
commit 1aefa5178b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
256 changed files with 3110 additions and 3200 deletions

View file

@ -268,18 +268,18 @@ impl Session {
};
let pending_kernel = cx
.spawn(|this, mut cx| async move {
.spawn(async move |this, cx| {
let kernel = kernel.await;
match kernel {
Ok(kernel) => {
this.update(&mut cx, |session, cx| {
this.update(cx, |session, cx| {
session.kernel(Kernel::RunningKernel(kernel), cx);
})
.ok();
}
Err(err) => {
this.update(&mut cx, |session, cx| {
this.update(cx, |session, cx| {
session.kernel_errored(err.to_string(), cx);
})
.ok();
@ -463,9 +463,9 @@ impl Session {
let task = task.clone();
let message = message.clone();
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
task.await;
this.update(&mut cx, |session, cx| {
this.update(cx, |session, cx| {
session.send(message, cx).ok();
})
.ok();
@ -573,7 +573,7 @@ impl Session {
let forced = kernel.force_shutdown(window, cx);
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
let message: JupyterMessage = ShutdownRequest { restart: false }.into();
request_tx.try_send(message).ok();
@ -582,7 +582,7 @@ impl Session {
// Give the kernel a bit of time to clean up
cx.background_executor().timer(Duration::from_secs(3)).await;
this.update(&mut cx, |session, cx| {
this.update(cx, |session, cx| {
session.clear_outputs(cx);
session.kernel(Kernel::Shutdown, cx);
cx.notify();
@ -610,7 +610,7 @@ impl Session {
let forced = kernel.force_shutdown(window, cx);
cx.spawn_in(window, |this, mut cx| async move {
cx.spawn_in(window, async move |this, cx| {
// Send shutdown request with restart flag
log::debug!("restarting kernel");
let message: JupyterMessage = ShutdownRequest { restart: true }.into();
@ -623,7 +623,7 @@ impl Session {
forced.await.log_err();
// Start a new kernel
this.update_in(&mut cx, |session, window, cx| {
this.update_in(cx, |session, window, cx| {
// TODO: Differentiate between restart and restart+clear-outputs
session.clear_outputs(cx);
session.start_kernel(window, cx);