Fix clippy::redundant_clone
lint violations (#36558)
This removes around 900 unnecessary clones, ranging from cloning a few ints all the way to large data structures and images. A lot of these were fixed using `cargo clippy --fix --workspace --all-targets`, however it often breaks other lints and needs to be run again. This was then followed up with some manual fixing. I understand this is a large diff, but all the changes are pretty trivial. Rust is doing some heavy lifting here for us. Once I get it up to speed with main, I'd appreciate this getting merged rather sooner than later. Release Notes: - N/A
This commit is contained in:
parent
cf7c64d77f
commit
7bdc99abc1
306 changed files with 805 additions and 1102 deletions
|
@ -22,7 +22,7 @@ impl CLspAdapter {
|
|||
#[async_trait(?Send)]
|
||||
impl super::LspAdapter for CLspAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
Self::SERVER_NAME.clone()
|
||||
Self::SERVER_NAME
|
||||
}
|
||||
|
||||
async fn check_if_user_installed(
|
||||
|
@ -253,8 +253,7 @@ impl super::LspAdapter for CLspAdapter {
|
|||
.grammar()
|
||||
.and_then(|g| g.highlight_id_for_name(highlight_name?))
|
||||
{
|
||||
let mut label =
|
||||
CodeLabel::plain(label.to_string(), completion.filter_text.as_deref());
|
||||
let mut label = CodeLabel::plain(label, completion.filter_text.as_deref());
|
||||
label.runs.push((
|
||||
0..label.text.rfind('(').unwrap_or(label.text.len()),
|
||||
highlight_id,
|
||||
|
@ -264,10 +263,7 @@ impl super::LspAdapter for CLspAdapter {
|
|||
}
|
||||
_ => {}
|
||||
}
|
||||
Some(CodeLabel::plain(
|
||||
label.to_string(),
|
||||
completion.filter_text.as_deref(),
|
||||
))
|
||||
Some(CodeLabel::plain(label, completion.filter_text.as_deref()))
|
||||
}
|
||||
|
||||
async fn label_for_symbol(
|
||||
|
|
|
@ -53,7 +53,7 @@ const BINARY: &str = if cfg!(target_os = "windows") {
|
|||
#[async_trait(?Send)]
|
||||
impl super::LspAdapter for GoLspAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
Self::SERVER_NAME.clone()
|
||||
Self::SERVER_NAME
|
||||
}
|
||||
|
||||
async fn fetch_latest_server_version(
|
||||
|
@ -525,7 +525,7 @@ impl ContextProvider for GoContextProvider {
|
|||
})
|
||||
.unwrap_or_else(|| format!("{}", buffer_dir.to_string_lossy()));
|
||||
|
||||
(GO_PACKAGE_TASK_VARIABLE.clone(), package_name.to_string())
|
||||
(GO_PACKAGE_TASK_VARIABLE.clone(), package_name)
|
||||
});
|
||||
|
||||
let go_module_root_variable = local_abs_path
|
||||
|
@ -702,7 +702,7 @@ impl ContextProvider for GoContextProvider {
|
|||
label: format!("go generate {}", GO_PACKAGE_TASK_VARIABLE.template_value()),
|
||||
command: "go".into(),
|
||||
args: vec!["generate".into()],
|
||||
cwd: package_cwd.clone(),
|
||||
cwd: package_cwd,
|
||||
tags: vec!["go-generate".to_owned()],
|
||||
..TaskTemplate::default()
|
||||
},
|
||||
|
@ -710,7 +710,7 @@ impl ContextProvider for GoContextProvider {
|
|||
label: "go generate ./...".into(),
|
||||
command: "go".into(),
|
||||
args: vec!["generate".into(), "./...".into()],
|
||||
cwd: module_cwd.clone(),
|
||||
cwd: module_cwd,
|
||||
..TaskTemplate::default()
|
||||
},
|
||||
])))
|
||||
|
|
|
@ -488,7 +488,7 @@ impl NodeVersionAdapter {
|
|||
#[async_trait(?Send)]
|
||||
impl LspAdapter for NodeVersionAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
Self::SERVER_NAME.clone()
|
||||
Self::SERVER_NAME
|
||||
}
|
||||
|
||||
async fn fetch_latest_server_version(
|
||||
|
|
|
@ -104,7 +104,7 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
|
|||
let typescript_context = Arc::new(typescript::TypeScriptContextProvider::new());
|
||||
let typescript_lsp_adapter = Arc::new(typescript::TypeScriptLspAdapter::new(node.clone()));
|
||||
let vtsls_adapter = Arc::new(vtsls::VtslsLspAdapter::new(node.clone()));
|
||||
let yaml_lsp_adapter = Arc::new(yaml::YamlLspAdapter::new(node.clone()));
|
||||
let yaml_lsp_adapter = Arc::new(yaml::YamlLspAdapter::new(node));
|
||||
|
||||
let built_in_languages = [
|
||||
LanguageInfo {
|
||||
|
@ -119,12 +119,12 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
|
|||
},
|
||||
LanguageInfo {
|
||||
name: "cpp",
|
||||
adapters: vec![c_lsp_adapter.clone()],
|
||||
adapters: vec![c_lsp_adapter],
|
||||
..Default::default()
|
||||
},
|
||||
LanguageInfo {
|
||||
name: "css",
|
||||
adapters: vec![css_lsp_adapter.clone()],
|
||||
adapters: vec![css_lsp_adapter],
|
||||
..Default::default()
|
||||
},
|
||||
LanguageInfo {
|
||||
|
@ -146,20 +146,20 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
|
|||
},
|
||||
LanguageInfo {
|
||||
name: "gowork",
|
||||
adapters: vec![go_lsp_adapter.clone()],
|
||||
context: Some(go_context_provider.clone()),
|
||||
adapters: vec![go_lsp_adapter],
|
||||
context: Some(go_context_provider),
|
||||
..Default::default()
|
||||
},
|
||||
LanguageInfo {
|
||||
name: "json",
|
||||
adapters: vec![json_lsp_adapter.clone(), node_version_lsp_adapter.clone()],
|
||||
adapters: vec![json_lsp_adapter.clone(), node_version_lsp_adapter],
|
||||
context: Some(json_context_provider.clone()),
|
||||
..Default::default()
|
||||
},
|
||||
LanguageInfo {
|
||||
name: "jsonc",
|
||||
adapters: vec![json_lsp_adapter.clone()],
|
||||
context: Some(json_context_provider.clone()),
|
||||
adapters: vec![json_lsp_adapter],
|
||||
context: Some(json_context_provider),
|
||||
..Default::default()
|
||||
},
|
||||
LanguageInfo {
|
||||
|
@ -174,7 +174,7 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
|
|||
},
|
||||
LanguageInfo {
|
||||
name: "python",
|
||||
adapters: vec![python_lsp_adapter.clone(), py_lsp_adapter.clone()],
|
||||
adapters: vec![python_lsp_adapter, py_lsp_adapter],
|
||||
context: Some(python_context_provider),
|
||||
toolchain: Some(python_toolchain_provider),
|
||||
manifest_name: Some(SharedString::new_static("pyproject.toml").into()),
|
||||
|
@ -201,7 +201,7 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
|
|||
LanguageInfo {
|
||||
name: "javascript",
|
||||
adapters: vec![typescript_lsp_adapter.clone(), vtsls_adapter.clone()],
|
||||
context: Some(typescript_context.clone()),
|
||||
context: Some(typescript_context),
|
||||
..Default::default()
|
||||
},
|
||||
LanguageInfo {
|
||||
|
@ -277,13 +277,13 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
|
|||
move || adapter.clone()
|
||||
});
|
||||
languages.register_available_lsp_adapter(LanguageServerName("vtsls".into()), {
|
||||
let adapter = vtsls_adapter.clone();
|
||||
let adapter = vtsls_adapter;
|
||||
move || adapter.clone()
|
||||
});
|
||||
languages.register_available_lsp_adapter(
|
||||
LanguageServerName("typescript-language-server".into()),
|
||||
{
|
||||
let adapter = typescript_lsp_adapter.clone();
|
||||
let adapter = typescript_lsp_adapter;
|
||||
move || adapter.clone()
|
||||
},
|
||||
);
|
||||
|
|
|
@ -103,7 +103,7 @@ impl PythonLspAdapter {
|
|||
#[async_trait(?Send)]
|
||||
impl LspAdapter for PythonLspAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
Self::SERVER_NAME.clone()
|
||||
Self::SERVER_NAME
|
||||
}
|
||||
|
||||
async fn initialization_options(
|
||||
|
@ -1026,7 +1026,7 @@ const BINARY_DIR: &str = if cfg!(target_os = "windows") {
|
|||
#[async_trait(?Send)]
|
||||
impl LspAdapter for PyLspAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
Self::SERVER_NAME.clone()
|
||||
Self::SERVER_NAME
|
||||
}
|
||||
|
||||
async fn check_if_user_installed(
|
||||
|
@ -1318,7 +1318,7 @@ impl BasedPyrightLspAdapter {
|
|||
#[async_trait(?Send)]
|
||||
impl LspAdapter for BasedPyrightLspAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
Self::SERVER_NAME.clone()
|
||||
Self::SERVER_NAME
|
||||
}
|
||||
|
||||
async fn initialization_options(
|
||||
|
|
|
@ -106,7 +106,7 @@ impl ManifestProvider for CargoManifestProvider {
|
|||
#[async_trait(?Send)]
|
||||
impl LspAdapter for RustLspAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
SERVER_NAME.clone()
|
||||
SERVER_NAME
|
||||
}
|
||||
|
||||
async fn check_if_user_installed(
|
||||
|
@ -659,7 +659,7 @@ impl ContextProvider for RustContextProvider {
|
|||
.variables
|
||||
.get(CUSTOM_TARGET_DIR)
|
||||
.cloned();
|
||||
let run_task_args = if let Some(package_to_run) = package_to_run.clone() {
|
||||
let run_task_args = if let Some(package_to_run) = package_to_run {
|
||||
vec!["run".into(), "-p".into(), package_to_run]
|
||||
} else {
|
||||
vec!["run".into()]
|
||||
|
@ -1019,8 +1019,8 @@ async fn get_cached_server_binary(container_dir: PathBuf) -> Option<LanguageServ
|
|||
|
||||
let path = last.context("no cached binary")?;
|
||||
let path = match RustLspAdapter::GITHUB_ASSET_KIND {
|
||||
AssetKind::TarGz | AssetKind::Gz => path.clone(), // Tar and gzip extract in place.
|
||||
AssetKind::Zip => path.clone().join("rust-analyzer.exe"), // zip contains a .exe
|
||||
AssetKind::TarGz | AssetKind::Gz => path, // Tar and gzip extract in place.
|
||||
AssetKind::Zip => path.join("rust-analyzer.exe"), // zip contains a .exe
|
||||
};
|
||||
|
||||
anyhow::Ok(LanguageServerBinary {
|
||||
|
|
|
@ -44,7 +44,7 @@ impl TailwindLspAdapter {
|
|||
#[async_trait(?Send)]
|
||||
impl LspAdapter for TailwindLspAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
Self::SERVER_NAME.clone()
|
||||
Self::SERVER_NAME
|
||||
}
|
||||
|
||||
async fn check_if_user_installed(
|
||||
|
|
|
@ -557,7 +557,7 @@ struct TypeScriptVersions {
|
|||
#[async_trait(?Send)]
|
||||
impl LspAdapter for TypeScriptLspAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
Self::SERVER_NAME.clone()
|
||||
Self::SERVER_NAME
|
||||
}
|
||||
|
||||
async fn fetch_latest_server_version(
|
||||
|
@ -879,7 +879,7 @@ impl LspAdapter for EsLintLspAdapter {
|
|||
}
|
||||
|
||||
fn name(&self) -> LanguageServerName {
|
||||
Self::SERVER_NAME.clone()
|
||||
Self::SERVER_NAME
|
||||
}
|
||||
|
||||
async fn fetch_latest_server_version(
|
||||
|
|
|
@ -67,7 +67,7 @@ const SERVER_NAME: LanguageServerName = LanguageServerName::new_static("vtsls");
|
|||
#[async_trait(?Send)]
|
||||
impl LspAdapter for VtslsLspAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
SERVER_NAME.clone()
|
||||
SERVER_NAME
|
||||
}
|
||||
|
||||
async fn fetch_latest_server_version(
|
||||
|
|
|
@ -38,7 +38,7 @@ impl YamlLspAdapter {
|
|||
#[async_trait(?Send)]
|
||||
impl LspAdapter for YamlLspAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
Self::SERVER_NAME.clone()
|
||||
Self::SERVER_NAME
|
||||
}
|
||||
|
||||
async fn fetch_latest_server_version(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue