Fix unnecessary-mut-passed lint (#36490)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-19 16:20:01 +02:00 committed by GitHub
parent e3b593efbd
commit c4083b9b63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 103 additions and 104 deletions

View file

@ -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()),

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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))?,
})
}

View file

@ -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| {

View file

@ -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"),

View file

@ -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(),