Fix clippy::needless_borrow lint violations (#36444)
Release Notes: - N/A
This commit is contained in:
parent
eecf142f06
commit
9e0e233319
242 changed files with 801 additions and 821 deletions
|
@ -368,7 +368,7 @@ impl ContextServerStore {
|
|||
}
|
||||
|
||||
pub fn restart_server(&mut self, id: &ContextServerId, cx: &mut Context<Self>) -> Result<()> {
|
||||
if let Some(state) = self.servers.get(&id) {
|
||||
if let Some(state) = self.servers.get(id) {
|
||||
let configuration = state.configuration();
|
||||
|
||||
self.stop_server(&state.server().id(), cx)?;
|
||||
|
@ -397,7 +397,7 @@ impl ContextServerStore {
|
|||
let server = server.clone();
|
||||
let configuration = configuration.clone();
|
||||
async move |this, cx| {
|
||||
match server.clone().start(&cx).await {
|
||||
match server.clone().start(cx).await {
|
||||
Ok(_) => {
|
||||
log::info!("Started {} context server", id);
|
||||
debug_assert!(server.client().is_some());
|
||||
|
@ -588,7 +588,7 @@ impl ContextServerStore {
|
|||
for server_id in this.servers.keys() {
|
||||
// All servers that are not in desired_servers should be removed from the store.
|
||||
// This can happen if the user removed a server from the context server settings.
|
||||
if !configured_servers.contains_key(&server_id) {
|
||||
if !configured_servers.contains_key(server_id) {
|
||||
if disabled_servers.contains_key(&server_id.0) {
|
||||
servers_to_stop.insert(server_id.clone());
|
||||
} else {
|
||||
|
|
|
@ -317,8 +317,8 @@ impl BreakpointStore {
|
|||
.iter()
|
||||
.filter_map(|breakpoint| {
|
||||
breakpoint.bp.bp.to_proto(
|
||||
&path,
|
||||
&breakpoint.position(),
|
||||
path,
|
||||
breakpoint.position(),
|
||||
&breakpoint.session_state,
|
||||
)
|
||||
})
|
||||
|
@ -753,7 +753,7 @@ impl BreakpointStore {
|
|||
.iter()
|
||||
.map(|breakpoint| {
|
||||
let position = snapshot
|
||||
.summary_for_anchor::<PointUtf16>(&breakpoint.position())
|
||||
.summary_for_anchor::<PointUtf16>(breakpoint.position())
|
||||
.row;
|
||||
let breakpoint = &breakpoint.bp;
|
||||
SourceBreakpoint {
|
||||
|
|
|
@ -215,7 +215,7 @@ impl DapStore {
|
|||
dap_settings.and_then(|s| s.binary.as_ref().map(PathBuf::from));
|
||||
let user_args = dap_settings.map(|s| s.args.clone());
|
||||
|
||||
let delegate = self.delegate(&worktree, console, cx);
|
||||
let delegate = self.delegate(worktree, console, cx);
|
||||
let cwd: Arc<Path> = worktree.read(cx).abs_path().as_ref().into();
|
||||
|
||||
cx.spawn(async move |this, cx| {
|
||||
|
@ -902,7 +902,7 @@ impl dap::adapters::DapDelegate for DapAdapterDelegate {
|
|||
}
|
||||
|
||||
fn worktree_root_path(&self) -> &Path {
|
||||
&self.worktree.abs_path()
|
||||
self.worktree.abs_path()
|
||||
}
|
||||
fn http_client(&self) -> Arc<dyn HttpClient> {
|
||||
self.http_client.clone()
|
||||
|
|
|
@ -187,12 +187,12 @@ impl DapLocator for CargoLocator {
|
|||
.cloned();
|
||||
}
|
||||
let executable = {
|
||||
if let Some(ref name) = test_name.as_ref().and_then(|name| {
|
||||
if let Some(name) = test_name.as_ref().and_then(|name| {
|
||||
name.strip_prefix('$')
|
||||
.map(|name| build_config.env.get(name))
|
||||
.unwrap_or(Some(name))
|
||||
}) {
|
||||
find_best_executable(&executables, &name).await
|
||||
find_best_executable(&executables, name).await
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -1630,7 +1630,7 @@ impl Session {
|
|||
+ 'static,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Option<T::Response>> {
|
||||
if !T::is_supported(&capabilities) {
|
||||
if !T::is_supported(capabilities) {
|
||||
log::warn!(
|
||||
"Attempted to send a DAP request that isn't supported: {:?}",
|
||||
request
|
||||
|
@ -1688,7 +1688,7 @@ impl Session {
|
|||
self.requests
|
||||
.entry((&*key.0 as &dyn Any).type_id())
|
||||
.and_modify(|request_map| {
|
||||
request_map.remove(&key);
|
||||
request_map.remove(key);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ async fn load_directory_shell_environment(
|
|||
);
|
||||
};
|
||||
|
||||
load_shell_environment(&dir, load_direnv).await
|
||||
load_shell_environment(dir, load_direnv).await
|
||||
}
|
||||
Err(err) => (
|
||||
None,
|
||||
|
|
|
@ -561,7 +561,7 @@ impl GitStore {
|
|||
pub fn active_repository(&self) -> Option<Entity<Repository>> {
|
||||
self.active_repo_id
|
||||
.as_ref()
|
||||
.map(|id| self.repositories[&id].clone())
|
||||
.map(|id| self.repositories[id].clone())
|
||||
}
|
||||
|
||||
pub fn open_unstaged_diff(
|
||||
|
@ -1277,7 +1277,7 @@ impl GitStore {
|
|||
) {
|
||||
match event {
|
||||
BufferStoreEvent::BufferAdded(buffer) => {
|
||||
cx.subscribe(&buffer, |this, buffer, event, cx| {
|
||||
cx.subscribe(buffer, |this, buffer, event, cx| {
|
||||
if let BufferEvent::LanguageChanged = event {
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
if let Some(diff_state) = this.diffs.get(&buffer_id) {
|
||||
|
@ -1295,7 +1295,7 @@ impl GitStore {
|
|||
}
|
||||
}
|
||||
BufferStoreEvent::BufferDropped(buffer_id) => {
|
||||
self.diffs.remove(&buffer_id);
|
||||
self.diffs.remove(buffer_id);
|
||||
for diffs in self.shared_diffs.values_mut() {
|
||||
diffs.remove(buffer_id);
|
||||
}
|
||||
|
@ -1384,8 +1384,8 @@ impl GitStore {
|
|||
repository.update(cx, |repository, cx| {
|
||||
let repo_abs_path = &repository.work_directory_abs_path;
|
||||
if changed_repos.iter().any(|update| {
|
||||
update.old_work_directory_abs_path.as_ref() == Some(&repo_abs_path)
|
||||
|| update.new_work_directory_abs_path.as_ref() == Some(&repo_abs_path)
|
||||
update.old_work_directory_abs_path.as_ref() == Some(repo_abs_path)
|
||||
|| update.new_work_directory_abs_path.as_ref() == Some(repo_abs_path)
|
||||
}) {
|
||||
repository.reload_buffer_diff_bases(cx);
|
||||
}
|
||||
|
@ -1536,7 +1536,7 @@ impl GitStore {
|
|||
});
|
||||
if is_new {
|
||||
this._subscriptions
|
||||
.push(cx.subscribe(&repo, Self::on_repository_event))
|
||||
.push(cx.subscribe(repo, Self::on_repository_event))
|
||||
}
|
||||
|
||||
repo.update(cx, {
|
||||
|
@ -2353,7 +2353,7 @@ impl GitStore {
|
|||
// All paths prefixed by a given repo will constitute a continuous range.
|
||||
while let Some(path) = entries.get(ix)
|
||||
&& let Some(repo_path) =
|
||||
RepositorySnapshot::abs_path_to_repo_path_inner(&repo_path, &path)
|
||||
RepositorySnapshot::abs_path_to_repo_path_inner(&repo_path, path)
|
||||
{
|
||||
paths.push((repo_path, ix));
|
||||
ix += 1;
|
||||
|
@ -2875,14 +2875,14 @@ impl RepositorySnapshot {
|
|||
}
|
||||
|
||||
pub fn had_conflict_on_last_merge_head_change(&self, repo_path: &RepoPath) -> bool {
|
||||
self.merge.conflicted_paths.contains(&repo_path)
|
||||
self.merge.conflicted_paths.contains(repo_path)
|
||||
}
|
||||
|
||||
pub fn has_conflict(&self, repo_path: &RepoPath) -> bool {
|
||||
let had_conflict_on_last_merge_head_change =
|
||||
self.merge.conflicted_paths.contains(&repo_path);
|
||||
self.merge.conflicted_paths.contains(repo_path);
|
||||
let has_conflict_currently = self
|
||||
.status_for_path(&repo_path)
|
||||
.status_for_path(repo_path)
|
||||
.map_or(false, |entry| entry.status.is_conflicted());
|
||||
had_conflict_on_last_merge_head_change || has_conflict_currently
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ impl Deref for GitEntryRef<'_> {
|
|||
type Target = Entry;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.entry
|
||||
self.entry
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ impl ProjectItem for ImageItem {
|
|||
path: &ProjectPath,
|
||||
cx: &mut App,
|
||||
) -> Option<Task<anyhow::Result<Entity<Self>>>> {
|
||||
if is_image_file(&project, &path, cx) {
|
||||
if is_image_file(project, path, cx) {
|
||||
Some(cx.spawn({
|
||||
let path = path.clone();
|
||||
let project = project.clone();
|
||||
|
|
|
@ -1165,7 +1165,7 @@ pub async fn location_link_from_lsp(
|
|||
server_id: LanguageServerId,
|
||||
cx: &mut AsyncApp,
|
||||
) -> Result<LocationLink> {
|
||||
let (_, language_server) = language_server_for_buffer(&lsp_store, &buffer, server_id, cx)?;
|
||||
let (_, language_server) = language_server_for_buffer(lsp_store, buffer, server_id, cx)?;
|
||||
|
||||
let (origin_range, target_uri, target_range) = (
|
||||
link.origin_selection_range,
|
||||
|
|
|
@ -442,14 +442,14 @@ impl LocalLspStore {
|
|||
match result {
|
||||
Ok(server) => {
|
||||
lsp_store
|
||||
.update(cx, |lsp_store, mut cx| {
|
||||
.update(cx, |lsp_store, cx| {
|
||||
lsp_store.insert_newly_running_language_server(
|
||||
adapter,
|
||||
server.clone(),
|
||||
server_id,
|
||||
key,
|
||||
pending_workspace_folders,
|
||||
&mut cx,
|
||||
cx,
|
||||
);
|
||||
})
|
||||
.ok();
|
||||
|
@ -1927,7 +1927,7 @@ impl LocalLspStore {
|
|||
if let Some(lsp_edits) = lsp_edits {
|
||||
this.update(cx, |this, cx| {
|
||||
this.as_local_mut().unwrap().edits_from_lsp(
|
||||
&buffer_handle,
|
||||
buffer_handle,
|
||||
lsp_edits,
|
||||
language_server.server_id(),
|
||||
None,
|
||||
|
@ -3115,7 +3115,7 @@ impl LocalLspStore {
|
|||
|
||||
let mut servers_to_remove = BTreeSet::default();
|
||||
let mut servers_to_preserve = HashSet::default();
|
||||
for (seed, ref state) in &self.language_server_ids {
|
||||
for (seed, state) in &self.language_server_ids {
|
||||
if seed.worktree_id == id_to_remove {
|
||||
servers_to_remove.insert(state.id);
|
||||
} else {
|
||||
|
@ -3169,7 +3169,7 @@ impl LocalLspStore {
|
|||
|
||||
for watcher in watchers {
|
||||
if let Some((worktree, literal_prefix, pattern)) =
|
||||
self.worktree_and_path_for_file_watcher(&worktrees, &watcher, cx)
|
||||
self.worktree_and_path_for_file_watcher(&worktrees, watcher, cx)
|
||||
{
|
||||
worktree.update(cx, |worktree, _| {
|
||||
if let Some((tree, glob)) =
|
||||
|
@ -4131,7 +4131,7 @@ impl LspStore {
|
|||
local.registered_buffers.remove(&buffer_id);
|
||||
local.buffers_opened_in_servers.remove(&buffer_id);
|
||||
if let Some(file) = File::from_dyn(buffer.read(cx).file()).cloned() {
|
||||
local.unregister_old_buffer_from_language_servers(&buffer, &file, cx);
|
||||
local.unregister_old_buffer_from_language_servers(buffer, &file, cx);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -4453,7 +4453,7 @@ impl LspStore {
|
|||
.contains(&server_status.name)
|
||||
.then_some(server_id)
|
||||
})
|
||||
.filter_map(|server_id| self.lsp_server_capabilities.get(&server_id))
|
||||
.filter_map(|server_id| self.lsp_server_capabilities.get(server_id))
|
||||
.any(check)
|
||||
}
|
||||
|
||||
|
@ -5419,7 +5419,7 @@ impl LspStore {
|
|||
) -> Task<Result<Vec<LocationLink>>> {
|
||||
if let Some((upstream_client, project_id)) = self.upstream_client() {
|
||||
let request = GetTypeDefinitions { position };
|
||||
if !self.is_capable_for_proto_request(&buffer, &request, cx) {
|
||||
if !self.is_capable_for_proto_request(buffer, &request, cx) {
|
||||
return Task::ready(Ok(Vec::new()));
|
||||
}
|
||||
let request_task = upstream_client.request(proto::MultiLspQuery {
|
||||
|
@ -5573,7 +5573,7 @@ impl LspStore {
|
|||
) -> Task<Result<Vec<Location>>> {
|
||||
if let Some((upstream_client, project_id)) = self.upstream_client() {
|
||||
let request = GetReferences { position };
|
||||
if !self.is_capable_for_proto_request(&buffer, &request, cx) {
|
||||
if !self.is_capable_for_proto_request(buffer, &request, cx) {
|
||||
return Task::ready(Ok(Vec::new()));
|
||||
}
|
||||
let request_task = upstream_client.request(proto::MultiLspQuery {
|
||||
|
@ -5755,7 +5755,7 @@ impl LspStore {
|
|||
|
||||
let lsp_data = self.lsp_code_lens.entry(buffer_id).or_default();
|
||||
if let Some((updating_for, running_update)) = &lsp_data.update {
|
||||
if !version_queried_for.changed_since(&updating_for) {
|
||||
if !version_queried_for.changed_since(updating_for) {
|
||||
return running_update.clone();
|
||||
}
|
||||
}
|
||||
|
@ -6786,7 +6786,7 @@ impl LspStore {
|
|||
|
||||
let lsp_data = self.lsp_document_colors.entry(buffer_id).or_default();
|
||||
if let Some((updating_for, running_update)) = &lsp_data.colors_update {
|
||||
if !version_queried_for.changed_since(&updating_for) {
|
||||
if !version_queried_for.changed_since(updating_for) {
|
||||
return Some(running_update.clone());
|
||||
}
|
||||
}
|
||||
|
@ -10057,7 +10057,7 @@ impl LspStore {
|
|||
) -> Shared<Task<Option<HashMap<String, String>>>> {
|
||||
if let Some(environment) = &self.as_local().map(|local| local.environment.clone()) {
|
||||
environment.update(cx, |env, cx| {
|
||||
env.get_buffer_environment(&buffer, &self.worktree_store, cx)
|
||||
env.get_buffer_environment(buffer, &self.worktree_store, cx)
|
||||
})
|
||||
} else {
|
||||
Task::ready(None).shared()
|
||||
|
@ -11175,7 +11175,7 @@ impl LspStore {
|
|||
let Some(local) = self.as_local() else { return };
|
||||
|
||||
local.prettier_store.update(cx, |prettier_store, cx| {
|
||||
prettier_store.update_prettier_settings(&worktree_handle, changes, cx)
|
||||
prettier_store.update_prettier_settings(worktree_handle, changes, cx)
|
||||
});
|
||||
|
||||
let worktree_id = worktree_handle.read(cx).id();
|
||||
|
|
|
@ -199,7 +199,7 @@ impl ManifestTree {
|
|||
) {
|
||||
match evt {
|
||||
WorktreeStoreEvent::WorktreeRemoved(_, worktree_id) => {
|
||||
self.root_points.remove(&worktree_id);
|
||||
self.root_points.remove(worktree_id);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ impl LanguageServerTree {
|
|||
)
|
||||
});
|
||||
languages.insert(language_name.clone());
|
||||
Arc::downgrade(&node).into()
|
||||
Arc::downgrade(node).into()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ impl LanguageServerTree {
|
|||
if !settings.enable_language_server {
|
||||
return Default::default();
|
||||
}
|
||||
let available_lsp_adapters = self.languages.lsp_adapters(&language_name);
|
||||
let available_lsp_adapters = self.languages.lsp_adapters(language_name);
|
||||
let available_language_servers = available_lsp_adapters
|
||||
.iter()
|
||||
.map(|lsp_adapter| lsp_adapter.name.clone())
|
||||
|
@ -287,7 +287,7 @@ impl LanguageServerTree {
|
|||
// (e.g., native vs extension) still end up in the right order at the end, rather than
|
||||
// it being based on which language server happened to be loaded in first.
|
||||
self.languages.reorder_language_servers(
|
||||
&language_name,
|
||||
language_name,
|
||||
adapters_with_settings
|
||||
.values()
|
||||
.map(|(_, adapter)| adapter.clone())
|
||||
|
@ -314,7 +314,7 @@ impl LanguageServerTree {
|
|||
pub(crate) fn remove_nodes(&mut self, ids: &BTreeSet<LanguageServerId>) {
|
||||
for (_, servers) in &mut self.instances {
|
||||
for (_, nodes) in &mut servers.roots {
|
||||
nodes.retain(|_, (node, _)| node.id.get().map_or(true, |id| !ids.contains(&id)));
|
||||
nodes.retain(|_, (node, _)| node.id.get().map_or(true, |id| !ids.contains(id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1848,7 +1848,7 @@ impl Project {
|
|||
cx: &'a mut App,
|
||||
) -> Shared<Task<Option<HashMap<String, String>>>> {
|
||||
self.environment.update(cx, |environment, cx| {
|
||||
environment.get_buffer_environment(&buffer, &worktree_store, cx)
|
||||
environment.get_buffer_environment(buffer, worktree_store, cx)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2592,7 +2592,7 @@ impl Project {
|
|||
cx: &mut App,
|
||||
) -> OpenLspBufferHandle {
|
||||
self.lsp_store.update(cx, |lsp_store, cx| {
|
||||
lsp_store.register_buffer_with_language_servers(&buffer, HashSet::default(), false, cx)
|
||||
lsp_store.register_buffer_with_language_servers(buffer, HashSet::default(), false, cx)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4167,15 +4167,14 @@ impl Project {
|
|||
})
|
||||
.collect();
|
||||
|
||||
cx.spawn(async move |_, mut cx| {
|
||||
cx.spawn(async move |_, cx| {
|
||||
if let Some(buffer_worktree_id) = buffer_worktree_id {
|
||||
if let Some((worktree, _)) = worktrees_with_ids
|
||||
.iter()
|
||||
.find(|(_, id)| *id == buffer_worktree_id)
|
||||
{
|
||||
for candidate in candidates.iter() {
|
||||
if let Some(path) =
|
||||
Self::resolve_path_in_worktree(&worktree, candidate, &mut cx)
|
||||
if let Some(path) = Self::resolve_path_in_worktree(worktree, candidate, cx)
|
||||
{
|
||||
return Some(path);
|
||||
}
|
||||
|
@ -4187,9 +4186,7 @@ impl Project {
|
|||
continue;
|
||||
}
|
||||
for candidate in candidates.iter() {
|
||||
if let Some(path) =
|
||||
Self::resolve_path_in_worktree(&worktree, candidate, &mut cx)
|
||||
{
|
||||
if let Some(path) = Self::resolve_path_in_worktree(&worktree, candidate, cx) {
|
||||
return Some(path);
|
||||
}
|
||||
}
|
||||
|
@ -5329,7 +5326,7 @@ impl ResolvedPath {
|
|||
|
||||
pub fn project_path(&self) -> Option<&ProjectPath> {
|
||||
match self {
|
||||
Self::ProjectPath { project_path, .. } => Some(&project_path),
|
||||
Self::ProjectPath { project_path, .. } => Some(project_path),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -5399,7 +5396,7 @@ impl Completion {
|
|||
_ => None,
|
||||
})
|
||||
.unwrap_or(DEFAULT_KIND_KEY);
|
||||
(kind_key, &self.label.filter_text())
|
||||
(kind_key, self.label.filter_text())
|
||||
}
|
||||
|
||||
/// Whether this completion is a snippet.
|
||||
|
|
|
@ -1105,7 +1105,7 @@ impl SettingsObserver {
|
|||
cx: &mut Context<Self>,
|
||||
) -> Task<()> {
|
||||
let mut user_tasks_file_rx =
|
||||
watch_config_file(&cx.background_executor(), fs, file_path.clone());
|
||||
watch_config_file(cx.background_executor(), fs, file_path.clone());
|
||||
let user_tasks_content = cx.background_executor().block(user_tasks_file_rx.next());
|
||||
let weak_entry = cx.weak_entity();
|
||||
cx.spawn(async move |settings_observer, cx| {
|
||||
|
@ -1160,7 +1160,7 @@ impl SettingsObserver {
|
|||
cx: &mut Context<Self>,
|
||||
) -> Task<()> {
|
||||
let mut user_tasks_file_rx =
|
||||
watch_config_file(&cx.background_executor(), fs, file_path.clone());
|
||||
watch_config_file(cx.background_executor(), fs, file_path.clone());
|
||||
let user_tasks_content = cx.background_executor().block(user_tasks_file_rx.next());
|
||||
let weak_entry = cx.weak_entity();
|
||||
cx.spawn(async move |settings_observer, cx| {
|
||||
|
|
|
@ -333,7 +333,7 @@ impl Inventory {
|
|||
|
||||
for locator in locators.values() {
|
||||
if let Some(scenario) = locator
|
||||
.create_scenario(&task.original_task(), &task.display_label(), &adapter)
|
||||
.create_scenario(task.original_task(), task.display_label(), &adapter)
|
||||
.await
|
||||
{
|
||||
scenarios.push((kind, scenario));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue