From b5a7cb331fed8215caef3ae276bcb90b1cc59981 Mon Sep 17 00:00:00 2001 From: veetaha Date: Sat, 4 Apr 2020 16:04:49 +0300 Subject: Simplify config --- crates/rust-analyzer/src/config.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 04f5bb473..113aa77af 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -120,12 +120,10 @@ impl Config { set(value, "/withSysroot", &mut self.with_sysroot); set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics); set(value, "/lruCapacity", &mut self.lru_capacity); - if let Some(watcher) = get::(value, "/files/watcher") { - self.files.watcher = match watcher.as_str() { - "client" => FilesWatcher::Client, - "notify"| _ => FilesWatcher::Notify, - } - } + self.files.watcher = match get::<&str>(value, "/files/watcher") { + Some("client") => FilesWatcher::Client, + Some("notify") | _ => FilesWatcher::Notify + }; set(value, "/notifications/workspaceLoaded", &mut self.notifications.workspace_loaded); set(value, "/notifications/cargoTomlNotFound", &mut self.notifications.cargo_toml_not_found); @@ -144,8 +142,9 @@ impl Config { } else if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { set(value, "/rustfmt/extraArgs", extra_args); } + if let Some(false) = get(value, "/checkOnSave/enable") { - self.check = None + self.check = None; } else { if let Some(mut args) = get::>(value, "/checkOnSave/overrideCommand") { if !args.is_empty() { @@ -153,7 +152,7 @@ impl Config { self.check = Some(FlycheckConfig::CustomCommand { command, args, - }) + }); } } else if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check @@ -179,7 +178,7 @@ impl Config { value.pointer(pointer).and_then(|it| T::deserialize(it).ok()) } - fn set<'a, T: Deserialize<'a> + std::fmt::Debug>(value: &'a serde_json::Value, pointer: &str, slot: &mut T) { + fn set<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str, slot: &mut T) { if let Some(new_value) = get(value, pointer) { *slot = new_value } -- cgit v1.2.3 From a1773f8a6780d8e9f9953a50cfb6bdf43d37ee3a Mon Sep 17 00:00:00 2001 From: veetaha Date: Sat, 4 Apr 2020 16:12:09 +0300 Subject: Remove explicit generic type parameter --- crates/rust-analyzer/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 113aa77af..b6a015790 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -120,7 +120,7 @@ impl Config { set(value, "/withSysroot", &mut self.with_sysroot); set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics); set(value, "/lruCapacity", &mut self.lru_capacity); - self.files.watcher = match get::<&str>(value, "/files/watcher") { + self.files.watcher = match get(value, "/files/watcher") { Some("client") => FilesWatcher::Client, Some("notify") | _ => FilesWatcher::Notify }; -- cgit v1.2.3