Skip to content

Commit 2071d0b

Browse files
bors[bot]Veetaha
andauthored
Merge #3845
3845: Simplify config r=matklad a=Veetaha Co-authored-by: veetaha <[email protected]>
2 parents cdb80ef + a1773f8 commit 2071d0b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,10 @@ impl Config {
120120
set(value, "/withSysroot", &mut self.with_sysroot);
121121
set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics);
122122
set(value, "/lruCapacity", &mut self.lru_capacity);
123-
if let Some(watcher) = get::<String>(value, "/files/watcher") {
124-
self.files.watcher = match watcher.as_str() {
125-
"client" => FilesWatcher::Client,
126-
"notify"| _ => FilesWatcher::Notify,
127-
}
128-
}
123+
self.files.watcher = match get(value, "/files/watcher") {
124+
Some("client") => FilesWatcher::Client,
125+
Some("notify") | _ => FilesWatcher::Notify
126+
};
129127
set(value, "/notifications/workspaceLoaded", &mut self.notifications.workspace_loaded);
130128
set(value, "/notifications/cargoTomlNotFound", &mut self.notifications.cargo_toml_not_found);
131129

@@ -144,16 +142,17 @@ impl Config {
144142
} else if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt {
145143
set(value, "/rustfmt/extraArgs", extra_args);
146144
}
145+
147146
if let Some(false) = get(value, "/checkOnSave/enable") {
148-
self.check = None
147+
self.check = None;
149148
} else {
150149
if let Some(mut args) = get::<Vec<String>>(value, "/checkOnSave/overrideCommand") {
151150
if !args.is_empty() {
152151
let command = args.remove(0);
153152
self.check = Some(FlycheckConfig::CustomCommand {
154153
command,
155154
args,
156-
})
155+
});
157156
}
158157

159158
} else if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check
@@ -179,7 +178,7 @@ impl Config {
179178
value.pointer(pointer).and_then(|it| T::deserialize(it).ok())
180179
}
181180

182-
fn set<'a, T: Deserialize<'a> + std::fmt::Debug>(value: &'a serde_json::Value, pointer: &str, slot: &mut T) {
181+
fn set<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str, slot: &mut T) {
183182
if let Some(new_value) = get(value, pointer) {
184183
*slot = new_value
185184
}

0 commit comments

Comments
 (0)