Detailed changes
@@ -832,6 +832,7 @@ redundant_closure = { level = "deny" }
declare_interior_mutable_const = { level = "deny" }
collapsible_if = { level = "warn"}
needless_borrow = { level = "warn"}
+unnecessary_mut_passed = {level = "warn"}
# Individual rules that have violations in the codebase:
type_complexity = "allow"
# We often return trait objects from `new` functions.
@@ -2173,7 +2173,7 @@ mod tests {
cx.run_until_parked();
- editor.read_with(&mut cx, |editor, cx| {
+ editor.read_with(&cx, |editor, cx| {
assert_eq!(
editor.text(cx),
"Lorem [@one.txt](file:///dir/a/one.txt) Ipsum [@eight.txt](file:///dir/b/eight.txt) [@MySymbol](file:///dir/a/one.txt?symbol=MySymbol#L1:1) "
@@ -320,7 +320,7 @@ impl ContextStore {
.client
.subscribe_to_entity(remote_id)
.log_err()
- .map(|subscription| subscription.set_entity(&cx.entity(), &mut cx.to_async()));
+ .map(|subscription| subscription.set_entity(&cx.entity(), &cx.to_async()));
self.advertise_contexts(cx);
} else {
self.client_subscription = None;
@@ -543,7 +543,7 @@ impl AutoUpdater {
async fn update(this: Entity<Self>, mut cx: AsyncApp) -> Result<()> {
let (client, installed_version, previous_status, release_channel) =
- this.read_with(&mut cx, |this, cx| {
+ this.read_with(&cx, |this, cx| {
(
this.http_client.clone(),
this.current_version,
@@ -116,7 +116,7 @@ impl ActiveCall {
envelope: TypedEnvelope<proto::IncomingCall>,
mut cx: AsyncApp,
) -> Result<proto::Ack> {
- let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;
+ let user_store = this.read_with(&cx, |this, _| this.user_store.clone())?;
let call = IncomingCall {
room_id: envelope.payload.room_id,
participants: user_store
@@ -82,7 +82,7 @@ impl ChannelBuffer {
collaborators: Default::default(),
acknowledge_task: None,
channel_id: channel.id,
- subscription: Some(subscription.set_entity(&cx.entity(), &mut cx.to_async())),
+ subscription: Some(subscription.set_entity(&cx.entity(), &cx.to_async())),
user_store,
channel_store,
};
@@ -110,7 +110,7 @@ impl ChannelBuffer {
let Ok(subscription) = self.client.subscribe_to_entity(self.channel_id.0) else {
return;
};
- self.subscription = Some(subscription.set_entity(&cx.entity(), &mut cx.to_async()));
+ self.subscription = Some(subscription.set_entity(&cx.entity(), &cx.to_async()));
cx.emit(ChannelBufferEvent::Connected);
}
}
@@ -532,7 +532,7 @@ impl ChannelChat {
message: TypedEnvelope<proto::ChannelMessageSent>,
mut cx: AsyncApp,
) -> Result<()> {
- let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;
+ let user_store = this.read_with(&cx, |this, _| this.user_store.clone())?;
let message = message.payload.message.context("empty message")?;
let message_id = message.id;
@@ -564,7 +564,7 @@ impl ChannelChat {
message: TypedEnvelope<proto::ChannelMessageUpdate>,
mut cx: AsyncApp,
) -> Result<()> {
- let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;
+ let user_store = this.read_with(&cx, |this, _| this.user_store.clone())?;
let message = message.payload.message.context("empty message")?;
let message = ChannelMessage::from_proto(message, &user_store, &mut cx).await?;
@@ -908,9 +908,9 @@ impl ChannelStore {
async fn handle_update_channels(
this: Entity<Self>,
message: TypedEnvelope<proto::UpdateChannels>,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> Result<()> {
- this.read_with(&mut cx, |this, _| {
+ this.read_with(&cx, |this, _| {
this.update_channels_tx
.unbounded_send(message.payload)
.unwrap();
@@ -2073,8 +2073,8 @@ mod tests {
let (done_tx1, done_rx1) = smol::channel::unbounded();
let (done_tx2, done_rx2) = smol::channel::unbounded();
AnyProtoClient::from(client.clone()).add_entity_message_handler(
- move |entity: Entity<TestEntity>, _: TypedEnvelope<proto::JoinProject>, mut cx| {
- match entity.read_with(&mut cx, |entity, _| entity.id).unwrap() {
+ move |entity: Entity<TestEntity>, _: TypedEnvelope<proto::JoinProject>, cx| {
+ match entity.read_with(&cx, |entity, _| entity.id).unwrap() {
1 => done_tx1.try_send(()).unwrap(),
2 => done_tx2.try_send(()).unwrap(),
_ => unreachable!(),
@@ -2098,17 +2098,17 @@ mod tests {
let _subscription1 = client
.subscribe_to_entity(1)
.unwrap()
- .set_entity(&entity1, &mut cx.to_async());
+ .set_entity(&entity1, &cx.to_async());
let _subscription2 = client
.subscribe_to_entity(2)
.unwrap()
- .set_entity(&entity2, &mut cx.to_async());
+ .set_entity(&entity2, &cx.to_async());
// Ensure dropping a subscription for the same entity type still allows receiving of
// messages for other entity IDs of the same type.
let subscription3 = client
.subscribe_to_entity(3)
.unwrap()
- .set_entity(&entity3, &mut cx.to_async());
+ .set_entity(&entity3, &cx.to_async());
drop(subscription3);
server.send(proto::JoinProject {
@@ -332,9 +332,9 @@ impl UserStore {
async fn handle_update_contacts(
this: Entity<Self>,
message: TypedEnvelope<proto::UpdateContacts>,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> Result<()> {
- this.read_with(&mut cx, |this, _| {
+ this.read_with(&cx, |this, _| {
this.update_contacts_tx
.unbounded_send(UpdateContacts::Update(message.payload))
.unwrap();
@@ -655,11 +655,11 @@ pub fn show_link_definition(
pub(crate) fn find_url(
buffer: &Entity<language::Buffer>,
position: text::Anchor,
- mut cx: AsyncWindowContext,
+ cx: AsyncWindowContext,
) -> Option<(Range<text::Anchor>, String)> {
const LIMIT: usize = 2048;
- let Ok(snapshot) = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot()) else {
+ let Ok(snapshot) = buffer.read_with(&cx, |buffer, _| buffer.snapshot()) else {
return None;
};
@@ -717,11 +717,11 @@ pub(crate) fn find_url(
pub(crate) fn find_url_from_range(
buffer: &Entity<language::Buffer>,
range: Range<text::Anchor>,
- mut cx: AsyncWindowContext,
+ cx: AsyncWindowContext,
) -> Option<String> {
const LIMIT: usize = 2048;
- let Ok(snapshot) = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot()) else {
+ let Ok(snapshot) = buffer.read_with(&cx, |buffer, _| buffer.snapshot()) else {
return None;
};
@@ -368,7 +368,7 @@ impl App {
}),
});
- init_app_menus(platform.as_ref(), &mut app.borrow_mut());
+ init_app_menus(platform.as_ref(), &app.borrow());
platform.on_keyboard_layout_change(Box::new({
let app = Rc::downgrade(&app);
@@ -1332,7 +1332,7 @@ impl App {
}
inner(
- &mut self.keystroke_observers,
+ &self.keystroke_observers,
Box::new(move |event, window, cx| {
f(event, window, cx);
true
@@ -1358,7 +1358,7 @@ impl App {
}
inner(
- &mut self.keystroke_interceptors,
+ &self.keystroke_interceptors,
Box::new(move |event, window, cx| {
f(event, window, cx);
true
@@ -472,7 +472,7 @@ impl<'a, T: 'static> Context<'a, T> {
let view = self.weak_entity();
inner(
- &mut self.keystroke_observers,
+ &self.keystroke_observers,
Box::new(move |event, window, cx| {
if let Some(view) = view.upgrade() {
view.update(cx, |view, cx| f(view, event, window, cx));
@@ -219,7 +219,7 @@ impl TestAppContext {
let mut cx = self.app.borrow_mut();
// Some tests rely on the window size matching the bounds of the test display
- let bounds = Bounds::maximized(None, &mut cx);
+ let bounds = Bounds::maximized(None, &cx);
cx.open_window(
WindowOptions {
window_bounds: Some(WindowBounds::Windowed(bounds)),
@@ -233,7 +233,7 @@ impl TestAppContext {
/// Adds a new window with no content.
pub fn add_empty_window(&mut self) -> &mut VisualTestContext {
let mut cx = self.app.borrow_mut();
- let bounds = Bounds::maximized(None, &mut cx);
+ let bounds = Bounds::maximized(None, &cx);
let window = cx
.open_window(
WindowOptions {
@@ -261,7 +261,7 @@ impl TestAppContext {
V: 'static + Render,
{
let mut cx = self.app.borrow_mut();
- let bounds = Bounds::maximized(None, &mut cx);
+ let bounds = Bounds::maximized(None, &cx);
let window = cx
.open_window(
WindowOptions {
@@ -1345,7 +1345,7 @@ impl BufferStore {
mut cx: AsyncApp,
) -> Result<proto::BufferSaved> {
let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
- let (buffer, project_id) = this.read_with(&mut cx, |this, _| {
+ let (buffer, project_id) = this.read_with(&cx, |this, _| {
anyhow::Ok((
this.get_existing(buffer_id)?,
this.downstream_client
@@ -1359,7 +1359,7 @@ impl BufferStore {
buffer.wait_for_version(deserialize_version(&envelope.payload.version))
})?
.await?;
- let buffer_id = buffer.read_with(&mut cx, |buffer, _| buffer.remote_id())?;
+ let buffer_id = buffer.read_with(&cx, |buffer, _| buffer.remote_id())?;
if let Some(new_path) = envelope.payload.new_path {
let new_path = ProjectPath::from_proto(new_path);
@@ -1372,7 +1372,7 @@ impl BufferStore {
.await?;
}
- buffer.read_with(&mut cx, |buffer, _| proto::BufferSaved {
+ buffer.read_with(&cx, |buffer, _| proto::BufferSaved {
project_id,
buffer_id: buffer_id.into(),
version: serialize_version(buffer.saved_version()),
@@ -267,7 +267,7 @@ impl BreakpointStore {
message: TypedEnvelope<proto::ToggleBreakpoint>,
mut cx: AsyncApp,
) -> Result<proto::Ack> {
- let breakpoints = this.read_with(&mut cx, |this, _| this.breakpoint_store())?;
+ let breakpoints = this.read_with(&cx, |this, _| this.breakpoint_store())?;
let path = this
.update(&mut cx, |this, cx| {
this.project_path_for_absolute_path(message.payload.path.as_ref(), cx)
@@ -332,9 +332,9 @@ impl LspCommand for PrepareRename {
_: Entity<LspStore>,
buffer: Entity<Buffer>,
_: LanguageServerId,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> Result<PrepareRenameResponse> {
- buffer.read_with(&mut cx, |buffer, _| match message {
+ buffer.read_with(&cx, |buffer, _| match message {
Some(lsp::PrepareRenameResponse::Range(range))
| Some(lsp::PrepareRenameResponse::RangeWithPlaceholder { range, .. }) => {
let Range { start, end } = range_from_lsp(range);
@@ -386,7 +386,7 @@ impl LspCommand for PrepareRename {
.await?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
})
}
@@ -543,7 +543,7 @@ impl LspCommand for PerformRename {
})?
.await?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
new_name: message.new_name,
push_to_history: false,
})
@@ -658,7 +658,7 @@ impl LspCommand for GetDefinitions {
})?
.await?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
})
}
@@ -761,7 +761,7 @@ impl LspCommand for GetDeclarations {
})?
.await?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
})
}
@@ -863,7 +863,7 @@ impl LspCommand for GetImplementations {
})?
.await?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
})
}
@@ -962,7 +962,7 @@ impl LspCommand for GetTypeDefinitions {
})?
.await?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
})
}
@@ -1330,7 +1330,7 @@ impl LspCommand for GetReferences {
target_buffer_handle
.clone()
- .read_with(&mut cx, |target_buffer, _| {
+ .read_with(&cx, |target_buffer, _| {
let target_start = target_buffer
.clip_point_utf16(point_from_lsp(lsp_location.range.start), Bias::Left);
let target_end = target_buffer
@@ -1374,7 +1374,7 @@ impl LspCommand for GetReferences {
})?
.await?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
})
}
@@ -1484,9 +1484,9 @@ impl LspCommand for GetDocumentHighlights {
_: Entity<LspStore>,
buffer: Entity<Buffer>,
_: LanguageServerId,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> Result<Vec<DocumentHighlight>> {
- buffer.read_with(&mut cx, |buffer, _| {
+ buffer.read_with(&cx, |buffer, _| {
let mut lsp_highlights = lsp_highlights.unwrap_or_default();
lsp_highlights.sort_unstable_by_key(|h| (h.range.start, Reverse(h.range.end)));
lsp_highlights
@@ -1534,7 +1534,7 @@ impl LspCommand for GetDocumentHighlights {
})?
.await?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
})
}
@@ -1865,7 +1865,7 @@ impl LspCommand for GetSignatureHelp {
})?
.await
.with_context(|| format!("waiting for version for buffer {}", buffer.entity_id()))?;
- let buffer_snapshot = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot())?;
+ let buffer_snapshot = buffer.read_with(&cx, |buffer, _| buffer.snapshot())?;
Ok(Self {
position: payload
.position
@@ -1947,13 +1947,13 @@ impl LspCommand for GetHover {
_: Entity<LspStore>,
buffer: Entity<Buffer>,
_: LanguageServerId,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> Result<Self::Response> {
let Some(hover) = message else {
return Ok(None);
};
- let (language, range) = buffer.read_with(&mut cx, |buffer, _| {
+ let (language, range) = buffer.read_with(&cx, |buffer, _| {
(
buffer.language().cloned(),
hover.range.map(|range| {
@@ -2039,7 +2039,7 @@ impl LspCommand for GetHover {
})?
.await?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
})
}
@@ -2113,7 +2113,7 @@ impl LspCommand for GetHover {
return Ok(None);
}
- let language = buffer.read_with(&mut cx, |buffer, _| buffer.language().cloned())?;
+ let language = buffer.read_with(&cx, |buffer, _| buffer.language().cloned())?;
let range = if let (Some(start), Some(end)) = (message.start, message.end) {
language::proto::deserialize_anchor(start)
.and_then(|start| language::proto::deserialize_anchor(end).map(|end| start..end))
@@ -2208,7 +2208,7 @@ impl LspCommand for GetCompletions {
let unfiltered_completions_count = completions.len();
let language_server_adapter = lsp_store
- .read_with(&mut cx, |lsp_store, _| {
+ .read_with(&cx, |lsp_store, _| {
lsp_store.language_server_adapter_for_id(server_id)
})?
.with_context(|| format!("no language server with id {server_id}"))?;
@@ -2394,7 +2394,7 @@ impl LspCommand for GetCompletions {
.position
.and_then(language::proto::deserialize_anchor)
.map(|p| {
- buffer.read_with(&mut cx, |buffer, _| {
+ buffer.read_with(&cx, |buffer, _| {
buffer.clip_point_utf16(Unclipped(p.to_point_utf16(buffer)), Bias::Left)
})
})
@@ -2862,7 +2862,7 @@ impl LspCommand for OnTypeFormatting {
})?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
trigger: message.trigger.clone(),
options,
push_to_history: false,
@@ -3474,9 +3474,9 @@ impl LspCommand for GetCodeLens {
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> anyhow::Result<Vec<CodeAction>> {
- let snapshot = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot())?;
+ let snapshot = buffer.read_with(&cx, |buffer, _| buffer.snapshot())?;
let language_server = cx.update(|cx| {
lsp_store
.read(cx)
@@ -669,10 +669,10 @@ impl LocalLspStore {
let this = this.clone();
move |_, cx| {
let this = this.clone();
- let mut cx = cx.clone();
+ let cx = cx.clone();
async move {
- let Some(server) = this
- .read_with(&mut cx, |this, _| this.language_server_for_id(server_id))?
+ let Some(server) =
+ this.read_with(&cx, |this, _| this.language_server_for_id(server_id))?
else {
return Ok(None);
};
@@ -8154,7 +8154,7 @@ impl LspStore {
envelope: TypedEnvelope<proto::MultiLspQuery>,
mut cx: AsyncApp,
) -> Result<proto::MultiLspQueryResponse> {
- let response_from_ssh = lsp_store.read_with(&mut cx, |this, _| {
+ let response_from_ssh = lsp_store.read_with(&cx, |this, _| {
let (upstream_client, project_id) = this.upstream_client()?;
let mut payload = envelope.payload.clone();
payload.project_id = project_id;
@@ -8176,7 +8176,7 @@ impl LspStore {
buffer.wait_for_version(version.clone())
})?
.await?;
- let buffer_version = buffer.read_with(&mut cx, |buffer, _| buffer.version())?;
+ let buffer_version = buffer.read_with(&cx, |buffer, _| buffer.version())?;
match envelope
.payload
.strategy
@@ -8717,7 +8717,7 @@ impl LspStore {
})?
.context("worktree not found")?;
let (old_abs_path, new_abs_path) = {
- let root_path = worktree.read_with(&mut cx, |this, _| this.abs_path())?;
+ let root_path = worktree.read_with(&cx, |this, _| this.abs_path())?;
let new_path = PathBuf::from_proto(envelope.payload.new_path.clone());
(root_path.join(&old_path), root_path.join(&new_path))
};
@@ -8732,7 +8732,7 @@ impl LspStore {
)
.await;
let response = Worktree::handle_rename_entry(worktree, envelope.payload, cx.clone()).await;
- this.read_with(&mut cx, |this, _| {
+ this.read_with(&cx, |this, _| {
this.did_rename_entry(worktree_id, &old_abs_path, &new_abs_path, is_dir);
})
.ok();
@@ -8966,10 +8966,10 @@ impl LspStore {
async fn handle_lsp_ext_cancel_flycheck(
lsp_store: Entity<Self>,
envelope: TypedEnvelope<proto::LspExtCancelFlycheck>,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> Result<proto::Ack> {
let server_id = LanguageServerId(envelope.payload.language_server_id as usize);
- lsp_store.read_with(&mut cx, |lsp_store, _| {
+ lsp_store.read_with(&cx, |lsp_store, _| {
if let Some(server) = lsp_store.language_server_for_id(server_id) {
server
.notify::<lsp_store::lsp_ext_command::LspExtCancelFlycheck>(&())
@@ -9018,10 +9018,10 @@ impl LspStore {
async fn handle_lsp_ext_clear_flycheck(
lsp_store: Entity<Self>,
envelope: TypedEnvelope<proto::LspExtClearFlycheck>,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> Result<proto::Ack> {
let server_id = LanguageServerId(envelope.payload.language_server_id as usize);
- lsp_store.read_with(&mut cx, |lsp_store, _| {
+ lsp_store.read_with(&cx, |lsp_store, _| {
if let Some(server) = lsp_store.language_server_for_id(server_id) {
server
.notify::<lsp_store::lsp_ext_command::LspExtClearFlycheck>(&())
@@ -9789,7 +9789,7 @@ impl LspStore {
let peer_id = envelope.original_sender_id().unwrap_or_default();
let symbol = envelope.payload.symbol.context("invalid symbol")?;
let symbol = Self::deserialize_symbol(symbol)?;
- let symbol = this.read_with(&mut cx, |this, _| {
+ let symbol = this.read_with(&cx, |this, _| {
let signature = this.symbol_signature(&symbol.path);
anyhow::ensure!(signature == symbol.signature, "invalid symbol signature");
Ok(symbol)
@@ -115,14 +115,14 @@ impl LspCommand for ExpandMacro {
message: Self::ProtoRequest,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> anyhow::Result<Self> {
let position = message
.position
.and_then(deserialize_anchor)
.context("invalid position")?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
})
}
@@ -249,14 +249,14 @@ impl LspCommand for OpenDocs {
message: Self::ProtoRequest,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> anyhow::Result<Self> {
let position = message
.position
.and_then(deserialize_anchor)
.context("invalid position")?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
})
}
@@ -462,14 +462,14 @@ impl LspCommand for GoToParentModule {
request: Self::ProtoRequest,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> anyhow::Result<Self> {
let position = request
.position
.and_then(deserialize_anchor)
.context("bad request with bad position")?;
Ok(Self {
- position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,
+ position: buffer.read_with(&cx, |buffer, _| position.to_point_utf16(buffer))?,
})
}
@@ -1613,25 +1613,23 @@ impl Project {
.into_iter()
.map(|s| match s {
EntitySubscription::BufferStore(subscription) => {
- subscription.set_entity(&buffer_store, &mut cx)
+ subscription.set_entity(&buffer_store, &cx)
}
EntitySubscription::WorktreeStore(subscription) => {
- subscription.set_entity(&worktree_store, &mut cx)
+ subscription.set_entity(&worktree_store, &cx)
}
EntitySubscription::GitStore(subscription) => {
- subscription.set_entity(&git_store, &mut cx)
+ subscription.set_entity(&git_store, &cx)
}
EntitySubscription::SettingsObserver(subscription) => {
- subscription.set_entity(&settings_observer, &mut cx)
- }
- EntitySubscription::Project(subscription) => {
- subscription.set_entity(&this, &mut cx)
+ subscription.set_entity(&settings_observer, &cx)
}
+ EntitySubscription::Project(subscription) => subscription.set_entity(&this, &cx),
EntitySubscription::LspStore(subscription) => {
- subscription.set_entity(&lsp_store, &mut cx)
+ subscription.set_entity(&lsp_store, &cx)
}
EntitySubscription::DapStore(subscription) => {
- subscription.set_entity(&dap_store, &mut cx)
+ subscription.set_entity(&dap_store, &cx)
}
})
.collect::<Vec<_>>();
@@ -2226,28 +2224,28 @@ impl Project {
self.client_subscriptions.extend([
self.client
.subscribe_to_entity(project_id)?
- .set_entity(&cx.entity(), &mut cx.to_async()),
+ .set_entity(&cx.entity(), &cx.to_async()),
self.client
.subscribe_to_entity(project_id)?
- .set_entity(&self.worktree_store, &mut cx.to_async()),
+ .set_entity(&self.worktree_store, &cx.to_async()),
self.client
.subscribe_to_entity(project_id)?
- .set_entity(&self.buffer_store, &mut cx.to_async()),
+ .set_entity(&self.buffer_store, &cx.to_async()),
self.client
.subscribe_to_entity(project_id)?
- .set_entity(&self.lsp_store, &mut cx.to_async()),
+ .set_entity(&self.lsp_store, &cx.to_async()),
self.client
.subscribe_to_entity(project_id)?
- .set_entity(&self.settings_observer, &mut cx.to_async()),
+ .set_entity(&self.settings_observer, &cx.to_async()),
self.client
.subscribe_to_entity(project_id)?
- .set_entity(&self.dap_store, &mut cx.to_async()),
+ .set_entity(&self.dap_store, &cx.to_async()),
self.client
.subscribe_to_entity(project_id)?
- .set_entity(&self.breakpoint_store, &mut cx.to_async()),
+ .set_entity(&self.breakpoint_store, &cx.to_async()),
self.client
.subscribe_to_entity(project_id)?
- .set_entity(&self.git_store, &mut cx.to_async()),
+ .set_entity(&self.git_store, &cx.to_async()),
]);
self.buffer_store.update(cx, |buffer_store, cx| {
@@ -202,7 +202,7 @@ mod tests {
assert_eq!(search_history.current(&cursor), Some("TypeScript"));
cursor.reset();
- assert_eq!(search_history.current(&mut cursor), None);
+ assert_eq!(search_history.current(&cursor), None);
assert_eq!(
search_history.previous(&mut cursor),
Some("TypeScript"),
@@ -71,7 +71,7 @@ impl TaskStore {
.payload
.location
.context("no location given for task context handling")?;
- let (buffer_store, is_remote) = store.read_with(&mut cx, |store, _| {
+ let (buffer_store, is_remote) = store.read_with(&cx, |store, _| {
Ok(match store {
TaskStore::Functional(state) => (
state.buffer_store.clone(),
@@ -372,7 +372,7 @@ impl HeadlessProject {
mut cx: AsyncApp,
) -> Result<proto::AddWorktreeResponse> {
use client::ErrorCodeExt;
- let fs = this.read_with(&mut cx, |this, _| this.fs.clone())?;
+ let fs = this.read_with(&cx, |this, _| this.fs.clone())?;
let path = PathBuf::from_proto(shellexpand::tilde(&message.payload.path).to_string());
let canonicalized = match fs.canonicalize(&path).await {
@@ -396,7 +396,7 @@ impl HeadlessProject {
};
let worktree = this
- .read_with(&mut cx.clone(), |this, _| {
+ .read_with(&cx.clone(), |this, _| {
Worktree::local(
Arc::from(canonicalized.as_path()),
message.payload.visible,
@@ -407,7 +407,7 @@ impl HeadlessProject {
})?
.await?;
- let response = this.read_with(&mut cx, |_, cx| {
+ let response = this.read_with(&cx, |_, cx| {
let worktree = worktree.read(cx);
proto::AddWorktreeResponse {
worktree_id: worktree.id().to_proto(),
@@ -586,7 +586,7 @@ impl HeadlessProject {
let buffer_store = this.read_with(&cx, |this, _| this.buffer_store.clone())?;
while let Ok(buffer) = results.recv().await {
- let buffer_id = buffer.read_with(&mut cx, |this, _| this.remote_id())?;
+ let buffer_id = buffer.read_with(&cx, |this, _| this.remote_id())?;
response.buffer_ids.push(buffer_id.to_proto());
buffer_store
.update(&mut cx, |buffer_store, cx| {
@@ -622,7 +622,7 @@ pub fn execute_proxy(identifier: String, is_reconnecting: bool) -> Result<()> {
Err(anyhow!(error))?;
}
n => {
- stderr.write_all(&mut stderr_buffer[..n]).await?;
+ stderr.write_all(&stderr_buffer[..n]).await?;
stderr.flush().await?;
}
}
@@ -1340,7 +1340,7 @@ impl BufferSearchBar {
if self.query(cx).is_empty()
&& let Some(new_query) = self
.search_history
- .current(&mut self.search_history_cursor)
+ .current(&self.search_history_cursor)
.map(str::to_string)
{
drop(self.search(&new_query, Some(self.search_options), window, cx));
@@ -4111,7 +4111,7 @@ pub mod tests {
});
cx.run_until_parked();
let project_search_view = pane
- .read_with(&mut cx, |pane, _| {
+ .read_with(&cx, |pane, _| {
pane.active_item()
.and_then(|item| item.downcast::<ProjectSearchView>())
})
@@ -811,7 +811,7 @@ mod tests {
pub fn expect_keystrokes(&mut self, expected: &[&str]) -> &mut Self {
let actual = self
.input
- .read_with(&mut self.cx, |input, _| input.keystrokes.clone());
+ .read_with(&self.cx, |input, _| input.keystrokes.clone());
Self::expect_keystrokes_equal(&actual, expected);
self
}
@@ -820,7 +820,7 @@ mod tests {
pub fn expect_close_keystrokes(&mut self, expected: &[&str]) -> &mut Self {
let actual = self
.input
- .read_with(&mut self.cx, |input, _| input.close_keystrokes.clone())
+ .read_with(&self.cx, |input, _| input.close_keystrokes.clone())
.unwrap_or_default();
Self::expect_keystrokes_equal(&actual, expected);
self
@@ -69,7 +69,7 @@ async fn process_updates(
entries: Vec<PathBuf>,
mut cx: AsyncApp,
) -> Result<()> {
- let fs = this.read_with(&mut cx, |this, _| this.fs.clone())?;
+ let fs = this.read_with(&cx, |this, _| this.fs.clone())?;
for entry_path in entries {
if !entry_path
.extension()
@@ -118,9 +118,9 @@ async fn process_updates(
async fn initial_scan(
this: WeakEntity<SnippetProvider>,
path: Arc<Path>,
- mut cx: AsyncApp,
+ cx: AsyncApp,
) -> Result<()> {
- let fs = this.read_with(&mut cx, |this, _| this.fs.clone())?;
+ let fs = this.read_with(&cx, |this, _| this.fs.clone())?;
let entries = fs.read_dir(&path).await;
if let Ok(entries) = entries {
let entries = entries