Pass a reference to `TestAppContext` in tests

Antonio Scandurra created

This allows us to drop the context *after* we ran all futures to
completion and that's crucial otherwise we'll never drop entities
and/or flush effects.

Change summary

crates/client/src/channel.rs              |  20 
crates/client/src/client.rs               |  21 
crates/diagnostics/src/diagnostics.rs     |  16 
crates/editor/src/display_map.rs          |  30 
crates/editor/src/display_map/wrap_map.rs |  39 +-
crates/editor/src/editor.rs               |  82 ++--
crates/file_finder/src/file_finder.rs     |  32 +-
crates/gpui/src/app.rs                    |  28 
crates/gpui_macros/src/gpui_macros.rs     |  55 ++
crates/language/src/tests.rs              |  56 +-
crates/lsp/src/lsp.rs                     |   2 
crates/project/src/project.rs             | 216 ++++++------
crates/project/src/worktree.rs            |   6 
crates/project_panel/src/project_panel.rs |  20 
crates/rpc/src/peer.rs                    |  10 
crates/search/src/buffer_search.rs        |  78 ++--
crates/search/src/project_search.rs       |  20 
crates/server/src/db.rs                   |   6 
crates/server/src/rpc.rs                  | 395 +++++++++++-------------
crates/zed/src/zed.rs                     | 160 ++++-----
20 files changed, 623 insertions(+), 669 deletions(-)

Detailed changes

crates/client/src/channel.rs 🔗

@@ -597,7 +597,7 @@ mod tests {
     use surf::http::Response;
 
     #[gpui::test]
-    async fn test_channel_messages(mut cx: TestAppContext) {
+    async fn test_channel_messages(cx: &mut TestAppContext) {
         cx.foreground().forbid_parking();
 
         let user_id = 5;
@@ -609,7 +609,7 @@ mod tests {
         let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
 
         let channel_list = cx.add_model(|cx| ChannelList::new(user_store, client.clone(), cx));
-        channel_list.read_with(&cx, |list, _| assert_eq!(list.available_channels(), None));
+        channel_list.read_with(cx, |list, _| assert_eq!(list.available_channels(), None));
 
         // Get the available channels.
         let get_channels = server.receive::<proto::GetChannels>().await.unwrap();
@@ -625,7 +625,7 @@ mod tests {
             )
             .await;
         channel_list.next_notification(&cx).await;
-        channel_list.read_with(&cx, |list, _| {
+        channel_list.read_with(cx, |list, _| {
             assert_eq!(
                 list.available_channels().unwrap(),
                 &[ChannelDetails {
@@ -652,12 +652,12 @@ mod tests {
 
         // Join a channel and populate its existing messages.
         let channel = channel_list
-            .update(&mut cx, |list, cx| {
+            .update(cx, |list, cx| {
                 let channel_id = list.available_channels().unwrap()[0].id;
                 list.get_channel(channel_id, cx)
             })
             .unwrap();
-        channel.read_with(&cx, |channel, _| assert!(channel.messages().is_empty()));
+        channel.read_with(cx, |channel, _| assert!(channel.messages().is_empty()));
         let join_channel = server.receive::<proto::JoinChannel>().await.unwrap();
         server
             .respond(
@@ -708,7 +708,7 @@ mod tests {
                 new_count: 2,
             }
         );
-        channel.read_with(&cx, |channel, _| {
+        channel.read_with(cx, |channel, _| {
             assert_eq!(
                 channel
                     .messages_in_range(0..2)
@@ -723,7 +723,7 @@ mod tests {
 
         // Receive a new message.
         server.send(proto::ChannelMessageSent {
-            channel_id: channel.read_with(&cx, |channel, _| channel.details.id),
+            channel_id: channel.read_with(cx, |channel, _| channel.details.id),
             message: Some(proto::ChannelMessage {
                 id: 12,
                 body: "c".into(),
@@ -756,7 +756,7 @@ mod tests {
                 new_count: 1,
             }
         );
-        channel.read_with(&cx, |channel, _| {
+        channel.read_with(cx, |channel, _| {
             assert_eq!(
                 channel
                     .messages_in_range(2..3)
@@ -767,7 +767,7 @@ mod tests {
         });
 
         // Scroll up to view older messages.
-        channel.update(&mut cx, |channel, cx| {
+        channel.update(cx, |channel, cx| {
             assert!(channel.load_more_messages(cx));
         });
         let get_messages = server.receive::<proto::GetChannelMessages>().await.unwrap();
@@ -805,7 +805,7 @@ mod tests {
                 new_count: 2,
             }
         );
-        channel.read_with(&cx, |channel, _| {
+        channel.read_with(cx, |channel, _| {
             assert_eq!(
                 channel
                     .messages_in_range(0..2)

crates/client/src/client.rs 🔗

@@ -933,7 +933,7 @@ mod tests {
     use gpui::TestAppContext;
 
     #[gpui::test(iterations = 10)]
-    async fn test_heartbeat(cx: TestAppContext) {
+    async fn test_heartbeat(cx: &mut TestAppContext) {
         cx.foreground().forbid_parking();
 
         let user_id = 5;
@@ -953,7 +953,7 @@ mod tests {
     }
 
     #[gpui::test(iterations = 10)]
-    async fn test_reconnection(cx: TestAppContext) {
+    async fn test_reconnection(cx: &mut TestAppContext) {
         cx.foreground().forbid_parking();
 
         let user_id = 5;
@@ -1001,7 +1001,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_subscribing_to_entity(mut cx: TestAppContext) {
+    async fn test_subscribing_to_entity(cx: &mut TestAppContext) {
         cx.foreground().forbid_parking();
 
         let user_id = 5;
@@ -1033,14 +1033,11 @@ mod tests {
             subscription: None,
         });
 
-        let _subscription1 =
-            model1.update(&mut cx, |_, cx| client.add_model_for_remote_entity(1, cx));
-        let _subscription2 =
-            model2.update(&mut cx, |_, cx| client.add_model_for_remote_entity(2, cx));
+        let _subscription1 = model1.update(cx, |_, cx| client.add_model_for_remote_entity(1, cx));
+        let _subscription2 = model2.update(cx, |_, cx| client.add_model_for_remote_entity(2, cx));
         // Ensure dropping a subscription for the same entity type still allows receiving of
         // messages for other entity IDs of the same type.
-        let subscription3 =
-            model3.update(&mut cx, |_, cx| client.add_model_for_remote_entity(3, cx));
+        let subscription3 = model3.update(cx, |_, cx| client.add_model_for_remote_entity(3, cx));
         drop(subscription3);
 
         server.send(proto::UnshareProject { project_id: 1 });
@@ -1050,7 +1047,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_subscribing_after_dropping_subscription(mut cx: TestAppContext) {
+    async fn test_subscribing_after_dropping_subscription(cx: &mut TestAppContext) {
         cx.foreground().forbid_parking();
 
         let user_id = 5;
@@ -1078,7 +1075,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_dropping_subscription_in_handler(mut cx: TestAppContext) {
+    async fn test_dropping_subscription_in_handler(cx: &mut TestAppContext) {
         cx.foreground().forbid_parking();
 
         let user_id = 5;
@@ -1095,7 +1092,7 @@ mod tests {
                 async { Ok(()) }
             },
         );
-        model.update(&mut cx, |model, _| {
+        model.update(cx, |model, _| {
             model.subscription = Some(subscription);
         });
         server.send(proto::Ping {});

crates/diagnostics/src/diagnostics.rs 🔗

@@ -725,7 +725,7 @@ mod tests {
     use workspace::WorkspaceParams;
 
     #[gpui::test]
-    async fn test_diagnostics(mut cx: TestAppContext) {
+    async fn test_diagnostics(cx: &mut TestAppContext) {
         let params = cx.update(WorkspaceParams::test);
         let project = params.project.clone();
         let workspace = cx.add_view(0, |cx| Workspace::new(&params, cx));
@@ -760,14 +760,14 @@ mod tests {
             .await;
 
         project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/test", false, cx)
             })
             .await
             .unwrap();
 
         // Create some diagnostics
-        project.update(&mut cx, |project, cx| {
+        project.update(cx, |project, cx| {
             project
                 .update_diagnostic_entries(
                     PathBuf::from("/test/main.rs"),
@@ -856,7 +856,7 @@ mod tests {
         });
 
         view.next_notification(&cx).await;
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             let editor = view.editor.update(cx, |editor, cx| editor.snapshot(cx));
 
             assert_eq!(
@@ -920,7 +920,7 @@ mod tests {
         });
 
         // Diagnostics are added for another earlier path.
-        project.update(&mut cx, |project, cx| {
+        project.update(cx, |project, cx| {
             project.disk_based_diagnostics_started(cx);
             project
                 .update_diagnostic_entries(
@@ -944,7 +944,7 @@ mod tests {
         });
 
         view.next_notification(&cx).await;
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             let editor = view.editor.update(cx, |editor, cx| editor.snapshot(cx));
 
             assert_eq!(
@@ -1021,7 +1021,7 @@ mod tests {
         });
 
         // Diagnostics are added to the first path
-        project.update(&mut cx, |project, cx| {
+        project.update(cx, |project, cx| {
             project.disk_based_diagnostics_started(cx);
             project
                 .update_diagnostic_entries(
@@ -1059,7 +1059,7 @@ mod tests {
         });
 
         view.next_notification(&cx).await;
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             let editor = view.editor.update(cx, |editor, cx| editor.snapshot(cx));
 
             assert_eq!(

crates/editor/src/display_map.rs 🔗

@@ -464,7 +464,7 @@ mod tests {
     use Bias::*;
 
     #[gpui::test(iterations = 100)]
-    async fn test_random_display_map(mut cx: gpui::TestAppContext, mut rng: StdRng) {
+    async fn test_random_display_map(cx: &mut gpui::TestAppContext, mut rng: StdRng) {
         cx.foreground().set_block_on_ticks(0..=50);
         cx.foreground().forbid_parking();
         let operations = env::var("OPERATIONS")
@@ -512,11 +512,11 @@ mod tests {
                 cx,
             )
         });
-        let mut notifications = observe(&map, &mut cx);
+        let mut notifications = observe(&map, cx);
         let mut fold_count = 0;
         let mut blocks = Vec::new();
 
-        let snapshot = map.update(&mut cx, |map, cx| map.snapshot(cx));
+        let snapshot = map.update(cx, |map, cx| map.snapshot(cx));
         log::info!("buffer text: {:?}", snapshot.buffer_snapshot.text());
         log::info!("fold text: {:?}", snapshot.folds_snapshot.text());
         log::info!("tab text: {:?}", snapshot.tabs_snapshot.text());
@@ -533,10 +533,10 @@ mod tests {
                         Some(rng.gen_range(0.0..=max_wrap_width))
                     };
                     log::info!("setting wrap width to {:?}", wrap_width);
-                    map.update(&mut cx, |map, cx| map.set_wrap_width(wrap_width, cx));
+                    map.update(cx, |map, cx| map.set_wrap_width(wrap_width, cx));
                 }
                 20..=44 => {
-                    map.update(&mut cx, |map, cx| {
+                    map.update(cx, |map, cx| {
                         if rng.gen() || blocks.is_empty() {
                             let buffer = map.snapshot(cx).buffer_snapshot;
                             let block_properties = (0..rng.gen_range(1..=1))
@@ -582,7 +582,7 @@ mod tests {
                 45..=79 => {
                     let mut ranges = Vec::new();
                     for _ in 0..rng.gen_range(1..=3) {
-                        buffer.read_with(&cx, |buffer, cx| {
+                        buffer.read_with(cx, |buffer, cx| {
                             let buffer = buffer.read(cx);
                             let end = buffer.clip_offset(rng.gen_range(0..=buffer.len()), Right);
                             let start = buffer.clip_offset(rng.gen_range(0..=end), Left);
@@ -592,26 +592,26 @@ mod tests {
 
                     if rng.gen() && fold_count > 0 {
                         log::info!("unfolding ranges: {:?}", ranges);
-                        map.update(&mut cx, |map, cx| {
+                        map.update(cx, |map, cx| {
                             map.unfold(ranges, cx);
                         });
                     } else {
                         log::info!("folding ranges: {:?}", ranges);
-                        map.update(&mut cx, |map, cx| {
+                        map.update(cx, |map, cx| {
                             map.fold(ranges, cx);
                         });
                     }
                 }
                 _ => {
-                    buffer.update(&mut cx, |buffer, cx| buffer.randomly_edit(&mut rng, 5, cx));
+                    buffer.update(cx, |buffer, cx| buffer.randomly_edit(&mut rng, 5, cx));
                 }
             }
 
-            if map.read_with(&cx, |map, cx| map.is_rewrapping(cx)) {
+            if map.read_with(cx, |map, cx| map.is_rewrapping(cx)) {
                 notifications.next().await.unwrap();
             }
 
-            let snapshot = map.update(&mut cx, |map, cx| map.snapshot(cx));
+            let snapshot = map.update(cx, |map, cx| map.snapshot(cx));
             fold_count = snapshot.fold_count();
             log::info!("buffer text: {:?}", snapshot.buffer_snapshot.text());
             log::info!("fold text: {:?}", snapshot.folds_snapshot.text());
@@ -846,7 +846,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_chunks(mut cx: gpui::TestAppContext) {
+    async fn test_chunks(cx: &mut gpui::TestAppContext) {
         use unindent::Unindent as _;
 
         let text = r#"
@@ -914,7 +914,7 @@ mod tests {
             ]
         );
 
-        map.update(&mut cx, |map, cx| {
+        map.update(cx, |map, cx| {
             map.fold(vec![Point::new(0, 6)..Point::new(3, 2)], cx)
         });
         assert_eq!(
@@ -931,7 +931,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_chunks_with_soft_wrapping(mut cx: gpui::TestAppContext) {
+    async fn test_chunks_with_soft_wrapping(cx: &mut gpui::TestAppContext) {
         use unindent::Unindent as _;
 
         cx.foreground().set_block_on_ticks(usize::MAX..=usize::MAX);
@@ -996,7 +996,7 @@ mod tests {
             [("{}\n\n".to_string(), None)]
         );
 
-        map.update(&mut cx, |map, cx| {
+        map.update(cx, |map, cx| {
             map.fold(vec![Point::new(0, 6)..Point::new(3, 2)], cx)
         });
         assert_eq!(

crates/editor/src/display_map/wrap_map.rs 🔗

@@ -1010,7 +1010,7 @@ mod tests {
     use text::Rope;
 
     #[gpui::test(iterations = 100)]
-    async fn test_random_wraps(mut cx: gpui::TestAppContext, mut rng: StdRng) {
+    async fn test_random_wraps(cx: &mut gpui::TestAppContext, mut rng: StdRng) {
         cx.foreground().set_block_on_ticks(0..=50);
         cx.foreground().forbid_parking();
         let operations = env::var("OPERATIONS")
@@ -1043,7 +1043,7 @@ mod tests {
                 MultiBuffer::build_simple(&text, cx)
             }
         });
-        let mut buffer_snapshot = buffer.read_with(&cx, |buffer, cx| buffer.snapshot(cx));
+        let mut buffer_snapshot = buffer.read_with(cx, |buffer, cx| buffer.snapshot(cx));
         let (mut fold_map, folds_snapshot) = FoldMap::new(buffer_snapshot.clone());
         let (tab_map, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), tab_size);
         log::info!("Unwrapped text (no folds): {:?}", buffer_snapshot.text());
@@ -1059,13 +1059,13 @@ mod tests {
 
         let (wrap_map, _) =
             cx.update(|cx| WrapMap::new(tabs_snapshot.clone(), font_id, font_size, wrap_width, cx));
-        let mut notifications = observe(&wrap_map, &mut cx);
+        let mut notifications = observe(&wrap_map, cx);
 
-        if wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) {
+        if wrap_map.read_with(cx, |map, _| map.is_rewrapping()) {
             notifications.next().await.unwrap();
         }
 
-        let (initial_snapshot, _) = wrap_map.update(&mut cx, |map, cx| {
+        let (initial_snapshot, _) = wrap_map.update(cx, |map, cx| {
             assert!(!map.is_rewrapping());
             map.sync(tabs_snapshot.clone(), Vec::new(), cx)
         });
@@ -1091,20 +1091,20 @@ mod tests {
                         Some(rng.gen_range(0.0..=1000.0))
                     };
                     log::info!("Setting wrap width to {:?}", wrap_width);
-                    wrap_map.update(&mut cx, |map, cx| map.set_wrap_width(wrap_width, cx));
+                    wrap_map.update(cx, |map, cx| map.set_wrap_width(wrap_width, cx));
                 }
                 20..=39 => {
                     for (folds_snapshot, fold_edits) in fold_map.randomly_mutate(&mut rng) {
                         let (tabs_snapshot, tab_edits) = tab_map.sync(folds_snapshot, fold_edits);
-                        let (mut snapshot, wrap_edits) = wrap_map
-                            .update(&mut cx, |map, cx| map.sync(tabs_snapshot, tab_edits, cx));
+                        let (mut snapshot, wrap_edits) =
+                            wrap_map.update(cx, |map, cx| map.sync(tabs_snapshot, tab_edits, cx));
                         snapshot.check_invariants();
                         snapshot.verify_chunks(&mut rng);
                         edits.push((snapshot, wrap_edits));
                     }
                 }
                 _ => {
-                    buffer.update(&mut cx, |buffer, cx| {
+                    buffer.update(cx, |buffer, cx| {
                         let subscription = buffer.subscribe();
                         let edit_count = rng.gen_range(1..=5);
                         buffer.randomly_mutate(&mut rng, edit_count, cx);
@@ -1125,24 +1125,23 @@ mod tests {
 
             let unwrapped_text = tabs_snapshot.text();
             let expected_text = wrap_text(&unwrapped_text, wrap_width, &mut line_wrapper);
-            let (mut snapshot, wrap_edits) = wrap_map.update(&mut cx, |map, cx| {
-                map.sync(tabs_snapshot.clone(), tab_edits, cx)
-            });
+            let (mut snapshot, wrap_edits) =
+                wrap_map.update(cx, |map, cx| map.sync(tabs_snapshot.clone(), tab_edits, cx));
             snapshot.check_invariants();
             snapshot.verify_chunks(&mut rng);
             edits.push((snapshot, wrap_edits));
 
-            if wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) && rng.gen_bool(0.4) {
+            if wrap_map.read_with(cx, |map, _| map.is_rewrapping()) && rng.gen_bool(0.4) {
                 log::info!("Waiting for wrapping to finish");
-                while wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) {
+                while wrap_map.read_with(cx, |map, _| map.is_rewrapping()) {
                     notifications.next().await.unwrap();
                 }
-                wrap_map.read_with(&cx, |map, _| assert!(map.pending_edits.is_empty()));
+                wrap_map.read_with(cx, |map, _| assert!(map.pending_edits.is_empty()));
             }
 
-            if !wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) {
+            if !wrap_map.read_with(cx, |map, _| map.is_rewrapping()) {
                 let (mut wrapped_snapshot, wrap_edits) =
-                    wrap_map.update(&mut cx, |map, cx| map.sync(tabs_snapshot, Vec::new(), cx));
+                    wrap_map.update(cx, |map, cx| map.sync(tabs_snapshot, Vec::new(), cx));
                 let actual_text = wrapped_snapshot.text();
                 let actual_longest_row = wrapped_snapshot.longest_row();
                 log::info!("Wrapping finished: {:?}", actual_text);
@@ -1220,13 +1219,13 @@ mod tests {
             assert_eq!(initial_text.to_string(), snapshot_text.to_string());
         }
 
-        if wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) {
+        if wrap_map.read_with(cx, |map, _| map.is_rewrapping()) {
             log::info!("Waiting for wrapping to finish");
-            while wrap_map.read_with(&cx, |map, _| map.is_rewrapping()) {
+            while wrap_map.read_with(cx, |map, _| map.is_rewrapping()) {
                 notifications.next().await.unwrap();
             }
         }
-        wrap_map.read_with(&cx, |map, _| assert!(map.pending_edits.is_empty()));
+        wrap_map.read_with(cx, |map, _| assert!(map.pending_edits.is_empty()));
     }
 
     fn wrap_text(

crates/editor/src/editor.rs 🔗

@@ -7772,7 +7772,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_select_larger_smaller_syntax_node(mut cx: gpui::TestAppContext) {
+    async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) {
         let settings = cx.read(Settings::test);
         let language = Arc::new(Language::new(
             LanguageConfig::default(),
@@ -7794,7 +7794,7 @@ mod tests {
         view.condition(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
             .await;
 
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             view.select_display_ranges(
                 &[
                     DisplayPoint::new(0, 25)..DisplayPoint::new(0, 25),
@@ -7806,7 +7806,7 @@ mod tests {
             view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx);
         });
         assert_eq!(
-            view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
+            view.update(cx, |view, cx| view.selected_display_ranges(cx)),
             &[
                 DisplayPoint::new(0, 23)..DisplayPoint::new(0, 27),
                 DisplayPoint::new(2, 35)..DisplayPoint::new(2, 7),
@@ -7814,50 +7814,50 @@ mod tests {
             ]
         );
 
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx);
         });
         assert_eq!(
-            view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
+            view.update(cx, |view, cx| view.selected_display_ranges(cx)),
             &[
                 DisplayPoint::new(0, 16)..DisplayPoint::new(0, 28),
                 DisplayPoint::new(4, 1)..DisplayPoint::new(2, 0),
             ]
         );
 
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx);
         });
         assert_eq!(
-            view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
+            view.update(cx, |view, cx| view.selected_display_ranges(cx)),
             &[DisplayPoint::new(5, 0)..DisplayPoint::new(0, 0)]
         );
 
         // Trying to expand the selected syntax node one more time has no effect.
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx);
         });
         assert_eq!(
-            view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
+            view.update(cx, |view, cx| view.selected_display_ranges(cx)),
             &[DisplayPoint::new(5, 0)..DisplayPoint::new(0, 0)]
         );
 
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx);
         });
         assert_eq!(
-            view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
+            view.update(cx, |view, cx| view.selected_display_ranges(cx)),
             &[
                 DisplayPoint::new(0, 16)..DisplayPoint::new(0, 28),
                 DisplayPoint::new(4, 1)..DisplayPoint::new(2, 0),
             ]
         );
 
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx);
         });
         assert_eq!(
-            view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
+            view.update(cx, |view, cx| view.selected_display_ranges(cx)),
             &[
                 DisplayPoint::new(0, 23)..DisplayPoint::new(0, 27),
                 DisplayPoint::new(2, 35)..DisplayPoint::new(2, 7),
@@ -7865,11 +7865,11 @@ mod tests {
             ]
         );
 
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx);
         });
         assert_eq!(
-            view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
+            view.update(cx, |view, cx| view.selected_display_ranges(cx)),
             &[
                 DisplayPoint::new(0, 25)..DisplayPoint::new(0, 25),
                 DisplayPoint::new(2, 24)..DisplayPoint::new(2, 12),
@@ -7878,11 +7878,11 @@ mod tests {
         );
 
         // Trying to shrink the selected syntax node one more time has no effect.
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx);
         });
         assert_eq!(
-            view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
+            view.update(cx, |view, cx| view.selected_display_ranges(cx)),
             &[
                 DisplayPoint::new(0, 25)..DisplayPoint::new(0, 25),
                 DisplayPoint::new(2, 24)..DisplayPoint::new(2, 12),
@@ -7892,7 +7892,7 @@ mod tests {
 
         // Ensure that we keep expanding the selection if the larger selection starts or ends within
         // a fold.
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             view.fold_ranges(
                 vec![
                     Point::new(0, 21)..Point::new(0, 24),
@@ -7903,7 +7903,7 @@ mod tests {
             view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx);
         });
         assert_eq!(
-            view.update(&mut cx, |view, cx| view.selected_display_ranges(cx)),
+            view.update(cx, |view, cx| view.selected_display_ranges(cx)),
             &[
                 DisplayPoint::new(0, 16)..DisplayPoint::new(0, 28),
                 DisplayPoint::new(2, 35)..DisplayPoint::new(2, 7),
@@ -7913,7 +7913,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_autoindent_selections(mut cx: gpui::TestAppContext) {
+    async fn test_autoindent_selections(cx: &mut gpui::TestAppContext) {
         let settings = cx.read(Settings::test);
         let language = Arc::new(
             Language::new(
@@ -7954,7 +7954,7 @@ mod tests {
             .condition(&cx, |editor, cx| !editor.buffer.read(cx).is_parsing(cx))
             .await;
 
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             editor.select_ranges([5..5, 8..8, 9..9], None, cx);
             editor.newline(&Newline, cx);
             assert_eq!(editor.text(cx), "fn a(\n    \n) {\n    \n}\n");
@@ -7970,7 +7970,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_autoclose_pairs(mut cx: gpui::TestAppContext) {
+    async fn test_autoclose_pairs(cx: &mut gpui::TestAppContext) {
         let settings = cx.read(Settings::test);
         let language = Arc::new(Language::new(
             LanguageConfig {
@@ -8007,7 +8007,7 @@ mod tests {
         view.condition(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
             .await;
 
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             view.select_display_ranges(
                 &[
                     DisplayPoint::new(0, 0)..DisplayPoint::new(0, 1),
@@ -8081,7 +8081,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_snippets(mut cx: gpui::TestAppContext) {
+    async fn test_snippets(cx: &mut gpui::TestAppContext) {
         let settings = cx.read(Settings::test);
 
         let text = "
@@ -8093,7 +8093,7 @@ mod tests {
         let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx));
         let (_, editor) = cx.add_window(|cx| build_editor(buffer, settings, cx));
 
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             let buffer = &editor.snapshot(cx).buffer_snapshot;
             let snippet = Snippet::parse("f(${1:one}, ${2:two}, ${1:three})$0").unwrap();
             let insertion_ranges = [
@@ -8188,7 +8188,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_completion(mut cx: gpui::TestAppContext) {
+    async fn test_completion(cx: &mut gpui::TestAppContext) {
         let settings = cx.read(Settings::test);
         let (language_server, mut fake) = cx.update(|cx| {
             lsp::LanguageServer::fake_with_capabilities(
@@ -8213,23 +8213,23 @@ mod tests {
         let fs = FakeFs::new(cx.background().clone());
         fs.insert_file("/file", text).await;
 
-        let project = Project::test(fs, &mut cx);
+        let project = Project::test(fs, cx);
 
         let (worktree, relative_path) = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/file", false, cx)
             })
             .await
             .unwrap();
         let project_path = ProjectPath {
-            worktree_id: worktree.read_with(&cx, |worktree, _| worktree.id()),
+            worktree_id: worktree.read_with(cx, |worktree, _| worktree.id()),
             path: relative_path.into(),
         };
         let buffer = project
-            .update(&mut cx, |project, cx| project.open_buffer(project_path, cx))
+            .update(cx, |project, cx| project.open_buffer(project_path, cx))
             .await
             .unwrap();
-        buffer.update(&mut cx, |buffer, cx| {
+        buffer.update(cx, |buffer, cx| {
             buffer.set_language_server(Some(language_server), cx);
         });
 
@@ -8238,7 +8238,7 @@ mod tests {
 
         let (_, editor) = cx.add_window(|cx| build_editor(buffer, settings, cx));
 
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             editor.project = Some(project);
             editor.select_ranges([Point::new(0, 3)..Point::new(0, 3)], None, cx);
             editor.handle_input(&Input(".".to_string()), cx);
@@ -8258,7 +8258,7 @@ mod tests {
             .condition(&cx, |editor, _| editor.context_menu_visible())
             .await;
 
-        let apply_additional_edits = editor.update(&mut cx, |editor, cx| {
+        let apply_additional_edits = editor.update(cx, |editor, cx| {
             editor.move_down(&MoveDown, cx);
             let apply_additional_edits = editor
                 .confirm_completion(&ConfirmCompletion(None), cx)
@@ -8282,7 +8282,7 @@ mod tests {
         .await;
         apply_additional_edits.await.unwrap();
         assert_eq!(
-            editor.read_with(&cx, |editor, cx| editor.text(cx)),
+            editor.read_with(cx, |editor, cx| editor.text(cx)),
             "
                 one.second_completion
                 two
@@ -8292,7 +8292,7 @@ mod tests {
             .unindent()
         );
 
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             editor.select_ranges(
                 [
                     Point::new(1, 3)..Point::new(1, 3),
@@ -8323,7 +8323,7 @@ mod tests {
             .condition(&cx, |editor, _| editor.context_menu_visible())
             .await;
 
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             editor.handle_input(&Input("i".to_string()), cx);
         });
 
@@ -8342,7 +8342,7 @@ mod tests {
             .condition(&cx, |editor, _| editor.context_menu_visible())
             .await;
 
-        let apply_additional_edits = editor.update(&mut cx, |editor, cx| {
+        let apply_additional_edits = editor.update(cx, |editor, cx| {
             let apply_additional_edits = editor
                 .confirm_completion(&ConfirmCompletion(None), cx)
                 .unwrap();
@@ -8421,7 +8421,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_toggle_comment(mut cx: gpui::TestAppContext) {
+    async fn test_toggle_comment(cx: &mut gpui::TestAppContext) {
         let settings = cx.read(Settings::test);
         let language = Arc::new(Language::new(
             LanguageConfig {
@@ -8444,7 +8444,7 @@ mod tests {
         let buffer = cx.add_model(|cx| MultiBuffer::singleton(buffer, cx));
         let (_, view) = cx.add_window(|cx| build_editor(buffer, settings, cx));
 
-        view.update(&mut cx, |editor, cx| {
+        view.update(cx, |editor, cx| {
             // If multiple selections intersect a line, the line is only
             // toggled once.
             editor.select_display_ranges(
@@ -8678,7 +8678,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_extra_newline_insertion(mut cx: gpui::TestAppContext) {
+    async fn test_extra_newline_insertion(cx: &mut gpui::TestAppContext) {
         let settings = cx.read(Settings::test);
         let language = Arc::new(Language::new(
             LanguageConfig {
@@ -8715,7 +8715,7 @@ mod tests {
         view.condition(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
             .await;
 
-        view.update(&mut cx, |view, cx| {
+        view.update(cx, |view, cx| {
             view.select_display_ranges(
                 &[
                     DisplayPoint::new(0, 2)..DisplayPoint::new(0, 3),

crates/file_finder/src/file_finder.rs 🔗

@@ -421,7 +421,7 @@ mod tests {
     use workspace::{Workspace, WorkspaceParams};
 
     #[gpui::test]
-    async fn test_matching_paths(mut cx: gpui::TestAppContext) {
+    async fn test_matching_paths(cx: &mut gpui::TestAppContext) {
         let mut path_openers = Vec::new();
         cx.update(|cx| {
             super::init(cx);
@@ -447,7 +447,7 @@ mod tests {
         let (window_id, workspace) = cx.add_window(|cx| Workspace::new(&params, cx));
         params
             .project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/root", false, cx)
             })
             .await
@@ -496,7 +496,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_matching_cancellation(mut cx: gpui::TestAppContext) {
+    async fn test_matching_cancellation(cx: &mut gpui::TestAppContext) {
         let params = cx.update(WorkspaceParams::test);
         let fs = params.fs.as_fake();
         fs.insert_tree(
@@ -516,7 +516,7 @@ mod tests {
         let (_, workspace) = cx.add_window(|cx| Workspace::new(&params, cx));
         params
             .project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/dir", false, cx)
             })
             .await
@@ -533,12 +533,12 @@ mod tests {
 
         let query = "hi".to_string();
         finder
-            .update(&mut cx, |f, cx| f.spawn_search(query.clone(), cx))
+            .update(cx, |f, cx| f.spawn_search(query.clone(), cx))
             .unwrap()
             .await;
-        finder.read_with(&cx, |f, _| assert_eq!(f.matches.len(), 5));
+        finder.read_with(cx, |f, _| assert_eq!(f.matches.len(), 5));
 
-        finder.update(&mut cx, |finder, cx| {
+        finder.update(cx, |finder, cx| {
             let matches = finder.matches.clone();
 
             // Simulate a search being cancelled after the time limit,
@@ -571,7 +571,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_single_file_worktrees(mut cx: gpui::TestAppContext) {
+    async fn test_single_file_worktrees(cx: &mut gpui::TestAppContext) {
         let params = cx.update(WorkspaceParams::test);
         params
             .fs
@@ -582,7 +582,7 @@ mod tests {
         let (_, workspace) = cx.add_window(|cx| Workspace::new(&params, cx));
         params
             .project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/root/the-parent-dir/the-file", false, cx)
             })
             .await
@@ -600,7 +600,7 @@ mod tests {
         // Even though there is only one worktree, that worktree's filename
         // is included in the matching, because the worktree is a single file.
         finder
-            .update(&mut cx, |f, cx| f.spawn_search("thf".into(), cx))
+            .update(cx, |f, cx| f.spawn_search("thf".into(), cx))
             .unwrap()
             .await;
         cx.read(|cx| {
@@ -618,14 +618,14 @@ mod tests {
         // Since the worktree root is a file, searching for its name followed by a slash does
         // not match anything.
         finder
-            .update(&mut cx, |f, cx| f.spawn_search("thf/".into(), cx))
+            .update(cx, |f, cx| f.spawn_search("thf/".into(), cx))
             .unwrap()
             .await;
-        finder.read_with(&cx, |f, _| assert_eq!(f.matches.len(), 0));
+        finder.read_with(cx, |f, _| assert_eq!(f.matches.len(), 0));
     }
 
     #[gpui::test(retries = 5)]
-    async fn test_multiple_matches_with_same_relative_path(mut cx: gpui::TestAppContext) {
+    async fn test_multiple_matches_with_same_relative_path(cx: &mut gpui::TestAppContext) {
         let params = cx.update(WorkspaceParams::test);
         params
             .fs
@@ -642,7 +642,7 @@ mod tests {
         let (_, workspace) = cx.add_window(|cx| Workspace::new(&params, cx));
 
         workspace
-            .update(&mut cx, |workspace, cx| {
+            .update(cx, |workspace, cx| {
                 workspace.open_paths(
                     &[PathBuf::from("/root/dir1"), PathBuf::from("/root/dir2")],
                     cx,
@@ -662,12 +662,12 @@ mod tests {
 
         // Run a search that matches two files with the same relative path.
         finder
-            .update(&mut cx, |f, cx| f.spawn_search("a.t".into(), cx))
+            .update(cx, |f, cx| f.spawn_search("a.t".into(), cx))
             .unwrap()
             .await;
 
         // Can switch between different matches with the same relative path.
-        finder.update(&mut cx, |f, cx| {
+        finder.update(cx, |f, cx| {
             assert_eq!(f.matches.len(), 2);
             assert_eq!(f.selected_index(), 0);
             f.select_next(&SelectNext, cx);

crates/gpui/src/app.rs 🔗

@@ -4726,7 +4726,7 @@ mod tests {
     }
 
     #[crate::test(self)]
-    async fn test_model_condition(mut cx: TestAppContext) {
+    async fn test_model_condition(cx: &mut TestAppContext) {
         struct Counter(usize);
 
         impl super::Entity for Counter {
@@ -4746,23 +4746,23 @@ mod tests {
         let condition2 = model.condition(&cx, |model, _| model.0 == 3);
         smol::pin!(condition1, condition2);
 
-        model.update(&mut cx, |model, cx| model.inc(cx));
+        model.update(cx, |model, cx| model.inc(cx));
         assert_eq!(poll_once(&mut condition1).await, None);
         assert_eq!(poll_once(&mut condition2).await, None);
 
-        model.update(&mut cx, |model, cx| model.inc(cx));
+        model.update(cx, |model, cx| model.inc(cx));
         assert_eq!(poll_once(&mut condition1).await, Some(()));
         assert_eq!(poll_once(&mut condition2).await, None);
 
-        model.update(&mut cx, |model, cx| model.inc(cx));
+        model.update(cx, |model, cx| model.inc(cx));
         assert_eq!(poll_once(&mut condition2).await, Some(()));
 
-        model.update(&mut cx, |_, cx| cx.notify());
+        model.update(cx, |_, cx| cx.notify());
     }
 
     #[crate::test(self)]
     #[should_panic]
-    async fn test_model_condition_timeout(mut cx: TestAppContext) {
+    async fn test_model_condition_timeout(cx: &mut TestAppContext) {
         struct Model;
 
         impl super::Entity for Model {
@@ -4775,7 +4775,7 @@ mod tests {
 
     #[crate::test(self)]
     #[should_panic(expected = "model dropped with pending condition")]
-    async fn test_model_condition_panic_on_drop(mut cx: TestAppContext) {
+    async fn test_model_condition_panic_on_drop(cx: &mut TestAppContext) {
         struct Model;
 
         impl super::Entity for Model {
@@ -4789,7 +4789,7 @@ mod tests {
     }
 
     #[crate::test(self)]
-    async fn test_view_condition(mut cx: TestAppContext) {
+    async fn test_view_condition(cx: &mut TestAppContext) {
         struct Counter(usize);
 
         impl super::Entity for Counter {
@@ -4819,22 +4819,22 @@ mod tests {
         let condition2 = view.condition(&cx, |view, _| view.0 == 3);
         smol::pin!(condition1, condition2);
 
-        view.update(&mut cx, |view, cx| view.inc(cx));
+        view.update(cx, |view, cx| view.inc(cx));
         assert_eq!(poll_once(&mut condition1).await, None);
         assert_eq!(poll_once(&mut condition2).await, None);
 
-        view.update(&mut cx, |view, cx| view.inc(cx));
+        view.update(cx, |view, cx| view.inc(cx));
         assert_eq!(poll_once(&mut condition1).await, Some(()));
         assert_eq!(poll_once(&mut condition2).await, None);
 
-        view.update(&mut cx, |view, cx| view.inc(cx));
+        view.update(cx, |view, cx| view.inc(cx));
         assert_eq!(poll_once(&mut condition2).await, Some(()));
-        view.update(&mut cx, |_, cx| cx.notify());
+        view.update(cx, |_, cx| cx.notify());
     }
 
     #[crate::test(self)]
     #[should_panic]
-    async fn test_view_condition_timeout(mut cx: TestAppContext) {
+    async fn test_view_condition_timeout(cx: &mut TestAppContext) {
         struct View;
 
         impl super::Entity for View {
@@ -4857,7 +4857,7 @@ mod tests {
 
     #[crate::test(self)]
     #[should_panic(expected = "view dropped with pending condition")]
-    async fn test_view_condition_panic_on_drop(mut cx: TestAppContext) {
+    async fn test_view_condition_panic_on_drop(cx: &mut TestAppContext) {
         struct View;
 
         impl super::Entity for View {

crates/gpui_macros/src/gpui_macros.rs 🔗

@@ -65,26 +65,13 @@ pub fn test(args: TokenStream, function: TokenStream) -> TokenStream {
     let mut outer_fn: ItemFn = if inner_fn.sig.asyncness.is_some() {
         // Pass to the test function the number of app contexts that it needs,
         // based on its parameter list.
+        let mut cx_vars = proc_macro2::TokenStream::new();
         let mut inner_fn_args = proc_macro2::TokenStream::new();
         for (ix, arg) in inner_fn.sig.inputs.iter().enumerate() {
             if let FnArg::Typed(arg) = arg {
                 if let Type::Path(ty) = &*arg.ty {
                     let last_segment = ty.path.segments.last();
                     match last_segment.map(|s| s.ident.to_string()).as_deref() {
-                        Some("TestAppContext") => {
-                            let first_entity_id = ix * 100_000;
-                            inner_fn_args.extend(quote!(
-                                #namespace::TestAppContext::new(
-                                    foreground_platform.clone(),
-                                    cx.platform().clone(),
-                                    deterministic.build_foreground(#ix),
-                                    deterministic.build_background(),
-                                    cx.font_cache().clone(),
-                                    cx.leak_detector(),
-                                    #first_entity_id,
-                                ),
-                            ));
-                        }
                         Some("StdRng") => {
                             inner_fn_args.extend(quote!(rand::SeedableRng::seed_from_u64(seed),));
                         }
@@ -98,6 +85,42 @@ pub fn test(args: TokenStream, function: TokenStream) -> TokenStream {
                             )
                         }
                     }
+                } else if let Type::Reference(ty) = &*arg.ty {
+                    match &*ty.elem {
+                        Type::Path(ty) => {
+                            let last_segment = ty.path.segments.last();
+                            match last_segment.map(|s| s.ident.to_string()).as_deref() {
+                                Some("TestAppContext") => {
+                                    let first_entity_id = ix * 100_000;
+                                    let cx_varname = format_ident!("cx_{}", ix);
+                                    cx_vars.extend(quote!(
+                                        let mut #cx_varname = #namespace::TestAppContext::new(
+                                            foreground_platform.clone(),
+                                            cx.platform().clone(),
+                                            deterministic.build_foreground(#ix),
+                                            deterministic.build_background(),
+                                            cx.font_cache().clone(),
+                                            cx.leak_detector(),
+                                            #first_entity_id,
+                                        );
+                                    ));
+                                    inner_fn_args.extend(quote!(&mut #cx_varname,));
+                                }
+                                _ => {
+                                    return TokenStream::from(
+                                        syn::Error::new_spanned(arg, "invalid argument")
+                                            .into_compile_error(),
+                                    )
+                                }
+                            }
+                        }
+                        _ => {
+                            return TokenStream::from(
+                                syn::Error::new_spanned(arg, "invalid argument")
+                                    .into_compile_error(),
+                            )
+                        }
+                    }
                 } else {
                     return TokenStream::from(
                         syn::Error::new_spanned(arg, "invalid argument").into_compile_error(),
@@ -120,7 +143,9 @@ pub fn test(args: TokenStream, function: TokenStream) -> TokenStream {
                     #starting_seed as u64,
                     #max_retries,
                     &mut |cx, foreground_platform, deterministic, seed, is_last_iteration| {
-                        cx.foreground().run(#inner_fn_name(#inner_fn_args))
+                        #cx_vars
+                        cx.foreground().run(#inner_fn_name(#inner_fn_args));
+                        cx.foreground().run_until_parked();
                     }
                 );
             }

crates/language/src/tests.rs 🔗

@@ -125,23 +125,23 @@ fn test_edit_events(cx: &mut gpui::MutableAppContext) {
 }
 
 #[gpui::test]
-async fn test_apply_diff(mut cx: gpui::TestAppContext) {
+async fn test_apply_diff(cx: &mut gpui::TestAppContext) {
     let text = "a\nbb\nccc\ndddd\neeeee\nffffff\n";
     let buffer = cx.add_model(|cx| Buffer::new(0, text, cx));
 
     let text = "a\nccc\ndddd\nffffff\n";
-    let diff = buffer.read_with(&cx, |b, cx| b.diff(text.into(), cx)).await;
-    buffer.update(&mut cx, |b, cx| b.apply_diff(diff, cx));
+    let diff = buffer.read_with(cx, |b, cx| b.diff(text.into(), cx)).await;
+    buffer.update(cx, |b, cx| b.apply_diff(diff, cx));
     cx.read(|cx| assert_eq!(buffer.read(cx).text(), text));
 
     let text = "a\n1\n\nccc\ndd2dd\nffffff\n";
-    let diff = buffer.read_with(&cx, |b, cx| b.diff(text.into(), cx)).await;
-    buffer.update(&mut cx, |b, cx| b.apply_diff(diff, cx));
+    let diff = buffer.read_with(cx, |b, cx| b.diff(text.into(), cx)).await;
+    buffer.update(cx, |b, cx| b.apply_diff(diff, cx));
     cx.read(|cx| assert_eq!(buffer.read(cx).text(), text));
 }
 
 #[gpui::test]
-async fn test_reparse(mut cx: gpui::TestAppContext) {
+async fn test_reparse(cx: &mut gpui::TestAppContext) {
     let text = "fn a() {}";
     let buffer =
         cx.add_model(|cx| Buffer::new(0, text, cx).with_language(Arc::new(rust_lang()), cx));
@@ -159,13 +159,13 @@ async fn test_reparse(mut cx: gpui::TestAppContext) {
         )
     );
 
-    buffer.update(&mut cx, |buffer, _| {
+    buffer.update(cx, |buffer, _| {
         buffer.set_sync_parse_timeout(Duration::ZERO)
     });
 
     // Perform some edits (add parameter and variable reference)
     // Parsing doesn't begin until the transaction is complete
-    buffer.update(&mut cx, |buf, cx| {
+    buffer.update(cx, |buf, cx| {
         buf.start_transaction();
 
         let offset = buf.text().find(")").unwrap();
@@ -196,19 +196,19 @@ async fn test_reparse(mut cx: gpui::TestAppContext) {
     // * turn identifier into a field expression
     // * turn field expression into a method call
     // * add a turbofish to the method call
-    buffer.update(&mut cx, |buf, cx| {
+    buffer.update(cx, |buf, cx| {
         let offset = buf.text().find(";").unwrap();
         buf.edit(vec![offset..offset], ".e", cx);
         assert_eq!(buf.text(), "fn a(b: C) { d.e; }");
         assert!(buf.is_parsing());
     });
-    buffer.update(&mut cx, |buf, cx| {
+    buffer.update(cx, |buf, cx| {
         let offset = buf.text().find(";").unwrap();
         buf.edit(vec![offset..offset], "(f)", cx);
         assert_eq!(buf.text(), "fn a(b: C) { d.e(f); }");
         assert!(buf.is_parsing());
     });
-    buffer.update(&mut cx, |buf, cx| {
+    buffer.update(cx, |buf, cx| {
         let offset = buf.text().find("(f)").unwrap();
         buf.edit(vec![offset..offset], "::<G>", cx);
         assert_eq!(buf.text(), "fn a(b: C) { d.e::<G>(f); }");
@@ -230,7 +230,7 @@ async fn test_reparse(mut cx: gpui::TestAppContext) {
         )
     );
 
-    buffer.update(&mut cx, |buf, cx| {
+    buffer.update(cx, |buf, cx| {
         buf.undo(cx);
         assert_eq!(buf.text(), "fn a() {}");
         assert!(buf.is_parsing());
@@ -247,7 +247,7 @@ async fn test_reparse(mut cx: gpui::TestAppContext) {
         )
     );
 
-    buffer.update(&mut cx, |buf, cx| {
+    buffer.update(cx, |buf, cx| {
         buf.redo(cx);
         assert_eq!(buf.text(), "fn a(b: C) { d.e::<G>(f); }");
         assert!(buf.is_parsing());
@@ -276,7 +276,7 @@ async fn test_reparse(mut cx: gpui::TestAppContext) {
 }
 
 #[gpui::test]
-async fn test_outline(mut cx: gpui::TestAppContext) {
+async fn test_outline(cx: &mut gpui::TestAppContext) {
     let language = Arc::new(
         rust_lang()
             .with_outline_query(
@@ -336,7 +336,7 @@ async fn test_outline(mut cx: gpui::TestAppContext) {
 
     let buffer = cx.add_model(|cx| Buffer::new(0, text, cx).with_language(language, cx));
     let outline = buffer
-        .read_with(&cx, |buffer, _| buffer.snapshot().outline(None))
+        .read_with(cx, |buffer, _| buffer.snapshot().outline(None))
         .unwrap();
 
     assert_eq!(
@@ -553,7 +553,7 @@ fn test_autoindent_adjusts_lines_when_only_text_changes(cx: &mut MutableAppConte
 }
 
 #[gpui::test]
-async fn test_diagnostics(mut cx: gpui::TestAppContext) {
+async fn test_diagnostics(cx: &mut gpui::TestAppContext) {
     let (language_server, mut fake) = cx.update(lsp::LanguageServer::fake);
     let mut rust_lang = rust_lang();
     rust_lang.config.language_server = Some(LanguageServerConfig {
@@ -579,13 +579,13 @@ async fn test_diagnostics(mut cx: gpui::TestAppContext) {
         .await;
 
     // Edit the buffer, moving the content down
-    buffer.update(&mut cx, |buffer, cx| buffer.edit([0..0], "\n\n", cx));
+    buffer.update(cx, |buffer, cx| buffer.edit([0..0], "\n\n", cx));
     let change_notification_1 = fake
         .receive_notification::<lsp::notification::DidChangeTextDocument>()
         .await;
     assert!(change_notification_1.text_document.version > open_notification.text_document.version);
 
-    buffer.update(&mut cx, |buffer, cx| {
+    buffer.update(cx, |buffer, cx| {
         // Receive diagnostics for an earlier version of the buffer.
         buffer
             .update_diagnostics(
@@ -760,7 +760,7 @@ async fn test_diagnostics(mut cx: gpui::TestAppContext) {
 
     // Keep editing the buffer and ensure disk-based diagnostics get translated according to the
     // changes since the last save.
-    buffer.update(&mut cx, |buffer, cx| {
+    buffer.update(cx, |buffer, cx| {
         buffer.edit(Some(Point::new(2, 0)..Point::new(2, 0)), "    ", cx);
         buffer.edit(Some(Point::new(2, 8)..Point::new(2, 10)), "(x: usize)", cx);
     });
@@ -771,7 +771,7 @@ async fn test_diagnostics(mut cx: gpui::TestAppContext) {
         change_notification_2.text_document.version > change_notification_1.text_document.version
     );
 
-    buffer.update(&mut cx, |buffer, cx| {
+    buffer.update(cx, |buffer, cx| {
         buffer
             .update_diagnostics(
                 vec![
@@ -836,7 +836,7 @@ async fn test_diagnostics(mut cx: gpui::TestAppContext) {
 }
 
 #[gpui::test]
-async fn test_edits_from_lsp_with_past_version(mut cx: gpui::TestAppContext) {
+async fn test_edits_from_lsp_with_past_version(cx: &mut gpui::TestAppContext) {
     let (language_server, mut fake) = cx.update(lsp::LanguageServer::fake);
 
     let text = "
@@ -865,7 +865,7 @@ async fn test_edits_from_lsp_with_past_version(mut cx: gpui::TestAppContext) {
         .version;
 
     // Simulate editing the buffer after the language server computes some edits.
-    buffer.update(&mut cx, |buffer, cx| {
+    buffer.update(cx, |buffer, cx| {
         buffer.edit(
             [Point::new(0, 0)..Point::new(0, 0)],
             "// above first function\n",
@@ -902,7 +902,7 @@ async fn test_edits_from_lsp_with_past_version(mut cx: gpui::TestAppContext) {
     });
 
     let edits = buffer
-        .update(&mut cx, |buffer, cx| {
+        .update(cx, |buffer, cx| {
             buffer.edits_from_lsp(
                 vec![
                     // replace body of first function
@@ -937,7 +937,7 @@ async fn test_edits_from_lsp_with_past_version(mut cx: gpui::TestAppContext) {
         .await
         .unwrap();
 
-    buffer.update(&mut cx, |buffer, cx| {
+    buffer.update(cx, |buffer, cx| {
         for (range, new_text) in edits {
             buffer.edit([range], new_text, cx);
         }
@@ -962,7 +962,7 @@ async fn test_edits_from_lsp_with_past_version(mut cx: gpui::TestAppContext) {
 }
 
 #[gpui::test]
-async fn test_edits_from_lsp_with_edits_on_adjacent_lines(mut cx: gpui::TestAppContext) {
+async fn test_edits_from_lsp_with_edits_on_adjacent_lines(cx: &mut gpui::TestAppContext) {
     let text = "
         use a::b;
         use a::c;
@@ -979,7 +979,7 @@ async fn test_edits_from_lsp_with_edits_on_adjacent_lines(mut cx: gpui::TestAppC
     // Simulate the language server sending us a small edit in the form of a very large diff.
     // Rust-analyzer does this when performing a merge-imports code action.
     let edits = buffer
-        .update(&mut cx, |buffer, cx| {
+        .update(cx, |buffer, cx| {
             buffer.edits_from_lsp(
                 [
                     // Replace the first use statement without editing the semicolon.
@@ -1015,7 +1015,7 @@ async fn test_edits_from_lsp_with_edits_on_adjacent_lines(mut cx: gpui::TestAppC
         .await
         .unwrap();
 
-    buffer.update(&mut cx, |buffer, cx| {
+    buffer.update(cx, |buffer, cx| {
         let edits = edits
             .into_iter()
             .map(|(range, text)| {
@@ -1053,7 +1053,7 @@ async fn test_edits_from_lsp_with_edits_on_adjacent_lines(mut cx: gpui::TestAppC
 }
 
 #[gpui::test]
-async fn test_empty_diagnostic_ranges(mut cx: gpui::TestAppContext) {
+async fn test_empty_diagnostic_ranges(cx: &mut gpui::TestAppContext) {
     cx.add_model(|cx| {
         let text = concat!(
             "let one = ;\n", //

crates/lsp/src/lsp.rs 🔗

@@ -712,7 +712,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_fake(mut cx: TestAppContext) {
+    async fn test_fake(cx: &mut TestAppContext) {
         let (server, mut fake) = cx.update(LanguageServer::fake);
 
         let (message_tx, message_rx) = channel::unbounded();

crates/project/src/project.rs 🔗

@@ -3603,7 +3603,7 @@ mod tests {
     use worktree::WorktreeHandle as _;
 
     #[gpui::test]
-    async fn test_populate_and_search(mut cx: gpui::TestAppContext) {
+    async fn test_populate_and_search(cx: &mut gpui::TestAppContext) {
         let dir = temp_tree(json!({
             "root": {
                 "apple": "",
@@ -3627,10 +3627,10 @@ mod tests {
         )
         .unwrap();
 
-        let project = Project::test(Arc::new(RealFs), &mut cx);
+        let project = Project::test(Arc::new(RealFs), cx);
 
         let (tree, _) = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree(&root_link_path, false, cx)
             })
             .await
@@ -3649,7 +3649,7 @@ mod tests {
 
         let cancel_flag = Default::default();
         let results = project
-            .read_with(&cx, |project, cx| {
+            .read_with(cx, |project, cx| {
                 project.match_paths("bna", false, false, 10, &cancel_flag, cx)
             })
             .await;
@@ -3666,7 +3666,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_language_server_diagnostics(mut cx: gpui::TestAppContext) {
+    async fn test_language_server_diagnostics(cx: &mut gpui::TestAppContext) {
         let (language_server_config, mut fake_servers) = LanguageServerConfig::fake();
         let progress_token = language_server_config
             .disk_based_diagnostics_progress_token
@@ -3693,31 +3693,31 @@ mod tests {
         )
         .await;
 
-        let project = Project::test(fs, &mut cx);
-        project.update(&mut cx, |project, _| {
+        let project = Project::test(fs, cx);
+        project.update(cx, |project, _| {
             Arc::get_mut(&mut project.languages).unwrap().add(language);
         });
 
         let (tree, _) = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/dir", false, cx)
             })
             .await
             .unwrap();
-        let worktree_id = tree.read_with(&cx, |tree, _| tree.id());
+        let worktree_id = tree.read_with(cx, |tree, _| tree.id());
 
         cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete())
             .await;
 
         // Cause worktree to start the fake language server
         let _buffer = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.open_buffer((worktree_id, Path::new("b.rs")), cx)
             })
             .await
             .unwrap();
 
-        let mut events = subscribe(&project, &mut cx);
+        let mut events = subscribe(&project, cx);
 
         let mut fake_server = fake_servers.next().await.unwrap();
         fake_server.start_progress(&progress_token).await;
@@ -3759,11 +3759,11 @@ mod tests {
         );
 
         let buffer = project
-            .update(&mut cx, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx))
+            .update(cx, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx))
             .await
             .unwrap();
 
-        buffer.read_with(&cx, |buffer, _| {
+        buffer.read_with(cx, |buffer, _| {
             let snapshot = buffer.snapshot();
             let diagnostics = snapshot
                 .diagnostics_in_range::<_, Point>(0..buffer.len())
@@ -3785,7 +3785,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_search_worktree_without_files(mut cx: gpui::TestAppContext) {
+    async fn test_search_worktree_without_files(cx: &mut gpui::TestAppContext) {
         let dir = temp_tree(json!({
             "root": {
                 "dir1": {},
@@ -3795,9 +3795,9 @@ mod tests {
             }
         }));
 
-        let project = Project::test(Arc::new(RealFs), &mut cx);
+        let project = Project::test(Arc::new(RealFs), cx);
         let (tree, _) = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree(&dir.path(), false, cx)
             })
             .await
@@ -3808,7 +3808,7 @@ mod tests {
 
         let cancel_flag = Default::default();
         let results = project
-            .read_with(&cx, |project, cx| {
+            .read_with(cx, |project, cx| {
                 project.match_paths("dir", false, false, 10, &cancel_flag, cx)
             })
             .await;
@@ -3817,7 +3817,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_definition(mut cx: gpui::TestAppContext) {
+    async fn test_definition(cx: &mut gpui::TestAppContext) {
         let (language_server_config, mut fake_servers) = LanguageServerConfig::fake();
         let language = Arc::new(Language::new(
             LanguageConfig {
@@ -3839,23 +3839,23 @@ mod tests {
         )
         .await;
 
-        let project = Project::test(fs, &mut cx);
-        project.update(&mut cx, |project, _| {
+        let project = Project::test(fs, cx);
+        project.update(cx, |project, _| {
             Arc::get_mut(&mut project.languages).unwrap().add(language);
         });
 
         let (tree, _) = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/dir/b.rs", false, cx)
             })
             .await
             .unwrap();
-        let worktree_id = tree.read_with(&cx, |tree, _| tree.id());
+        let worktree_id = tree.read_with(cx, |tree, _| tree.id());
         cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete())
             .await;
 
         let buffer = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.open_buffer(
                     ProjectPath {
                         worktree_id,
@@ -3883,7 +3883,7 @@ mod tests {
         });
 
         let mut definitions = project
-            .update(&mut cx, |project, cx| project.definition(&buffer, 22, cx))
+            .update(cx, |project, cx| project.definition(&buffer, 22, cx))
             .await
             .unwrap();
 
@@ -3934,7 +3934,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_save_file(mut cx: gpui::TestAppContext) {
+    async fn test_save_file(cx: &mut gpui::TestAppContext) {
         let fs = FakeFs::new(cx.background());
         fs.insert_tree(
             "/dir",
@@ -3944,22 +3944,22 @@ mod tests {
         )
         .await;
 
-        let project = Project::test(fs.clone(), &mut cx);
+        let project = Project::test(fs.clone(), cx);
         let worktree_id = project
-            .update(&mut cx, |p, cx| {
+            .update(cx, |p, cx| {
                 p.find_or_create_local_worktree("/dir", false, cx)
             })
             .await
             .unwrap()
             .0
-            .read_with(&cx, |tree, _| tree.id());
+            .read_with(cx, |tree, _| tree.id());
 
         let buffer = project
-            .update(&mut cx, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
+            .update(cx, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
             .await
             .unwrap();
         buffer
-            .update(&mut cx, |buffer, cx| {
+            .update(cx, |buffer, cx| {
                 assert_eq!(buffer.text(), "the old contents");
                 buffer.edit(Some(0..0), "a line of text.\n".repeat(10 * 1024), cx);
                 buffer.save(cx)
@@ -3968,11 +3968,11 @@ mod tests {
             .unwrap();
 
         let new_text = fs.load(Path::new("/dir/file1")).await.unwrap();
-        assert_eq!(new_text, buffer.read_with(&cx, |buffer, _| buffer.text()));
+        assert_eq!(new_text, buffer.read_with(cx, |buffer, _| buffer.text()));
     }
 
     #[gpui::test]
-    async fn test_save_in_single_file_worktree(mut cx: gpui::TestAppContext) {
+    async fn test_save_in_single_file_worktree(cx: &mut gpui::TestAppContext) {
         let fs = FakeFs::new(cx.background());
         fs.insert_tree(
             "/dir",
@@ -3982,22 +3982,22 @@ mod tests {
         )
         .await;
 
-        let project = Project::test(fs.clone(), &mut cx);
+        let project = Project::test(fs.clone(), cx);
         let worktree_id = project
-            .update(&mut cx, |p, cx| {
+            .update(cx, |p, cx| {
                 p.find_or_create_local_worktree("/dir/file1", false, cx)
             })
             .await
             .unwrap()
             .0
-            .read_with(&cx, |tree, _| tree.id());
+            .read_with(cx, |tree, _| tree.id());
 
         let buffer = project
-            .update(&mut cx, |p, cx| p.open_buffer((worktree_id, ""), cx))
+            .update(cx, |p, cx| p.open_buffer((worktree_id, ""), cx))
             .await
             .unwrap();
         buffer
-            .update(&mut cx, |buffer, cx| {
+            .update(cx, |buffer, cx| {
                 buffer.edit(Some(0..0), "a line of text.\n".repeat(10 * 1024), cx);
                 buffer.save(cx)
             })
@@ -4005,11 +4005,11 @@ mod tests {
             .unwrap();
 
         let new_text = fs.load(Path::new("/dir/file1")).await.unwrap();
-        assert_eq!(new_text, buffer.read_with(&cx, |buffer, _| buffer.text()));
+        assert_eq!(new_text, buffer.read_with(cx, |buffer, _| buffer.text()));
     }
 
     #[gpui::test(retries = 5)]
-    async fn test_rescan_and_remote_updates(mut cx: gpui::TestAppContext) {
+    async fn test_rescan_and_remote_updates(cx: &mut gpui::TestAppContext) {
         let dir = temp_tree(json!({
             "a": {
                 "file1": "",
@@ -4024,16 +4024,16 @@ mod tests {
             }
         }));
 
-        let project = Project::test(Arc::new(RealFs), &mut cx);
-        let rpc = project.read_with(&cx, |p, _| p.client.clone());
+        let project = Project::test(Arc::new(RealFs), cx);
+        let rpc = project.read_with(cx, |p, _| p.client.clone());
 
         let (tree, _) = project
-            .update(&mut cx, |p, cx| {
+            .update(cx, |p, cx| {
                 p.find_or_create_local_worktree(dir.path(), false, cx)
             })
             .await
             .unwrap();
-        let worktree_id = tree.read_with(&cx, |tree, _| tree.id());
+        let worktree_id = tree.read_with(cx, |tree, _| tree.id());
 
         let buffer_for_path = |path: &'static str, cx: &mut gpui::TestAppContext| {
             let buffer = project.update(cx, |p, cx| p.open_buffer((worktree_id, path), cx));
@@ -4047,10 +4047,10 @@ mod tests {
             })
         };
 
-        let buffer2 = buffer_for_path("a/file2", &mut cx).await;
-        let buffer3 = buffer_for_path("a/file3", &mut cx).await;
-        let buffer4 = buffer_for_path("b/c/file4", &mut cx).await;
-        let buffer5 = buffer_for_path("b/c/file5", &mut cx).await;
+        let buffer2 = buffer_for_path("a/file2", cx).await;
+        let buffer3 = buffer_for_path("a/file3", cx).await;
+        let buffer4 = buffer_for_path("b/c/file4", cx).await;
+        let buffer5 = buffer_for_path("b/c/file5", cx).await;
 
         let file2_id = id_for_path("a/file2", &cx);
         let file3_id = id_for_path("a/file3", &cx);
@@ -4061,7 +4061,7 @@ mod tests {
             .await;
 
         // Create a remote copy of this worktree.
-        let initial_snapshot = tree.read_with(&cx, |tree, _| tree.as_local().unwrap().snapshot());
+        let initial_snapshot = tree.read_with(cx, |tree, _| tree.as_local().unwrap().snapshot());
         let (remote, load_task) = cx.update(|cx| {
             Worktree::remote(
                 1,
@@ -4136,7 +4136,7 @@ mod tests {
 
         // Update the remote worktree. Check that it becomes consistent with the
         // local worktree.
-        remote.update(&mut cx, |remote, cx| {
+        remote.update(cx, |remote, cx| {
             let update_message = tree.read(cx).as_local().unwrap().snapshot().build_update(
                 &initial_snapshot,
                 1,
@@ -4161,7 +4161,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_buffer_deduping(mut cx: gpui::TestAppContext) {
+    async fn test_buffer_deduping(cx: &mut gpui::TestAppContext) {
         let fs = FakeFs::new(cx.background());
         fs.insert_tree(
             "/the-dir",
@@ -4172,18 +4172,18 @@ mod tests {
         )
         .await;
 
-        let project = Project::test(fs.clone(), &mut cx);
+        let project = Project::test(fs.clone(), cx);
         let worktree_id = project
-            .update(&mut cx, |p, cx| {
+            .update(cx, |p, cx| {
                 p.find_or_create_local_worktree("/the-dir", false, cx)
             })
             .await
             .unwrap()
             .0
-            .read_with(&cx, |tree, _| tree.id());
+            .read_with(cx, |tree, _| tree.id());
 
         // Spawn multiple tasks to open paths, repeating some paths.
-        let (buffer_a_1, buffer_b, buffer_a_2) = project.update(&mut cx, |p, cx| {
+        let (buffer_a_1, buffer_b, buffer_a_2) = project.update(cx, |p, cx| {
             (
                 p.open_buffer((worktree_id, "a.txt"), cx),
                 p.open_buffer((worktree_id, "b.txt"), cx),
@@ -4194,8 +4194,8 @@ mod tests {
         let buffer_a_1 = buffer_a_1.await.unwrap();
         let buffer_a_2 = buffer_a_2.await.unwrap();
         let buffer_b = buffer_b.await.unwrap();
-        assert_eq!(buffer_a_1.read_with(&cx, |b, _| b.text()), "a-contents");
-        assert_eq!(buffer_b.read_with(&cx, |b, _| b.text()), "b-contents");
+        assert_eq!(buffer_a_1.read_with(cx, |b, _| b.text()), "a-contents");
+        assert_eq!(buffer_b.read_with(cx, |b, _| b.text()), "b-contents");
 
         // There is only one buffer per path.
         let buffer_a_id = buffer_a_1.id();
@@ -4204,7 +4204,7 @@ mod tests {
         // Open the same path again while it is still open.
         drop(buffer_a_1);
         let buffer_a_3 = project
-            .update(&mut cx, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
+            .update(cx, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
             .await
             .unwrap();
 
@@ -4213,7 +4213,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_buffer_is_dirty(mut cx: gpui::TestAppContext) {
+    async fn test_buffer_is_dirty(cx: &mut gpui::TestAppContext) {
         use std::fs;
 
         let dir = temp_tree(json!({
@@ -4222,28 +4222,28 @@ mod tests {
             "file3": "ghi",
         }));
 
-        let project = Project::test(Arc::new(RealFs), &mut cx);
+        let project = Project::test(Arc::new(RealFs), cx);
         let (worktree, _) = project
-            .update(&mut cx, |p, cx| {
+            .update(cx, |p, cx| {
                 p.find_or_create_local_worktree(dir.path(), false, cx)
             })
             .await
             .unwrap();
-        let worktree_id = worktree.read_with(&cx, |worktree, _| worktree.id());
+        let worktree_id = worktree.read_with(cx, |worktree, _| worktree.id());
 
         worktree.flush_fs_events(&cx).await;
         worktree
-            .read_with(&cx, |t, _| t.as_local().unwrap().scan_complete())
+            .read_with(cx, |t, _| t.as_local().unwrap().scan_complete())
             .await;
 
         let buffer1 = project
-            .update(&mut cx, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
+            .update(cx, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
             .await
             .unwrap();
         let events = Rc::new(RefCell::new(Vec::new()));
 
         // initially, the buffer isn't dirty.
-        buffer1.update(&mut cx, |buffer, cx| {
+        buffer1.update(cx, |buffer, cx| {
             cx.subscribe(&buffer1, {
                 let events = events.clone();
                 move |_, _, event, _| events.borrow_mut().push(event.clone())
@@ -4257,7 +4257,7 @@ mod tests {
         });
 
         // after the first edit, the buffer is dirty, and emits a dirtied event.
-        buffer1.update(&mut cx, |buffer, cx| {
+        buffer1.update(cx, |buffer, cx| {
             assert!(buffer.text() == "ac");
             assert!(buffer.is_dirty());
             assert_eq!(
@@ -4269,7 +4269,7 @@ mod tests {
         });
 
         // after saving, the buffer is not dirty, and emits a saved event.
-        buffer1.update(&mut cx, |buffer, cx| {
+        buffer1.update(cx, |buffer, cx| {
             assert!(!buffer.is_dirty());
             assert_eq!(*events.borrow(), &[language::Event::Saved]);
             events.borrow_mut().clear();
@@ -4279,7 +4279,7 @@ mod tests {
         });
 
         // after editing again, the buffer is dirty, and emits another dirty event.
-        buffer1.update(&mut cx, |buffer, cx| {
+        buffer1.update(cx, |buffer, cx| {
             assert!(buffer.text() == "aBDc");
             assert!(buffer.is_dirty());
             assert_eq!(
@@ -4304,10 +4304,10 @@ mod tests {
         // When a file is deleted, the buffer is considered dirty.
         let events = Rc::new(RefCell::new(Vec::new()));
         let buffer2 = project
-            .update(&mut cx, |p, cx| p.open_buffer((worktree_id, "file2"), cx))
+            .update(cx, |p, cx| p.open_buffer((worktree_id, "file2"), cx))
             .await
             .unwrap();
-        buffer2.update(&mut cx, |_, cx| {
+        buffer2.update(cx, |_, cx| {
             cx.subscribe(&buffer2, {
                 let events = events.clone();
                 move |_, _, event, _| events.borrow_mut().push(event.clone())
@@ -4325,10 +4325,10 @@ mod tests {
         // When a file is already dirty when deleted, we don't emit a Dirtied event.
         let events = Rc::new(RefCell::new(Vec::new()));
         let buffer3 = project
-            .update(&mut cx, |p, cx| p.open_buffer((worktree_id, "file3"), cx))
+            .update(cx, |p, cx| p.open_buffer((worktree_id, "file3"), cx))
             .await
             .unwrap();
-        buffer3.update(&mut cx, |_, cx| {
+        buffer3.update(cx, |_, cx| {
             cx.subscribe(&buffer3, {
                 let events = events.clone();
                 move |_, _, event, _| events.borrow_mut().push(event.clone())
@@ -4337,7 +4337,7 @@ mod tests {
         });
 
         worktree.flush_fs_events(&cx).await;
-        buffer3.update(&mut cx, |buffer, cx| {
+        buffer3.update(cx, |buffer, cx| {
             buffer.edit(Some(0..0), "x", cx);
         });
         events.borrow_mut().clear();
@@ -4350,30 +4350,28 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_buffer_file_changes_on_disk(mut cx: gpui::TestAppContext) {
+    async fn test_buffer_file_changes_on_disk(cx: &mut gpui::TestAppContext) {
         use std::fs;
 
         let initial_contents = "aaa\nbbbbb\nc\n";
         let dir = temp_tree(json!({ "the-file": initial_contents }));
 
-        let project = Project::test(Arc::new(RealFs), &mut cx);
+        let project = Project::test(Arc::new(RealFs), cx);
         let (worktree, _) = project
-            .update(&mut cx, |p, cx| {
+            .update(cx, |p, cx| {
                 p.find_or_create_local_worktree(dir.path(), false, cx)
             })
             .await
             .unwrap();
-        let worktree_id = worktree.read_with(&cx, |tree, _| tree.id());
+        let worktree_id = worktree.read_with(cx, |tree, _| tree.id());
 
         worktree
-            .read_with(&cx, |t, _| t.as_local().unwrap().scan_complete())
+            .read_with(cx, |t, _| t.as_local().unwrap().scan_complete())
             .await;
 
         let abs_path = dir.path().join("the-file");
         let buffer = project
-            .update(&mut cx, |p, cx| {
-                p.open_buffer((worktree_id, "the-file"), cx)
-            })
+            .update(cx, |p, cx| p.open_buffer((worktree_id, "the-file"), cx))
             .await
             .unwrap();
 
@@ -4397,7 +4395,7 @@ mod tests {
 
         // Change the file on disk, adding two new lines of text, and removing
         // one line.
-        buffer.read_with(&cx, |buffer, _| {
+        buffer.read_with(cx, |buffer, _| {
             assert!(!buffer.is_dirty());
             assert!(!buffer.has_conflict());
         });
@@ -4411,7 +4409,7 @@ mod tests {
             .condition(&cx, |buffer, _| buffer.text() == new_contents)
             .await;
 
-        buffer.update(&mut cx, |buffer, _| {
+        buffer.update(cx, |buffer, _| {
             assert_eq!(buffer.text(), new_contents);
             assert!(!buffer.is_dirty());
             assert!(!buffer.has_conflict());
@@ -4433,7 +4431,7 @@ mod tests {
         });
 
         // Modify the buffer
-        buffer.update(&mut cx, |buffer, cx| {
+        buffer.update(cx, |buffer, cx| {
             buffer.edit(vec![0..0], " ", cx);
             assert!(buffer.is_dirty());
             assert!(!buffer.has_conflict());
@@ -4450,7 +4448,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_grouped_diagnostics(mut cx: gpui::TestAppContext) {
+    async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
         let fs = FakeFs::new(cx.background());
         fs.insert_tree(
             "/the-dir",
@@ -4467,17 +4465,17 @@ mod tests {
         )
         .await;
 
-        let project = Project::test(fs.clone(), &mut cx);
+        let project = Project::test(fs.clone(), cx);
         let (worktree, _) = project
-            .update(&mut cx, |p, cx| {
+            .update(cx, |p, cx| {
                 p.find_or_create_local_worktree("/the-dir", false, cx)
             })
             .await
             .unwrap();
-        let worktree_id = worktree.read_with(&cx, |tree, _| tree.id());
+        let worktree_id = worktree.read_with(cx, |tree, _| tree.id());
 
         let buffer = project
-            .update(&mut cx, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx))
+            .update(cx, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx))
             .await
             .unwrap();
 
@@ -4582,11 +4580,11 @@ mod tests {
         };
 
         project
-            .update(&mut cx, |p, cx| {
+            .update(cx, |p, cx| {
                 p.update_diagnostics(message, &Default::default(), cx)
             })
             .unwrap();
-        let buffer = buffer.read_with(&cx, |buffer, _| buffer.snapshot());
+        let buffer = buffer.read_with(cx, |buffer, _| buffer.snapshot());
 
         assert_eq!(
             buffer
@@ -4709,7 +4707,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_rename(mut cx: gpui::TestAppContext) {
+    async fn test_rename(cx: &mut gpui::TestAppContext) {
         let (language_server_config, mut fake_servers) = LanguageServerConfig::fake();
         let language = Arc::new(Language::new(
             LanguageConfig {
@@ -4731,23 +4729,23 @@ mod tests {
         )
         .await;
 
-        let project = Project::test(fs.clone(), &mut cx);
-        project.update(&mut cx, |project, _| {
+        let project = Project::test(fs.clone(), cx);
+        project.update(cx, |project, _| {
             Arc::get_mut(&mut project.languages).unwrap().add(language);
         });
 
         let (tree, _) = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/dir", false, cx)
             })
             .await
             .unwrap();
-        let worktree_id = tree.read_with(&cx, |tree, _| tree.id());
+        let worktree_id = tree.read_with(cx, |tree, _| tree.id());
         cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete())
             .await;
 
         let buffer = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.open_buffer((worktree_id, Path::new("one.rs")), cx)
             })
             .await
@@ -4755,7 +4753,7 @@ mod tests {
 
         let mut fake_server = fake_servers.next().await.unwrap();
 
-        let response = project.update(&mut cx, |project, cx| {
+        let response = project.update(cx, |project, cx| {
             project.prepare_rename(buffer.clone(), 7, cx)
         });
         fake_server
@@ -4771,10 +4769,10 @@ mod tests {
             .await
             .unwrap();
         let range = response.await.unwrap().unwrap();
-        let range = buffer.read_with(&cx, |buffer, _| range.to_offset(buffer));
+        let range = buffer.read_with(cx, |buffer, _| range.to_offset(buffer));
         assert_eq!(range, 6..9);
 
-        let response = project.update(&mut cx, |project, cx| {
+        let response = project.update(cx, |project, cx| {
             project.perform_rename(buffer.clone(), 7, "THREE".to_string(), true, cx)
         });
         fake_server
@@ -4837,7 +4835,7 @@ mod tests {
                 .remove_entry(&buffer)
                 .unwrap()
                 .0
-                .read_with(&cx, |buffer, _| buffer.text()),
+                .read_with(cx, |buffer, _| buffer.text()),
             "const THREE: usize = 1;"
         );
         assert_eq!(
@@ -4845,13 +4843,13 @@ mod tests {
                 .into_keys()
                 .next()
                 .unwrap()
-                .read_with(&cx, |buffer, _| buffer.text()),
+                .read_with(cx, |buffer, _| buffer.text()),
             "const TWO: usize = one::THREE + one::THREE;"
         );
     }
 
     #[gpui::test]
-    async fn test_search(mut cx: gpui::TestAppContext) {
+    async fn test_search(cx: &mut gpui::TestAppContext) {
         let fs = FakeFs::new(cx.background());
         fs.insert_tree(
             "/dir",
@@ -4863,19 +4861,19 @@ mod tests {
             }),
         )
         .await;
-        let project = Project::test(fs.clone(), &mut cx);
+        let project = Project::test(fs.clone(), cx);
         let (tree, _) = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/dir", false, cx)
             })
             .await
             .unwrap();
-        let worktree_id = tree.read_with(&cx, |tree, _| tree.id());
+        let worktree_id = tree.read_with(cx, |tree, _| tree.id());
         cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete())
             .await;
 
         assert_eq!(
-            search(&project, SearchQuery::text("TWO", false, true), &mut cx)
+            search(&project, SearchQuery::text("TWO", false, true), cx)
                 .await
                 .unwrap(),
             HashMap::from_iter([
@@ -4885,17 +4883,17 @@ mod tests {
         );
 
         let buffer_4 = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.open_buffer((worktree_id, "four.rs"), cx)
             })
             .await
             .unwrap();
-        buffer_4.update(&mut cx, |buffer, cx| {
+        buffer_4.update(cx, |buffer, cx| {
             buffer.edit([20..28, 31..43], "two::TWO", cx);
         });
 
         assert_eq!(
-            search(&project, SearchQuery::text("TWO", false, true), &mut cx)
+            search(&project, SearchQuery::text("TWO", false, true), cx)
                 .await
                 .unwrap(),
             HashMap::from_iter([

crates/project/src/worktree.rs 🔗

@@ -2441,7 +2441,7 @@ mod tests {
     use util::test::temp_tree;
 
     #[gpui::test]
-    async fn test_traversal(cx: gpui::TestAppContext) {
+    async fn test_traversal(cx: &mut gpui::TestAppContext) {
         let fs = FakeFs::new(cx.background());
         fs.insert_tree(
             "/root",
@@ -2470,7 +2470,7 @@ mod tests {
         cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete())
             .await;
 
-        tree.read_with(&cx, |tree, _| {
+        tree.read_with(cx, |tree, _| {
             assert_eq!(
                 tree.entries(false)
                     .map(|entry| entry.path.as_ref())
@@ -2486,7 +2486,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_rescan_with_gitignore(cx: gpui::TestAppContext) {
+    async fn test_rescan_with_gitignore(cx: &mut gpui::TestAppContext) {
         let dir = temp_tree(json!({
             ".git": {},
             ".gitignore": "ignored-dir\n",

crates/project_panel/src/project_panel.rs 🔗

@@ -589,7 +589,7 @@ mod tests {
     use workspace::WorkspaceParams;
 
     #[gpui::test]
-    async fn test_visible_list(mut cx: gpui::TestAppContext) {
+    async fn test_visible_list(cx: &mut gpui::TestAppContext) {
         let params = cx.update(WorkspaceParams::test);
         let settings = params.settings.clone();
         let fs = params.fs.as_fake();
@@ -639,28 +639,28 @@ mod tests {
             )
         });
         let (root1, _) = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/root1", false, cx)
             })
             .await
             .unwrap();
         root1
-            .read_with(&cx, |t, _| t.as_local().unwrap().scan_complete())
+            .read_with(cx, |t, _| t.as_local().unwrap().scan_complete())
             .await;
         let (root2, _) = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/root2", false, cx)
             })
             .await
             .unwrap();
         root2
-            .read_with(&cx, |t, _| t.as_local().unwrap().scan_complete())
+            .read_with(cx, |t, _| t.as_local().unwrap().scan_complete())
             .await;
 
         let (_, workspace) = cx.add_window(|cx| Workspace::new(&params, cx));
-        let panel = workspace.update(&mut cx, |_, cx| ProjectPanel::new(project, settings, cx));
+        let panel = workspace.update(cx, |_, cx| ProjectPanel::new(project, settings, cx));
         assert_eq!(
-            visible_entry_details(&panel, 0..50, &mut cx),
+            visible_entry_details(&panel, 0..50, cx),
             &[
                 EntryDetails {
                     filename: "root1".to_string(),
@@ -721,9 +721,9 @@ mod tests {
             ],
         );
 
-        toggle_expand_dir(&panel, "root1/b", &mut cx);
+        toggle_expand_dir(&panel, "root1/b", cx);
         assert_eq!(
-            visible_entry_details(&panel, 0..50, &mut cx),
+            visible_entry_details(&panel, 0..50, cx),
             &[
                 EntryDetails {
                     filename: "root1".to_string(),
@@ -799,7 +799,7 @@ mod tests {
         );
 
         assert_eq!(
-            visible_entry_details(&panel, 5..8, &mut cx),
+            visible_entry_details(&panel, 5..8, cx),
             [
                 EntryDetails {
                     filename: "4".to_string(),

crates/rpc/src/peer.rs 🔗

@@ -347,7 +347,7 @@ mod tests {
     use gpui::TestAppContext;
 
     #[gpui::test(iterations = 50)]
-    async fn test_request_response(cx: TestAppContext) {
+    async fn test_request_response(cx: &mut TestAppContext) {
         let executor = cx.foreground();
 
         // create 2 clients connected to 1 server
@@ -441,7 +441,7 @@ mod tests {
     }
 
     #[gpui::test(iterations = 50)]
-    async fn test_order_of_response_and_incoming(cx: TestAppContext) {
+    async fn test_order_of_response_and_incoming(cx: &mut TestAppContext) {
         let executor = cx.foreground();
         let server = Peer::new();
         let client = Peer::new();
@@ -539,7 +539,7 @@ mod tests {
     }
 
     #[gpui::test(iterations = 50)]
-    async fn test_dropping_request_before_completion(cx: TestAppContext) {
+    async fn test_dropping_request_before_completion(cx: &mut TestAppContext) {
         let executor = cx.foreground();
         let server = Peer::new();
         let client = Peer::new();
@@ -651,7 +651,7 @@ mod tests {
     }
 
     #[gpui::test(iterations = 50)]
-    async fn test_disconnect(cx: TestAppContext) {
+    async fn test_disconnect(cx: &mut TestAppContext) {
         let executor = cx.foreground();
 
         let (client_conn, mut server_conn, _) = Connection::in_memory(cx.background());
@@ -686,7 +686,7 @@ mod tests {
     }
 
     #[gpui::test(iterations = 50)]
-    async fn test_io_error(cx: TestAppContext) {
+    async fn test_io_error(cx: &mut TestAppContext) {
         let executor = cx.foreground();
         let (client_conn, mut server_conn, _) = Connection::in_memory(cx.background());
 

crates/search/src/buffer_search.rs 🔗

@@ -520,7 +520,7 @@ mod tests {
     use unindent::Unindent as _;
 
     #[gpui::test]
-    async fn test_search_simple(mut cx: TestAppContext) {
+    async fn test_search_simple(cx: &mut TestAppContext) {
         let fonts = cx.font_cache();
         let mut theme = gpui::fonts::with_font_cache(fonts.clone(), || theme::Theme::default());
         theme.search.match_background = Color::red();
@@ -551,11 +551,11 @@ mod tests {
 
         // Search for a string that appears with different casing.
         // By default, search is case-insensitive.
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             search_bar.set_query("us", cx);
         });
         editor.next_notification(&cx).await;
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             assert_eq!(
                 editor.all_highlighted_ranges(cx),
                 &[
@@ -572,11 +572,11 @@ mod tests {
         });
 
         // Switch to a case sensitive search.
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             search_bar.toggle_search_option(&ToggleSearchOption(SearchOption::CaseSensitive), cx);
         });
         editor.next_notification(&cx).await;
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             assert_eq!(
                 editor.all_highlighted_ranges(cx),
                 &[(
@@ -588,11 +588,11 @@ mod tests {
 
         // Search for a string that appears both as a whole word and
         // within other words. By default, all results are found.
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             search_bar.set_query("or", cx);
         });
         editor.next_notification(&cx).await;
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             assert_eq!(
                 editor.all_highlighted_ranges(cx),
                 &[
@@ -629,11 +629,11 @@ mod tests {
         });
 
         // Switch to a whole word search.
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             search_bar.toggle_search_option(&ToggleSearchOption(SearchOption::WholeWord), cx);
         });
         editor.next_notification(&cx).await;
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             assert_eq!(
                 editor.all_highlighted_ranges(cx),
                 &[
@@ -653,10 +653,10 @@ mod tests {
             );
         });
 
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             editor.select_display_ranges(&[DisplayPoint::new(0, 0)..DisplayPoint::new(0, 0)], cx);
         });
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             assert_eq!(search_bar.active_match_index, Some(0));
             search_bar.select_match(&SelectMatch(Direction::Next), cx);
             assert_eq!(
@@ -664,82 +664,82 @@ mod tests {
                 [DisplayPoint::new(0, 41)..DisplayPoint::new(0, 43)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(0));
         });
 
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             search_bar.select_match(&SelectMatch(Direction::Next), cx);
             assert_eq!(
                 editor.update(cx, |editor, cx| editor.selected_display_ranges(cx)),
                 [DisplayPoint::new(3, 11)..DisplayPoint::new(3, 13)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(1));
         });
 
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             search_bar.select_match(&SelectMatch(Direction::Next), cx);
             assert_eq!(
                 editor.update(cx, |editor, cx| editor.selected_display_ranges(cx)),
                 [DisplayPoint::new(3, 56)..DisplayPoint::new(3, 58)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(2));
         });
 
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             search_bar.select_match(&SelectMatch(Direction::Next), cx);
             assert_eq!(
                 editor.update(cx, |editor, cx| editor.selected_display_ranges(cx)),
                 [DisplayPoint::new(0, 41)..DisplayPoint::new(0, 43)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(0));
         });
 
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             search_bar.select_match(&SelectMatch(Direction::Prev), cx);
             assert_eq!(
                 editor.update(cx, |editor, cx| editor.selected_display_ranges(cx)),
                 [DisplayPoint::new(3, 56)..DisplayPoint::new(3, 58)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(2));
         });
 
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             search_bar.select_match(&SelectMatch(Direction::Prev), cx);
             assert_eq!(
                 editor.update(cx, |editor, cx| editor.selected_display_ranges(cx)),
                 [DisplayPoint::new(3, 11)..DisplayPoint::new(3, 13)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(1));
         });
 
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             search_bar.select_match(&SelectMatch(Direction::Prev), cx);
             assert_eq!(
                 editor.update(cx, |editor, cx| editor.selected_display_ranges(cx)),
                 [DisplayPoint::new(0, 41)..DisplayPoint::new(0, 43)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(0));
         });
 
         // Park the cursor in between matches and ensure that going to the previous match selects
         // the closest match to the left.
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             editor.select_display_ranges(&[DisplayPoint::new(1, 0)..DisplayPoint::new(1, 0)], cx);
         });
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             assert_eq!(search_bar.active_match_index, Some(1));
             search_bar.select_match(&SelectMatch(Direction::Prev), cx);
             assert_eq!(
@@ -747,16 +747,16 @@ mod tests {
                 [DisplayPoint::new(0, 41)..DisplayPoint::new(0, 43)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(0));
         });
 
         // Park the cursor in between matches and ensure that going to the next match selects the
         // closest match to the right.
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             editor.select_display_ranges(&[DisplayPoint::new(1, 0)..DisplayPoint::new(1, 0)], cx);
         });
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             assert_eq!(search_bar.active_match_index, Some(1));
             search_bar.select_match(&SelectMatch(Direction::Next), cx);
             assert_eq!(
@@ -764,16 +764,16 @@ mod tests {
                 [DisplayPoint::new(3, 11)..DisplayPoint::new(3, 13)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(1));
         });
 
         // Park the cursor after the last match and ensure that going to the previous match selects
         // the last match.
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             editor.select_display_ranges(&[DisplayPoint::new(3, 60)..DisplayPoint::new(3, 60)], cx);
         });
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             assert_eq!(search_bar.active_match_index, Some(2));
             search_bar.select_match(&SelectMatch(Direction::Prev), cx);
             assert_eq!(
@@ -781,16 +781,16 @@ mod tests {
                 [DisplayPoint::new(3, 56)..DisplayPoint::new(3, 58)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(2));
         });
 
         // Park the cursor after the last match and ensure that going to the next match selects the
         // first match.
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             editor.select_display_ranges(&[DisplayPoint::new(3, 60)..DisplayPoint::new(3, 60)], cx);
         });
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             assert_eq!(search_bar.active_match_index, Some(2));
             search_bar.select_match(&SelectMatch(Direction::Next), cx);
             assert_eq!(
@@ -798,16 +798,16 @@ mod tests {
                 [DisplayPoint::new(0, 41)..DisplayPoint::new(0, 43)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(0));
         });
 
         // Park the cursor before the first match and ensure that going to the previous match
         // selects the last match.
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             editor.select_display_ranges(&[DisplayPoint::new(0, 0)..DisplayPoint::new(0, 0)], cx);
         });
-        search_bar.update(&mut cx, |search_bar, cx| {
+        search_bar.update(cx, |search_bar, cx| {
             assert_eq!(search_bar.active_match_index, Some(0));
             search_bar.select_match(&SelectMatch(Direction::Prev), cx);
             assert_eq!(
@@ -815,7 +815,7 @@ mod tests {
                 [DisplayPoint::new(3, 56)..DisplayPoint::new(3, 58)]
             );
         });
-        search_bar.read_with(&cx, |search_bar, _| {
+        search_bar.read_with(cx, |search_bar, _| {
             assert_eq!(search_bar.active_match_index, Some(2));
         });
     }

crates/search/src/project_search.rs 🔗

@@ -714,7 +714,7 @@ mod tests {
     use std::sync::Arc;
 
     #[gpui::test]
-    async fn test_project_search(mut cx: TestAppContext) {
+    async fn test_project_search(cx: &mut TestAppContext) {
         let fonts = cx.font_cache();
         let mut theme = gpui::fonts::with_font_cache(fonts.clone(), || theme::Theme::default());
         theme.search.match_background = Color::red();
@@ -732,9 +732,9 @@ mod tests {
             }),
         )
         .await;
-        let project = Project::test(fs.clone(), &mut cx);
+        let project = Project::test(fs.clone(), cx);
         let (tree, _) = project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/dir", false, cx)
             })
             .await
@@ -747,14 +747,14 @@ mod tests {
             ProjectSearchView::new(search.clone(), None, settings, cx)
         });
 
-        search_view.update(&mut cx, |search_view, cx| {
+        search_view.update(cx, |search_view, cx| {
             search_view
                 .query_editor
                 .update(cx, |query_editor, cx| query_editor.set_text("TWO", cx));
             search_view.search(&Search, cx);
         });
         search_view.next_notification(&cx).await;
-        search_view.update(&mut cx, |search_view, cx| {
+        search_view.update(cx, |search_view, cx| {
             assert_eq!(
                 search_view
                     .results_editor
@@ -791,7 +791,7 @@ mod tests {
             search_view.select_match(&SelectMatch(Direction::Next), cx);
         });
 
-        search_view.update(&mut cx, |search_view, cx| {
+        search_view.update(cx, |search_view, cx| {
             assert_eq!(search_view.active_match_index, Some(1));
             assert_eq!(
                 search_view
@@ -802,7 +802,7 @@ mod tests {
             search_view.select_match(&SelectMatch(Direction::Next), cx);
         });
 
-        search_view.update(&mut cx, |search_view, cx| {
+        search_view.update(cx, |search_view, cx| {
             assert_eq!(search_view.active_match_index, Some(2));
             assert_eq!(
                 search_view
@@ -813,7 +813,7 @@ mod tests {
             search_view.select_match(&SelectMatch(Direction::Next), cx);
         });
 
-        search_view.update(&mut cx, |search_view, cx| {
+        search_view.update(cx, |search_view, cx| {
             assert_eq!(search_view.active_match_index, Some(0));
             assert_eq!(
                 search_view
@@ -824,7 +824,7 @@ mod tests {
             search_view.select_match(&SelectMatch(Direction::Prev), cx);
         });
 
-        search_view.update(&mut cx, |search_view, cx| {
+        search_view.update(cx, |search_view, cx| {
             assert_eq!(search_view.active_match_index, Some(2));
             assert_eq!(
                 search_view
@@ -835,7 +835,7 @@ mod tests {
             search_view.select_match(&SelectMatch(Direction::Prev), cx);
         });
 
-        search_view.update(&mut cx, |search_view, cx| {
+        search_view.update(cx, |search_view, cx| {
             assert_eq!(search_view.active_match_index, Some(1));
             assert_eq!(
                 search_view

crates/server/src/db.rs 🔗

@@ -627,7 +627,7 @@ pub mod tests {
     use util::post_inc;
 
     #[gpui::test]
-    async fn test_get_users_by_ids(cx: TestAppContext) {
+    async fn test_get_users_by_ids(cx: &mut TestAppContext) {
         for test_db in [TestDb::postgres(), TestDb::fake(cx.background())] {
             let db = test_db.db();
 
@@ -667,7 +667,7 @@ pub mod tests {
     }
 
     #[gpui::test]
-    async fn test_recent_channel_messages(cx: TestAppContext) {
+    async fn test_recent_channel_messages(cx: &mut TestAppContext) {
         for test_db in [TestDb::postgres(), TestDb::fake(cx.background())] {
             let db = test_db.db();
             let user = db.create_user("user", false).await.unwrap();
@@ -703,7 +703,7 @@ pub mod tests {
     }
 
     #[gpui::test]
-    async fn test_channel_message_nonces(cx: TestAppContext) {
+    async fn test_channel_message_nonces(cx: &mut TestAppContext) {
         for test_db in [TestDb::postgres(), TestDb::fake(cx.background())] {
             let db = test_db.db();
             let user = db.create_user("user", false).await.unwrap();

crates/server/src/rpc.rs 🔗

@@ -1037,7 +1037,7 @@ mod tests {
     }
 
     #[gpui::test(iterations = 10)]
-    async fn test_share_project(mut cx_a: TestAppContext, mut cx_b: TestAppContext) {
+    async fn test_share_project(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext) {
         let (window_b, _) = cx_b.add_window(|_| EmptyView);
         let lang_registry = Arc::new(LanguageRegistry::new());
         let fs = FakeFs::new(cx_a.background());
@@ -1045,8 +1045,8 @@ mod tests {
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         fs.insert_tree(
@@ -1068,20 +1068,17 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/a", false, cx)
             })
             .await
             .unwrap();
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
 
         // Join that project as client B
         let project_b = Project::remote(
@@ -1095,7 +1092,7 @@ mod tests {
         .await
         .unwrap();
 
-        let replica_id_b = project_b.read_with(&cx_b, |project, _| {
+        let replica_id_b = project_b.read_with(cx_b, |project, _| {
             assert_eq!(
                 project
                     .collaborators()
@@ -1120,18 +1117,18 @@ mod tests {
 
         // Open the same file as client B and client A.
         let buffer_b = project_b
-            .update(&mut cx_b, |p, cx| p.open_buffer((worktree_id, "b.txt"), cx))
+            .update(cx_b, |p, cx| p.open_buffer((worktree_id, "b.txt"), cx))
             .await
             .unwrap();
         let buffer_b = cx_b.add_model(|cx| MultiBuffer::singleton(buffer_b, cx));
-        buffer_b.read_with(&cx_b, |buf, cx| {
+        buffer_b.read_with(cx_b, |buf, cx| {
             assert_eq!(buf.read(cx).text(), "b-contents")
         });
-        project_a.read_with(&cx_a, |project, cx| {
+        project_a.read_with(cx_a, |project, cx| {
             assert!(project.has_open_buffer((worktree_id, "b.txt"), cx))
         });
         let buffer_a = project_a
-            .update(&mut cx_a, |p, cx| p.open_buffer((worktree_id, "b.txt"), cx))
+            .update(cx_a, |p, cx| p.open_buffer((worktree_id, "b.txt"), cx))
             .await
             .unwrap();
 
@@ -1151,7 +1148,7 @@ mod tests {
         //     .await;
 
         // Edit the buffer as client B and see that edit as client A.
-        editor_b.update(&mut cx_b, |editor, cx| {
+        editor_b.update(cx_b, |editor, cx| {
             editor.handle_input(&Input("ok, ".into()), cx)
         });
         buffer_a
@@ -1173,15 +1170,15 @@ mod tests {
     }
 
     #[gpui::test(iterations = 10)]
-    async fn test_unshare_project(mut cx_a: TestAppContext, mut cx_b: TestAppContext) {
+    async fn test_unshare_project(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext) {
         let lang_registry = Arc::new(LanguageRegistry::new());
         let fs = FakeFs::new(cx_a.background());
         cx_a.foreground().forbid_parking();
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         fs.insert_tree(
@@ -1203,21 +1200,18 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/a", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
-        assert!(worktree_a.read_with(&cx_a, |tree, _| tree.as_local().unwrap().is_shared()));
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
+        assert!(worktree_a.read_with(cx_a, |tree, _| tree.as_local().unwrap().is_shared()));
 
         // Join that project as client B
         let project_b = Project::remote(
@@ -1231,27 +1225,27 @@ mod tests {
         .await
         .unwrap();
         project_b
-            .update(&mut cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
+            .update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
             .await
             .unwrap();
 
         // Unshare the project as client A
         project_a
-            .update(&mut cx_a, |project, cx| project.unshare(cx))
+            .update(cx_a, |project, cx| project.unshare(cx))
             .await
             .unwrap();
         project_b
-            .condition(&mut cx_b, |project, _| project.is_read_only())
+            .condition(cx_b, |project, _| project.is_read_only())
             .await;
-        assert!(worktree_a.read_with(&cx_a, |tree, _| !tree.as_local().unwrap().is_shared()));
+        assert!(worktree_a.read_with(cx_a, |tree, _| !tree.as_local().unwrap().is_shared()));
         drop(project_b);
 
         // Share the project again and ensure guests can still join.
         project_a
-            .update(&mut cx_a, |project, cx| project.share(cx))
+            .update(cx_a, |project, cx| project.share(cx))
             .await
             .unwrap();
-        assert!(worktree_a.read_with(&cx_a, |tree, _| tree.as_local().unwrap().is_shared()));
+        assert!(worktree_a.read_with(cx_a, |tree, _| tree.as_local().unwrap().is_shared()));
 
         let project_c = Project::remote(
             project_id,
@@ -1264,16 +1258,16 @@ mod tests {
         .await
         .unwrap();
         project_c
-            .update(&mut cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
+            .update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
             .await
             .unwrap();
     }
 
     #[gpui::test(iterations = 10)]
     async fn test_propagate_saves_and_fs_changes(
-        mut cx_a: TestAppContext,
-        mut cx_b: TestAppContext,
-        mut cx_c: TestAppContext,
+        cx_a: &mut TestAppContext,
+        cx_b: &mut TestAppContext,
+        cx_c: &mut TestAppContext,
     ) {
         let lang_registry = Arc::new(LanguageRegistry::new());
         let fs = FakeFs::new(cx_a.background());
@@ -1281,9 +1275,9 @@ mod tests {
 
         // Connect to a server as 3 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
-        let client_c = server.create_client(&mut cx_c, "user_c").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
+        let client_c = server.create_client(cx_c, "user_c").await;
 
         // Share a worktree as client A.
         fs.insert_tree(
@@ -1305,20 +1299,17 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/a", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
 
         // Join that worktree as clients B and C.
         let project_b = Project::remote(
@@ -1341,56 +1332,56 @@ mod tests {
         )
         .await
         .unwrap();
-        let worktree_b = project_b.read_with(&cx_b, |p, cx| p.worktrees(cx).next().unwrap());
-        let worktree_c = project_c.read_with(&cx_c, |p, cx| p.worktrees(cx).next().unwrap());
+        let worktree_b = project_b.read_with(cx_b, |p, cx| p.worktrees(cx).next().unwrap());
+        let worktree_c = project_c.read_with(cx_c, |p, cx| p.worktrees(cx).next().unwrap());
 
         // Open and edit a buffer as both guests B and C.
         let buffer_b = project_b
-            .update(&mut cx_b, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
+            .update(cx_b, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
             .await
             .unwrap();
         let buffer_c = project_c
-            .update(&mut cx_c, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
+            .update(cx_c, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
             .await
             .unwrap();
-        buffer_b.update(&mut cx_b, |buf, cx| buf.edit([0..0], "i-am-b, ", cx));
-        buffer_c.update(&mut cx_c, |buf, cx| buf.edit([0..0], "i-am-c, ", cx));
+        buffer_b.update(cx_b, |buf, cx| buf.edit([0..0], "i-am-b, ", cx));
+        buffer_c.update(cx_c, |buf, cx| buf.edit([0..0], "i-am-c, ", cx));
 
         // Open and edit that buffer as the host.
         let buffer_a = project_a
-            .update(&mut cx_a, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
+            .update(cx_a, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
             .await
             .unwrap();
 
         buffer_a
-            .condition(&mut cx_a, |buf, _| buf.text() == "i-am-c, i-am-b, ")
+            .condition(cx_a, |buf, _| buf.text() == "i-am-c, i-am-b, ")
             .await;
-        buffer_a.update(&mut cx_a, |buf, cx| {
+        buffer_a.update(cx_a, |buf, cx| {
             buf.edit([buf.len()..buf.len()], "i-am-a", cx)
         });
 
         // Wait for edits to propagate
         buffer_a
-            .condition(&mut cx_a, |buf, _| buf.text() == "i-am-c, i-am-b, i-am-a")
+            .condition(cx_a, |buf, _| buf.text() == "i-am-c, i-am-b, i-am-a")
             .await;
         buffer_b
-            .condition(&mut cx_b, |buf, _| buf.text() == "i-am-c, i-am-b, i-am-a")
+            .condition(cx_b, |buf, _| buf.text() == "i-am-c, i-am-b, i-am-a")
             .await;
         buffer_c
-            .condition(&mut cx_c, |buf, _| buf.text() == "i-am-c, i-am-b, i-am-a")
+            .condition(cx_c, |buf, _| buf.text() == "i-am-c, i-am-b, i-am-a")
             .await;
 
         // Edit the buffer as the host and concurrently save as guest B.
-        let save_b = buffer_b.update(&mut cx_b, |buf, cx| buf.save(cx));
-        buffer_a.update(&mut cx_a, |buf, cx| buf.edit([0..0], "hi-a, ", cx));
+        let save_b = buffer_b.update(cx_b, |buf, cx| buf.save(cx));
+        buffer_a.update(cx_a, |buf, cx| buf.edit([0..0], "hi-a, ", cx));
         save_b.await.unwrap();
         assert_eq!(
             fs.load("/a/file1".as_ref()).await.unwrap(),
             "hi-a, i-am-c, i-am-b, i-am-a"
         );
-        buffer_a.read_with(&cx_a, |buf, _| assert!(!buf.is_dirty()));
-        buffer_b.read_with(&cx_b, |buf, _| assert!(!buf.is_dirty()));
-        buffer_c.condition(&cx_c, |buf, _| !buf.is_dirty()).await;
+        buffer_a.read_with(cx_a, |buf, _| assert!(!buf.is_dirty()));
+        buffer_b.read_with(cx_b, |buf, _| assert!(!buf.is_dirty()));
+        buffer_c.condition(cx_c, |buf, _| !buf.is_dirty()).await;
 
         // Make changes on host's file system, see those changes on guest worktrees.
         fs.rename(
@@ -1450,15 +1441,15 @@ mod tests {
     }
 
     #[gpui::test(iterations = 10)]
-    async fn test_buffer_conflict_after_save(mut cx_a: TestAppContext, mut cx_b: TestAppContext) {
+    async fn test_buffer_conflict_after_save(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext) {
         cx_a.foreground().forbid_parking();
         let lang_registry = Arc::new(LanguageRegistry::new());
         let fs = FakeFs::new(cx_a.background());
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         fs.insert_tree(
@@ -1480,20 +1471,17 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/dir", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
 
         // Join that project as client B
         let project_b = Project::remote(
@@ -1509,44 +1497,41 @@ mod tests {
 
         // Open a buffer as client B
         let buffer_b = project_b
-            .update(&mut cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
+            .update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
             .await
             .unwrap();
 
-        buffer_b.update(&mut cx_b, |buf, cx| buf.edit([0..0], "world ", cx));
-        buffer_b.read_with(&cx_b, |buf, _| {
+        buffer_b.update(cx_b, |buf, cx| buf.edit([0..0], "world ", cx));
+        buffer_b.read_with(cx_b, |buf, _| {
             assert!(buf.is_dirty());
             assert!(!buf.has_conflict());
         });
 
-        buffer_b
-            .update(&mut cx_b, |buf, cx| buf.save(cx))
-            .await
-            .unwrap();
+        buffer_b.update(cx_b, |buf, cx| buf.save(cx)).await.unwrap();
         buffer_b
             .condition(&cx_b, |buffer_b, _| !buffer_b.is_dirty())
             .await;
-        buffer_b.read_with(&cx_b, |buf, _| {
+        buffer_b.read_with(cx_b, |buf, _| {
             assert!(!buf.has_conflict());
         });
 
-        buffer_b.update(&mut cx_b, |buf, cx| buf.edit([0..0], "hello ", cx));
-        buffer_b.read_with(&cx_b, |buf, _| {
+        buffer_b.update(cx_b, |buf, cx| buf.edit([0..0], "hello ", cx));
+        buffer_b.read_with(cx_b, |buf, _| {
             assert!(buf.is_dirty());
             assert!(!buf.has_conflict());
         });
     }
 
     #[gpui::test(iterations = 10)]
-    async fn test_buffer_reloading(mut cx_a: TestAppContext, mut cx_b: TestAppContext) {
+    async fn test_buffer_reloading(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext) {
         cx_a.foreground().forbid_parking();
         let lang_registry = Arc::new(LanguageRegistry::new());
         let fs = FakeFs::new(cx_a.background());
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         fs.insert_tree(
@@ -1568,20 +1553,17 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/dir", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
 
         // Join that project as client B
         let project_b = Project::remote(
@@ -1594,14 +1576,14 @@ mod tests {
         )
         .await
         .unwrap();
-        let _worktree_b = project_b.update(&mut cx_b, |p, cx| p.worktrees(cx).next().unwrap());
+        let _worktree_b = project_b.update(cx_b, |p, cx| p.worktrees(cx).next().unwrap());
 
         // Open a buffer as client B
         let buffer_b = project_b
-            .update(&mut cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
+            .update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
             .await
             .unwrap();
-        buffer_b.read_with(&cx_b, |buf, _| {
+        buffer_b.read_with(cx_b, |buf, _| {
             assert!(!buf.is_dirty());
             assert!(!buf.has_conflict());
         });
@@ -1614,15 +1596,15 @@ mod tests {
                 buf.text() == "new contents" && !buf.is_dirty()
             })
             .await;
-        buffer_b.read_with(&cx_b, |buf, _| {
+        buffer_b.read_with(cx_b, |buf, _| {
             assert!(!buf.has_conflict());
         });
     }
 
     #[gpui::test(iterations = 10)]
     async fn test_editing_while_guest_opens_buffer(
-        mut cx_a: TestAppContext,
-        mut cx_b: TestAppContext,
+        cx_a: &mut TestAppContext,
+        cx_b: &mut TestAppContext,
     ) {
         cx_a.foreground().forbid_parking();
         let lang_registry = Arc::new(LanguageRegistry::new());
@@ -1630,8 +1612,8 @@ mod tests {
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         fs.insert_tree(
@@ -1652,20 +1634,17 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/dir", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
 
         // Join that project as client B
         let project_b = Project::remote(
@@ -1681,30 +1660,30 @@ mod tests {
 
         // Open a buffer as client A
         let buffer_a = project_a
-            .update(&mut cx_a, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
+            .update(cx_a, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
             .await
             .unwrap();
 
         // Start opening the same buffer as client B
         let buffer_b = cx_b
             .background()
-            .spawn(project_b.update(&mut cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx)));
+            .spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx)));
 
         // Edit the buffer as client A while client B is still opening it.
         cx_b.background().simulate_random_delay().await;
-        buffer_a.update(&mut cx_a, |buf, cx| buf.edit([0..0], "X", cx));
+        buffer_a.update(cx_a, |buf, cx| buf.edit([0..0], "X", cx));
         cx_b.background().simulate_random_delay().await;
-        buffer_a.update(&mut cx_a, |buf, cx| buf.edit([1..1], "Y", cx));
+        buffer_a.update(cx_a, |buf, cx| buf.edit([1..1], "Y", cx));
 
-        let text = buffer_a.read_with(&cx_a, |buf, _| buf.text());
+        let text = buffer_a.read_with(cx_a, |buf, _| buf.text());
         let buffer_b = buffer_b.await.unwrap();
         buffer_b.condition(&cx_b, |buf, _| buf.text() == text).await;
     }
 
     #[gpui::test(iterations = 10)]
     async fn test_leaving_worktree_while_opening_buffer(
-        mut cx_a: TestAppContext,
-        mut cx_b: TestAppContext,
+        cx_a: &mut TestAppContext,
+        cx_b: &mut TestAppContext,
     ) {
         cx_a.foreground().forbid_parking();
         let lang_registry = Arc::new(LanguageRegistry::new());
@@ -1712,8 +1691,8 @@ mod tests {
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         fs.insert_tree(
@@ -1734,20 +1713,17 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/dir", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
 
         // Join that project as client B
         let project_b = Project::remote(
@@ -1769,7 +1745,7 @@ mod tests {
         // Begin opening a buffer as client B, but leave the project before the open completes.
         let buffer_b = cx_b
             .background()
-            .spawn(project_b.update(&mut cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx)));
+            .spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx)));
         cx_b.update(|_| drop(project_b));
         drop(buffer_b);
 
@@ -1780,15 +1756,15 @@ mod tests {
     }
 
     #[gpui::test(iterations = 10)]
-    async fn test_peer_disconnection(mut cx_a: TestAppContext, mut cx_b: TestAppContext) {
+    async fn test_peer_disconnection(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext) {
         cx_a.foreground().forbid_parking();
         let lang_registry = Arc::new(LanguageRegistry::new());
         let fs = FakeFs::new(cx_a.background());
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         fs.insert_tree(
@@ -1810,19 +1786,19 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/a", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
         let project_id = project_a
-            .update(&mut cx_a, |project, _| project.next_remote_id())
+            .update(cx_a, |project, _| project.next_remote_id())
             .await;
         project_a
-            .update(&mut cx_a, |project, cx| project.share(cx))
+            .update(cx_a, |project, cx| project.share(cx))
             .await
             .unwrap();
 
@@ -1852,8 +1828,8 @@ mod tests {
 
     #[gpui::test(iterations = 10)]
     async fn test_collaborating_with_diagnostics(
-        mut cx_a: TestAppContext,
-        mut cx_b: TestAppContext,
+        cx_a: &mut TestAppContext,
+        cx_b: &mut TestAppContext,
     ) {
         cx_a.foreground().forbid_parking();
         let mut lang_registry = Arc::new(LanguageRegistry::new());
@@ -1875,8 +1851,8 @@ mod tests {
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         fs.insert_tree(
@@ -1898,25 +1874,22 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/a", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
 
         // Cause the language server to start.
         let _ = cx_a
             .background()
-            .spawn(project_a.update(&mut cx_a, |project, cx| {
+            .spawn(project_a.update(cx_a, |project, cx| {
                 project.open_buffer(
                     ProjectPath {
                         worktree_id,
@@ -1972,7 +1945,7 @@ mod tests {
         .await
         .unwrap();
 
-        project_b.read_with(&cx_b, |project, cx| {
+        project_b.read_with(cx_b, |project, cx| {
             assert_eq!(
                 project.diagnostic_summaries(cx).collect::<Vec<_>>(),
                 &[(
@@ -2035,11 +2008,11 @@ mod tests {
         // Open the file with the errors on client B. They should be present.
         let buffer_b = cx_b
             .background()
-            .spawn(project_b.update(&mut cx_b, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx)))
+            .spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx)))
             .await
             .unwrap();
 
-        buffer_b.read_with(&cx_b, |buffer, _| {
+        buffer_b.read_with(cx_b, |buffer, _| {
             assert_eq!(
                 buffer
                     .snapshot()
@@ -2074,8 +2047,8 @@ mod tests {
 
     #[gpui::test(iterations = 10)]
     async fn test_collaborating_with_completion(
-        mut cx_a: TestAppContext,
-        mut cx_b: TestAppContext,
+        cx_a: &mut TestAppContext,
+        cx_b: &mut TestAppContext,
     ) {
         cx_a.foreground().forbid_parking();
         let mut lang_registry = Arc::new(LanguageRegistry::new());
@@ -2104,8 +2077,8 @@ mod tests {
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         fs.insert_tree(
@@ -2127,20 +2100,17 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/a", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
 
         // Join the worktree as client B.
         let project_b = Project::remote(
@@ -2156,9 +2126,7 @@ mod tests {
 
         // Open a file in an editor as the guest.
         let buffer_b = project_b
-            .update(&mut cx_b, |p, cx| {
-                p.open_buffer((worktree_id, "main.rs"), cx)
-            })
+            .update(cx_b, |p, cx| p.open_buffer((worktree_id, "main.rs"), cx))
             .await
             .unwrap();
         let (window_b, _) = cx_b.add_window(|_| EmptyView);
@@ -2177,7 +2145,7 @@ mod tests {
             .await;
 
         // Type a completion trigger character as the guest.
-        editor_b.update(&mut cx_b, |editor, cx| {
+        editor_b.update(cx_b, |editor, cx| {
             editor.select_ranges([13..13], None, cx);
             editor.handle_input(&Input(".".into()), cx);
             cx.focus(&editor_b);
@@ -2233,9 +2201,7 @@ mod tests {
 
         // Open the buffer on the host.
         let buffer_a = project_a
-            .update(&mut cx_a, |p, cx| {
-                p.open_buffer((worktree_id, "main.rs"), cx)
-            })
+            .update(cx_a, |p, cx| p.open_buffer((worktree_id, "main.rs"), cx))
             .await
             .unwrap();
         buffer_a
@@ -2246,7 +2212,7 @@ mod tests {
         editor_b
             .condition(&cx_b, |editor, _| editor.context_menu_visible())
             .await;
-        editor_b.update(&mut cx_b, |editor, cx| {
+        editor_b.update(cx_b, |editor, cx| {
             editor.confirm_completion(&ConfirmCompletion(Some(0)), cx);
             assert_eq!(editor.text(cx), "fn main() { a.first_method() }");
         });
@@ -2290,7 +2256,7 @@ mod tests {
     }
 
     #[gpui::test(iterations = 10)]
-    async fn test_formatting_buffer(mut cx_a: TestAppContext, mut cx_b: TestAppContext) {
+    async fn test_formatting_buffer(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext) {
         cx_a.foreground().forbid_parking();
         let mut lang_registry = Arc::new(LanguageRegistry::new());
         let fs = FakeFs::new(cx_a.background());
@@ -2311,8 +2277,8 @@ mod tests {
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         fs.insert_tree(
@@ -2333,20 +2299,17 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/a", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
 
         // Join the worktree as client B.
         let project_b = Project::remote(
@@ -2362,11 +2325,11 @@ mod tests {
 
         let buffer_b = cx_b
             .background()
-            .spawn(project_b.update(&mut cx_b, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx)))
+            .spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx)))
             .await
             .unwrap();
 
-        let format = project_b.update(&mut cx_b, |project, cx| {
+        let format = project_b.update(cx_b, |project, cx| {
             project.format(HashSet::from_iter([buffer_b.clone()]), true, cx)
         });
 
@@ -2386,13 +2349,13 @@ mod tests {
 
         format.await.unwrap();
         assert_eq!(
-            buffer_b.read_with(&cx_b, |buffer, _| buffer.text()),
+            buffer_b.read_with(cx_b, |buffer, _| buffer.text()),
             "let honey = two"
         );
     }
 
     #[gpui::test(iterations = 10)]
-    async fn test_definition(mut cx_a: TestAppContext, mut cx_b: TestAppContext) {
+    async fn test_definition(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext) {
         cx_a.foreground().forbid_parking();
         let mut lang_registry = Arc::new(LanguageRegistry::new());
         let fs = FakeFs::new(cx_a.background());
@@ -2428,8 +2391,8 @@ mod tests {
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         let project_a = cx_a.update(|cx| {
@@ -2442,20 +2405,17 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/root-1", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
 
         // Join the worktree as client B.
         let project_b = Project::remote(
@@ -2472,12 +2432,12 @@ mod tests {
         // Open the file on client B.
         let buffer_b = cx_b
             .background()
-            .spawn(project_b.update(&mut cx_b, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx)))
+            .spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx)))
             .await
             .unwrap();
 
         // Request the definition of a symbol as the guest.
-        let definitions_1 = project_b.update(&mut cx_b, |p, cx| p.definition(&buffer_b, 23, cx));
+        let definitions_1 = project_b.update(cx_b, |p, cx| p.definition(&buffer_b, 23, cx));
 
         let mut fake_language_server = fake_language_servers.next().await.unwrap();
         fake_language_server.handle_request::<lsp::request::GotoDefinition, _>(|_, _| {
@@ -2504,7 +2464,7 @@ mod tests {
 
         // Try getting more definitions for the same buffer, ensuring the buffer gets reused from
         // the previous call to `definition`.
-        let definitions_2 = project_b.update(&mut cx_b, |p, cx| p.definition(&buffer_b, 33, cx));
+        let definitions_2 = project_b.update(cx_b, |p, cx| p.definition(&buffer_b, 33, cx));
         fake_language_server.handle_request::<lsp::request::GotoDefinition, _>(|_, _| {
             Some(lsp::GotoDefinitionResponse::Scalar(lsp::Location::new(
                 lsp::Url::from_file_path("/root-2/b.rs").unwrap(),
@@ -2530,7 +2490,7 @@ mod tests {
     }
 
     #[gpui::test(iterations = 10)]
-    async fn test_references(mut cx_a: TestAppContext, mut cx_b: TestAppContext) {
+    async fn test_references(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext) {
         cx_a.foreground().forbid_parking();
         let mut lang_registry = Arc::new(LanguageRegistry::new());
         let fs = FakeFs::new(cx_a.background());
@@ -2567,8 +2527,8 @@ mod tests {
 
         // Connect to a server as 2 clients.
         let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
-        let client_a = server.create_client(&mut cx_a, "user_a").await;
-        let client_b = server.create_client(&mut cx_b, "user_b").await;
+        let client_a = server.create_client(cx_a, "user_a").await;
+        let client_b = server.create_client(cx_b, "user_b").await;
 
         // Share a project as client A
         let project_a = cx_a.update(|cx| {
@@ -2581,20 +2541,17 @@ mod tests {
             )
         });
         let (worktree_a, _) = project_a
-            .update(&mut cx_a, |p, cx| {
+            .update(cx_a, |p, cx| {
                 p.find_or_create_local_worktree("/root-1", false, cx)
             })
             .await
             .unwrap();
         worktree_a
-            .read_with(&cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
+            .read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
             .await;
-        let project_id = project_a.update(&mut cx_a, |p, _| p.next_remote_id()).await;
-        let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
-        project_a
-            .update(&mut cx_a, |p, cx| p.share(cx))
-            .await
-            .unwrap();
+        let project_id = project_a.update(cx_a, |p, _| p.next_remote_id()).await;
+        let worktree_id = worktree_a.read_with(cx_a, |tree, _| tree.id());
+        project_a.update(cx_a, |p, cx| p.share(cx)).await.unwrap();
 
         // Join the worktree as client B.
         let project_b = Project::remote(
@@ -2611,14 +2568,12 @@ mod tests {
         // Open the file on client B.
         let buffer_b = cx_b
             .background()
-            .spawn(project_b.update(&mut cx_b, |p, cx| {
-                p.open_buffer((worktree_id, "one.rs"), cx)
-            }))
+            .spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "one.rs"), cx)))
             .await
             .unwrap();
 
         // Request references to a symbol as the guest.
-        let references = project_b.update(&mut cx_b, |p, cx| p.references(&buffer_b, 7, cx));
+        let references = project_b.update(cx_b, |p, cx| p.references(&buffer_b, 7, cx));
 
         let mut fake_language_server = fake_language_servers.next().await.unwrap();
         fake_language_server.handle_request::<lsp::request::References, _>(|params, _| {
@@ -2666,7 +2621,7 @@ mod tests {
     }
 
     #[gpui::test(iterations = 10)]
-    async fn test_project_search(mut cx_a: TestAppContext, mut cx_b: TestAppContext) {
+    async fn test_project_search(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext) {
         cx_a.foreground().forbid_parking();
         let lang_registry = Arc::new(LanguageRegistry::new());
         let fs = FakeFs::new(cx_a.background());

crates/zed/src/zed.rs 🔗

@@ -152,7 +152,7 @@ mod tests {
     };
 
     #[gpui::test]
-    async fn test_open_paths_action(mut cx: TestAppContext) {
+    async fn test_open_paths_action(cx: &mut TestAppContext) {
         let app_state = cx.update(test_app_state);
         let dir = temp_tree(json!({
             "a": {
@@ -186,7 +186,7 @@ mod tests {
             .await;
         assert_eq!(cx.window_ids().len(), 1);
         let workspace_1 = cx.root_view::<Workspace>(cx.window_ids()[0]).unwrap();
-        workspace_1.read_with(&cx, |workspace, cx| {
+        workspace_1.read_with(cx, |workspace, cx| {
             assert_eq!(workspace.worktrees(cx).count(), 2)
         });
 
@@ -205,7 +205,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_new_empty_workspace(mut cx: TestAppContext) {
+    async fn test_new_empty_workspace(cx: &mut TestAppContext) {
         let app_state = cx.update(test_app_state);
         cx.update(|cx| {
             workspace::init(cx);
@@ -213,7 +213,7 @@ mod tests {
         cx.dispatch_global_action(workspace::OpenNew(app_state.clone()));
         let window_id = *cx.window_ids().first().unwrap();
         let workspace = cx.root_view::<Workspace>(window_id).unwrap();
-        let editor = workspace.update(&mut cx, |workspace, cx| {
+        let editor = workspace.update(cx, |workspace, cx| {
             workspace
                 .active_item(cx)
                 .unwrap()
@@ -221,22 +221,22 @@ mod tests {
                 .unwrap()
         });
 
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             assert!(editor.text(cx).is_empty());
         });
 
-        let save_task = workspace.update(&mut cx, |workspace, cx| workspace.save_active_item(cx));
+        let save_task = workspace.update(cx, |workspace, cx| workspace.save_active_item(cx));
         app_state.fs.as_fake().insert_dir("/root").await;
         cx.simulate_new_path_selection(|_| Some(PathBuf::from("/root/the-new-name")));
         save_task.await.unwrap();
-        editor.read_with(&cx, |editor, cx| {
+        editor.read_with(cx, |editor, cx| {
             assert!(!editor.is_dirty(cx));
             assert_eq!(editor.title(cx), "the-new-name");
         });
     }
 
     #[gpui::test]
-    async fn test_open_entry(mut cx: TestAppContext) {
+    async fn test_open_entry(cx: &mut TestAppContext) {
         let app_state = cx.update(test_app_state);
         app_state
             .fs
@@ -256,7 +256,7 @@ mod tests {
         let (_, workspace) = cx.add_window(|cx| Workspace::new(&params, cx));
         params
             .project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/root", false, cx)
             })
             .await
@@ -271,7 +271,7 @@ mod tests {
 
         // Open the first entry
         let entry_1 = workspace
-            .update(&mut cx, |w, cx| w.open_path(file1.clone(), cx))
+            .update(cx, |w, cx| w.open_path(file1.clone(), cx))
             .await
             .unwrap();
         cx.read(|cx| {
@@ -285,7 +285,7 @@ mod tests {
 
         // Open the second entry
         workspace
-            .update(&mut cx, |w, cx| w.open_path(file2.clone(), cx))
+            .update(cx, |w, cx| w.open_path(file2.clone(), cx))
             .await
             .unwrap();
         cx.read(|cx| {
@@ -299,7 +299,7 @@ mod tests {
 
         // Open the first entry again. The existing pane item is activated.
         let entry_1b = workspace
-            .update(&mut cx, |w, cx| w.open_path(file1.clone(), cx))
+            .update(cx, |w, cx| w.open_path(file1.clone(), cx))
             .await
             .unwrap();
         assert_eq!(entry_1.id(), entry_1b.id());
@@ -315,14 +315,14 @@ mod tests {
 
         // Split the pane with the first entry, then open the second entry again.
         workspace
-            .update(&mut cx, |w, cx| {
+            .update(cx, |w, cx| {
                 w.split_pane(w.active_pane().clone(), SplitDirection::Right, cx);
                 w.open_path(file2.clone(), cx)
             })
             .await
             .unwrap();
 
-        workspace.read_with(&cx, |w, cx| {
+        workspace.read_with(cx, |w, cx| {
             assert_eq!(
                 w.active_pane()
                     .read(cx)
@@ -334,7 +334,7 @@ mod tests {
         });
 
         // Open the third entry twice concurrently. Only one pane item is added.
-        let (t1, t2) = workspace.update(&mut cx, |w, cx| {
+        let (t1, t2) = workspace.update(cx, |w, cx| {
             (
                 w.open_path(file3.clone(), cx),
                 w.open_path(file3.clone(), cx),
@@ -357,7 +357,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_open_paths(mut cx: TestAppContext) {
+    async fn test_open_paths(cx: &mut TestAppContext) {
         let app_state = cx.update(test_app_state);
         let fs = app_state.fs.as_fake();
         fs.insert_dir("/dir1").await;
@@ -369,7 +369,7 @@ mod tests {
         let (_, workspace) = cx.add_window(|cx| Workspace::new(&params, cx));
         params
             .project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/dir1", false, cx)
             })
             .await
@@ -435,7 +435,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_save_conflicting_item(mut cx: TestAppContext) {
+    async fn test_save_conflicting_item(cx: &mut TestAppContext) {
         let app_state = cx.update(test_app_state);
         let fs = app_state.fs.as_fake();
         fs.insert_tree("/root", json!({ "a.txt": "" })).await;
@@ -444,7 +444,7 @@ mod tests {
         let (window_id, workspace) = cx.add_window(|cx| Workspace::new(&params, cx));
         params
             .project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/root", false, cx)
             })
             .await
@@ -474,24 +474,24 @@ mod tests {
             .await;
         cx.read(|cx| assert!(editor.is_dirty(cx)));
 
-        let save_task = workspace.update(&mut cx, |workspace, cx| workspace.save_active_item(cx));
+        let save_task = workspace.update(cx, |workspace, cx| workspace.save_active_item(cx));
         cx.simulate_prompt_answer(window_id, 0);
         save_task.await.unwrap();
-        editor.read_with(&cx, |editor, cx| {
+        editor.read_with(cx, |editor, cx| {
             assert!(!editor.is_dirty(cx));
             assert!(!editor.has_conflict(cx));
         });
     }
 
     #[gpui::test]
-    async fn test_open_and_save_new_file(mut cx: TestAppContext) {
+    async fn test_open_and_save_new_file(cx: &mut TestAppContext) {
         let app_state = cx.update(test_app_state);
         app_state.fs.as_fake().insert_dir("/root").await;
         let params = cx.update(|cx| WorkspaceParams::local(&app_state, cx));
         let (window_id, workspace) = cx.add_window(|cx| Workspace::new(&params, cx));
         params
             .project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/root", false, cx)
             })
             .await
@@ -500,7 +500,7 @@ mod tests {
 
         // Create a new untitled buffer
         cx.dispatch_action(window_id, vec![workspace.id()], OpenNew(app_state.clone()));
-        let editor = workspace.read_with(&cx, |workspace, cx| {
+        let editor = workspace.read_with(cx, |workspace, cx| {
             workspace
                 .active_item(cx)
                 .unwrap()
@@ -508,7 +508,7 @@ mod tests {
                 .unwrap()
         });
 
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             assert!(!editor.is_dirty(cx));
             assert_eq!(editor.title(cx), "untitled");
             assert!(Arc::ptr_eq(
@@ -520,7 +520,7 @@ mod tests {
         });
 
         // Save the buffer. This prompts for a filename.
-        let save_task = workspace.update(&mut cx, |workspace, cx| workspace.save_active_item(cx));
+        let save_task = workspace.update(cx, |workspace, cx| workspace.save_active_item(cx));
         cx.simulate_new_path_selection(|parent_dir| {
             assert_eq!(parent_dir, Path::new("/root"));
             Some(parent_dir.join("the-new-name.rs"))
@@ -533,21 +533,21 @@ mod tests {
         // When the save completes, the buffer's title is updated and the language is assigned based
         // on the path.
         save_task.await.unwrap();
-        editor.read_with(&cx, |editor, cx| {
+        editor.read_with(cx, |editor, cx| {
             assert!(!editor.is_dirty(cx));
             assert_eq!(editor.title(cx), "the-new-name.rs");
             assert_eq!(editor.language(cx).unwrap().name().as_ref(), "Rust");
         });
 
         // Edit the file and save it again. This time, there is no filename prompt.
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             editor.handle_input(&editor::Input(" there".into()), cx);
             assert_eq!(editor.is_dirty(cx.as_ref()), true);
         });
-        let save_task = workspace.update(&mut cx, |workspace, cx| workspace.save_active_item(cx));
+        let save_task = workspace.update(cx, |workspace, cx| workspace.save_active_item(cx));
         save_task.await.unwrap();
         assert!(!cx.did_prompt_for_new_path());
-        editor.read_with(&cx, |editor, cx| {
+        editor.read_with(cx, |editor, cx| {
             assert!(!editor.is_dirty(cx));
             assert_eq!(editor.title(cx), "the-new-name.rs")
         });
@@ -556,7 +556,7 @@ mod tests {
         // the same buffer.
         cx.dispatch_action(window_id, vec![workspace.id()], OpenNew(app_state.clone()));
         workspace
-            .update(&mut cx, |workspace, cx| {
+            .update(cx, |workspace, cx| {
                 workspace.split_pane(workspace.active_pane().clone(), SplitDirection::Right, cx);
                 workspace.open_path(
                     ProjectPath {
@@ -568,7 +568,7 @@ mod tests {
             })
             .await
             .unwrap();
-        let editor2 = workspace.update(&mut cx, |workspace, cx| {
+        let editor2 = workspace.update(cx, |workspace, cx| {
             workspace
                 .active_item(cx)
                 .unwrap()
@@ -584,7 +584,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_setting_language_when_saving_as_single_file_worktree(mut cx: TestAppContext) {
+    async fn test_setting_language_when_saving_as_single_file_worktree(cx: &mut TestAppContext) {
         let app_state = cx.update(test_app_state);
         app_state.fs.as_fake().insert_dir("/root").await;
         let params = cx.update(|cx| WorkspaceParams::local(&app_state, cx));
@@ -592,7 +592,7 @@ mod tests {
 
         // Create a new untitled buffer
         cx.dispatch_action(window_id, vec![workspace.id()], OpenNew(app_state.clone()));
-        let editor = workspace.read_with(&cx, |workspace, cx| {
+        let editor = workspace.read_with(cx, |workspace, cx| {
             workspace
                 .active_item(cx)
                 .unwrap()
@@ -600,7 +600,7 @@ mod tests {
                 .unwrap()
         });
 
-        editor.update(&mut cx, |editor, cx| {
+        editor.update(cx, |editor, cx| {
             assert!(Arc::ptr_eq(
                 editor.language(cx).unwrap(),
                 &language::PLAIN_TEXT
@@ -610,18 +610,18 @@ mod tests {
         });
 
         // Save the buffer. This prompts for a filename.
-        let save_task = workspace.update(&mut cx, |workspace, cx| workspace.save_active_item(cx));
+        let save_task = workspace.update(cx, |workspace, cx| workspace.save_active_item(cx));
         cx.simulate_new_path_selection(|_| Some(PathBuf::from("/root/the-new-name.rs")));
         save_task.await.unwrap();
         // The buffer is not dirty anymore and the language is assigned based on the path.
-        editor.read_with(&cx, |editor, cx| {
+        editor.read_with(cx, |editor, cx| {
             assert!(!editor.is_dirty(cx));
             assert_eq!(editor.language(cx).unwrap().name().as_ref(), "Rust")
         });
     }
 
     #[gpui::test]
-    async fn test_pane_actions(mut cx: TestAppContext) {
+    async fn test_pane_actions(cx: &mut TestAppContext) {
         cx.update(|cx| pane::init(cx));
         let app_state = cx.update(test_app_state);
         app_state
@@ -643,7 +643,7 @@ mod tests {
         let (window_id, workspace) = cx.add_window(|cx| Workspace::new(&params, cx));
         params
             .project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/root", false, cx)
             })
             .await
@@ -656,7 +656,7 @@ mod tests {
         let pane_1 = cx.read(|cx| workspace.read(cx).active_pane().clone());
 
         workspace
-            .update(&mut cx, |w, cx| w.open_path(file1.clone(), cx))
+            .update(cx, |w, cx| w.open_path(file1.clone(), cx))
             .await
             .unwrap();
         cx.read(|cx| {
@@ -686,7 +686,7 @@ mod tests {
     }
 
     #[gpui::test]
-    async fn test_navigation(mut cx: TestAppContext) {
+    async fn test_navigation(cx: &mut TestAppContext) {
         let app_state = cx.update(test_app_state);
         app_state
             .fs
@@ -706,7 +706,7 @@ mod tests {
         let (_, workspace) = cx.add_window(|cx| Workspace::new(&params, cx));
         params
             .project
-            .update(&mut cx, |project, cx| {
+            .update(cx, |project, cx| {
                 project.find_or_create_local_worktree("/root", false, cx)
             })
             .await
@@ -719,110 +719,94 @@ mod tests {
         let file3 = entries[2].clone();
 
         let editor1 = workspace
-            .update(&mut cx, |w, cx| w.open_path(file1.clone(), cx))
+            .update(cx, |w, cx| w.open_path(file1.clone(), cx))
             .await
             .unwrap()
             .downcast::<Editor>()
             .unwrap();
-        editor1.update(&mut cx, |editor, cx| {
+        editor1.update(cx, |editor, cx| {
             editor.select_display_ranges(&[DisplayPoint::new(10, 0)..DisplayPoint::new(10, 0)], cx);
         });
         let editor2 = workspace
-            .update(&mut cx, |w, cx| w.open_path(file2.clone(), cx))
+            .update(cx, |w, cx| w.open_path(file2.clone(), cx))
             .await
             .unwrap()
             .downcast::<Editor>()
             .unwrap();
         let editor3 = workspace
-            .update(&mut cx, |w, cx| w.open_path(file3.clone(), cx))
+            .update(cx, |w, cx| w.open_path(file3.clone(), cx))
             .await
             .unwrap()
             .downcast::<Editor>()
             .unwrap();
-        editor3.update(&mut cx, |editor, cx| {
+        editor3.update(cx, |editor, cx| {
             editor.select_display_ranges(&[DisplayPoint::new(15, 0)..DisplayPoint::new(15, 0)], cx);
         });
         assert_eq!(
-            active_location(&workspace, &mut cx),
+            active_location(&workspace, cx),
             (file3.clone(), DisplayPoint::new(15, 0))
         );
 
-        workspace
-            .update(&mut cx, |w, cx| Pane::go_back(w, cx))
-            .await;
+        workspace.update(cx, |w, cx| Pane::go_back(w, cx)).await;
         assert_eq!(
-            active_location(&workspace, &mut cx),
+            active_location(&workspace, cx),
             (file3.clone(), DisplayPoint::new(0, 0))
         );
 
-        workspace
-            .update(&mut cx, |w, cx| Pane::go_back(w, cx))
-            .await;
+        workspace.update(cx, |w, cx| Pane::go_back(w, cx)).await;
         assert_eq!(
-            active_location(&workspace, &mut cx),
+            active_location(&workspace, cx),
             (file2.clone(), DisplayPoint::new(0, 0))
         );
 
-        workspace
-            .update(&mut cx, |w, cx| Pane::go_back(w, cx))
-            .await;
+        workspace.update(cx, |w, cx| Pane::go_back(w, cx)).await;
         assert_eq!(
-            active_location(&workspace, &mut cx),
+            active_location(&workspace, cx),
             (file1.clone(), DisplayPoint::new(10, 0))
         );
 
-        workspace
-            .update(&mut cx, |w, cx| Pane::go_back(w, cx))
-            .await;
+        workspace.update(cx, |w, cx| Pane::go_back(w, cx)).await;
         assert_eq!(
-            active_location(&workspace, &mut cx),
+            active_location(&workspace, cx),
             (file1.clone(), DisplayPoint::new(0, 0))
         );
 
         // Go back one more time and ensure we don't navigate past the first item in the history.
-        workspace
-            .update(&mut cx, |w, cx| Pane::go_back(w, cx))
-            .await;
+        workspace.update(cx, |w, cx| Pane::go_back(w, cx)).await;
         assert_eq!(
-            active_location(&workspace, &mut cx),
+            active_location(&workspace, cx),
             (file1.clone(), DisplayPoint::new(0, 0))
         );
 
-        workspace
-            .update(&mut cx, |w, cx| Pane::go_forward(w, cx))
-            .await;
+        workspace.update(cx, |w, cx| Pane::go_forward(w, cx)).await;
         assert_eq!(
-            active_location(&workspace, &mut cx),
+            active_location(&workspace, cx),
             (file1.clone(), DisplayPoint::new(10, 0))
         );
 
-        workspace
-            .update(&mut cx, |w, cx| Pane::go_forward(w, cx))
-            .await;
+        workspace.update(cx, |w, cx| Pane::go_forward(w, cx)).await;
         assert_eq!(
-            active_location(&workspace, &mut cx),
+            active_location(&workspace, cx),
             (file2.clone(), DisplayPoint::new(0, 0))
         );
 
         // Go forward to an item that has been closed, ensuring it gets re-opened at the same
         // location.
-        workspace.update(&mut cx, |workspace, cx| {
+        workspace.update(cx, |workspace, cx| {
             workspace
                 .active_pane()
                 .update(cx, |pane, cx| pane.close_item(editor3.id(), cx));
             drop(editor3);
         });
-        workspace
-            .update(&mut cx, |w, cx| Pane::go_forward(w, cx))
-            .await;
+        workspace.update(cx, |w, cx| Pane::go_forward(w, cx)).await;
         assert_eq!(
-            active_location(&workspace, &mut cx),
+            active_location(&workspace, cx),
             (file3.clone(), DisplayPoint::new(0, 0))
         );
 
         // Go back to an item that has been closed and removed from disk, ensuring it gets skipped.
         workspace
-            .update(&mut cx, |workspace, cx| {
+            .update(cx, |workspace, cx| {
                 workspace
                     .active_pane()
                     .update(cx, |pane, cx| pane.close_item(editor2.id(), cx));
@@ -834,18 +818,14 @@ mod tests {
             })
             .await
             .unwrap();
-        workspace
-            .update(&mut cx, |w, cx| Pane::go_back(w, cx))
-            .await;
+        workspace.update(cx, |w, cx| Pane::go_back(w, cx)).await;
         assert_eq!(
-            active_location(&workspace, &mut cx),
+            active_location(&workspace, cx),
             (file1.clone(), DisplayPoint::new(10, 0))
         );
-        workspace
-            .update(&mut cx, |w, cx| Pane::go_forward(w, cx))
-            .await;
+        workspace.update(cx, |w, cx| Pane::go_forward(w, cx)).await;
         assert_eq!(
-            active_location(&workspace, &mut cx),
+            active_location(&workspace, cx),
             (file3.clone(), DisplayPoint::new(0, 0))
         );