@@ -124,65 +124,8 @@ config_data! {
124
124
/// Unsets `#[cfg(test)]` for the specified crates.
125
125
cargo_unsetTest: Vec <String > = "[\" core\" ]" ,
126
126
127
- /// Check all targets and tests (`--all-targets`).
128
- checkOnSave_allTargets: bool = "true" ,
129
- /// Cargo command to use for `cargo check`.
130
- checkOnSave_command: String = "\" check\" " ,
131
- /// Run specified `cargo check` command for diagnostics on save.
132
- checkOnSave_enable: bool = "true" ,
133
- /// Extra arguments for `cargo check`.
134
- checkOnSave_extraArgs: Vec <String > = "[]" ,
135
- /// Extra environment variables that will be set when running `cargo check`.
136
- /// Extends `#rust-analyzer.cargo.extraEnv#`.
137
- checkOnSave_extraEnv: FxHashMap <String , String > = "{}" ,
138
- /// List of features to activate. Defaults to
139
- /// `#rust-analyzer.cargo.features#`.
140
- ///
141
- /// Set to `"all"` to pass `--all-features` to Cargo.
142
- checkOnSave_features: Option <CargoFeaturesDef > = "null" ,
143
- /// Specifies the working directory for running checks.
144
- /// - "workspace": run checks for workspaces in the corresponding workspaces' root directories.
145
- // FIXME: Ideally we would support this in some way
146
- /// This falls back to "root" if `#rust-analyzer.cargo.checkOnSave.invocationStrategy#` is set to `once`.
147
- /// - "root": run checks in the project's root directory.
148
- /// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
149
- /// is set.
150
- checkOnSave_invocationLocation: InvocationLocation = "\" workspace\" " ,
151
- /// Specifies the invocation strategy to use when running the checkOnSave command.
152
- /// If `per_workspace` is set, the command will be executed for each workspace.
153
- /// If `once` is set, the command will be executed once.
154
- /// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
155
- /// is set.
156
- checkOnSave_invocationStrategy: InvocationStrategy = "\" per_workspace\" " ,
157
- /// Whether to pass `--no-default-features` to Cargo. Defaults to
158
- /// `#rust-analyzer.cargo.noDefaultFeatures#`.
159
- checkOnSave_noDefaultFeatures: Option <bool > = "null" ,
160
- /// Override the command rust-analyzer uses instead of `cargo check` for
161
- /// diagnostics on save. The command is required to output json and
162
- /// should therefore include `--message-format=json` or a similar option.
163
- ///
164
- /// If you're changing this because you're using some tool wrapping
165
- /// Cargo, you might also want to change
166
- /// `#rust-analyzer.cargo.buildScripts.overrideCommand#`.
167
- ///
168
- /// If there are multiple linked projects, this command is invoked for
169
- /// each of them, with the working directory being the project root
170
- /// (i.e., the folder containing the `Cargo.toml`).
171
- ///
172
- /// An example command would be:
173
- ///
174
- /// ```bash
175
- /// cargo check --workspace --message-format=json --all-targets
176
- /// ```
177
- /// .
178
- checkOnSave_overrideCommand: Option <Vec <String >> = "null" ,
179
- /// Check for specific targets. Defaults to `#rust-analyzer.cargo.target#` if empty.
180
- ///
181
- /// Can be a single target, e.g. `"x86_64-unknown-linux-gnu"` or a list of targets, e.g.
182
- /// `["aarch64-apple-darwin", "x86_64-apple-darwin"]`.
183
- ///
184
- /// Aliased as `"checkOnSave.targets"`.
185
- checkOnSave_target | checkOnSave_targets: Option <CheckOnSaveTargets > = "null" ,
127
+ /// Run the flycheck command for diagnostics on save.
128
+ checkOnSave | checkOnSave_enable: bool = "true" ,
186
129
187
130
/// Toggles the additional completions that automatically add imports when completed.
188
131
/// Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.
@@ -268,6 +211,64 @@ config_data! {
268
211
/// Controls file watching implementation.
269
212
files_watcher: FilesWatcherDef = "\" client\" " ,
270
213
214
+ /// Check all targets and tests (`--all-targets`).
215
+ flycheck_allTargets | checkOnSave_allTargets: bool = "true" ,
216
+ /// Cargo command to use for `cargo check`.
217
+ flycheck_command | checkOnSave_command: String = "\" check\" " ,
218
+ /// Extra arguments for `cargo check`.
219
+ flycheck_extraArgs | checkOnSave_extraArgs: Vec <String > = "[]" ,
220
+ /// Extra environment variables that will be set when running `cargo check`.
221
+ /// Extends `#rust-analyzer.cargo.extraEnv#`.
222
+ flycheck_extraEnv | checkOnSave_extraEnv: FxHashMap <String , String > = "{}" ,
223
+ /// List of features to activate. Defaults to
224
+ /// `#rust-analyzer.cargo.features#`.
225
+ ///
226
+ /// Set to `"all"` to pass `--all-features` to Cargo.
227
+ flycheck_features | checkOnSave_features: Option <CargoFeaturesDef > = "null" ,
228
+ /// Specifies the working directory for running checks.
229
+ /// - "workspace": run checks for workspaces in the corresponding workspaces' root directories.
230
+ // FIXME: Ideally we would support this in some way
231
+ /// This falls back to "root" if `#rust-analyzer.cargo.checkOnSave.invocationStrategy#` is set to `once`.
232
+ /// - "root": run checks in the project's root directory.
233
+ /// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
234
+ /// is set.
235
+ flycheck_invocationLocation | checkOnSave_invocationLocation: InvocationLocation = "\" workspace\" " ,
236
+ /// Specifies the invocation strategy to use when running the checkOnSave command.
237
+ /// If `per_workspace` is set, the command will be executed for each workspace.
238
+ /// If `once` is set, the command will be executed once.
239
+ /// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
240
+ /// is set.
241
+ flycheck_invocationStrategy | checkOnSave_invocationStrategy: InvocationStrategy = "\" per_workspace\" " ,
242
+ /// Whether to pass `--no-default-features` to Cargo. Defaults to
243
+ /// `#rust-analyzer.cargo.noDefaultFeatures#`.
244
+ flycheck_noDefaultFeatures | checkOnSave_noDefaultFeatures: Option <bool > = "null" ,
245
+ /// Override the command rust-analyzer uses instead of `cargo check` for
246
+ /// diagnostics on save. The command is required to output json and
247
+ /// should therefore include `--message-format=json` or a similar option.
248
+ ///
249
+ /// If you're changing this because you're using some tool wrapping
250
+ /// Cargo, you might also want to change
251
+ /// `#rust-analyzer.cargo.buildScripts.overrideCommand#`.
252
+ ///
253
+ /// If there are multiple linked projects, this command is invoked for
254
+ /// each of them, with the working directory being the project root
255
+ /// (i.e., the folder containing the `Cargo.toml`).
256
+ ///
257
+ /// An example command would be:
258
+ ///
259
+ /// ```bash
260
+ /// cargo check --workspace --message-format=json --all-targets
261
+ /// ```
262
+ /// .
263
+ flycheck_overrideCommand | checkOnSave_overrideCommand: Option <Vec <String >> = "null" ,
264
+ /// Check for specific targets. Defaults to `#rust-analyzer.cargo.target#` if empty.
265
+ ///
266
+ /// Can be a single target, e.g. `"x86_64-unknown-linux-gnu"` or a list of targets, e.g.
267
+ /// `["aarch64-apple-darwin", "x86_64-apple-darwin"]`.
268
+ ///
269
+ /// Aliased as `"checkOnSave.targets"`.
270
+ flycheck_targets | checkOnSave_targets | checkOnSave_target: Option <CheckOnSaveTargets > = "null" ,
271
+
271
272
/// Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords.
272
273
highlightRelated_breakPoints_enable: bool = "true" ,
273
274
/// Enables highlighting of all exit points while the cursor is on any `return`, `?`, `fn`, or return type arrow (`->`).
@@ -786,9 +787,9 @@ impl Config {
786
787
787
788
fn validate ( & self , error_sink : & mut Vec < ( String , serde_json:: Error ) > ) {
788
789
use serde:: de:: Error ;
789
- if self . data . checkOnSave_command . is_empty ( ) {
790
+ if self . data . flycheck_command . is_empty ( ) {
790
791
error_sink. push ( (
791
- "/checkOnSave /command" . to_string ( ) ,
792
+ "/flycheck /command" . to_string ( ) ,
792
793
serde_json:: Error :: custom ( "expected a non-empty string" ) ,
793
794
) ) ;
794
795
}
@@ -1033,7 +1034,7 @@ impl Config {
1033
1034
1034
1035
pub fn check_on_save_extra_env ( & self ) -> FxHashMap < String , String > {
1035
1036
let mut extra_env = self . data . cargo_extraEnv . clone ( ) ;
1036
- extra_env. extend ( self . data . checkOnSave_extraEnv . clone ( ) ) ;
1037
+ extra_env. extend ( self . data . flycheck_extraEnv . clone ( ) ) ;
1037
1038
extra_env
1038
1039
}
1039
1040
@@ -1145,21 +1146,21 @@ impl Config {
1145
1146
}
1146
1147
1147
1148
pub fn flycheck ( & self ) -> FlycheckConfig {
1148
- match & self . data . checkOnSave_overrideCommand {
1149
+ match & self . data . flycheck_overrideCommand {
1149
1150
Some ( args) if !args. is_empty ( ) => {
1150
1151
let mut args = args. clone ( ) ;
1151
1152
let command = args. remove ( 0 ) ;
1152
1153
FlycheckConfig :: CustomCommand {
1153
1154
command,
1154
1155
args,
1155
1156
extra_env : self . check_on_save_extra_env ( ) ,
1156
- invocation_strategy : match self . data . checkOnSave_invocationStrategy {
1157
+ invocation_strategy : match self . data . flycheck_invocationStrategy {
1157
1158
InvocationStrategy :: Once => flycheck:: InvocationStrategy :: Once ,
1158
1159
InvocationStrategy :: PerWorkspace => {
1159
1160
flycheck:: InvocationStrategy :: PerWorkspace
1160
1161
}
1161
1162
} ,
1162
- invocation_location : match self . data . checkOnSave_invocationLocation {
1163
+ invocation_location : match self . data . flycheck_invocationLocation {
1163
1164
InvocationLocation :: Root => {
1164
1165
flycheck:: InvocationLocation :: Root ( self . root_path . clone ( ) )
1165
1166
}
@@ -1168,42 +1169,42 @@ impl Config {
1168
1169
}
1169
1170
}
1170
1171
Some ( _) | None => FlycheckConfig :: CargoCommand {
1171
- command : self . data . checkOnSave_command . clone ( ) ,
1172
+ command : self . data . flycheck_command . clone ( ) ,
1172
1173
target_triples : self
1173
1174
. data
1174
- . checkOnSave_target
1175
+ . flycheck_targets
1175
1176
. clone ( )
1176
1177
. and_then ( |targets| match & targets. 0 [ ..] {
1177
1178
[ ] => None ,
1178
1179
targets => Some ( targets. into ( ) ) ,
1179
1180
} )
1180
1181
. unwrap_or_else ( || self . data . cargo_target . clone ( ) . into_iter ( ) . collect ( ) ) ,
1181
- all_targets : self . data . checkOnSave_allTargets ,
1182
+ all_targets : self . data . flycheck_allTargets ,
1182
1183
no_default_features : self
1183
1184
. data
1184
- . checkOnSave_noDefaultFeatures
1185
+ . flycheck_noDefaultFeatures
1185
1186
. unwrap_or ( self . data . cargo_noDefaultFeatures ) ,
1186
1187
all_features : matches ! (
1187
- self . data. checkOnSave_features . as_ref( ) . unwrap_or( & self . data. cargo_features) ,
1188
+ self . data. flycheck_features . as_ref( ) . unwrap_or( & self . data. cargo_features) ,
1188
1189
CargoFeaturesDef :: All
1189
1190
) ,
1190
1191
features : match self
1191
1192
. data
1192
- . checkOnSave_features
1193
+ . flycheck_features
1193
1194
. clone ( )
1194
1195
. unwrap_or_else ( || self . data . cargo_features . clone ( ) )
1195
1196
{
1196
1197
CargoFeaturesDef :: All => vec ! [ ] ,
1197
1198
CargoFeaturesDef :: Selected ( it) => it,
1198
1199
} ,
1199
- extra_args : self . data . checkOnSave_extraArgs . clone ( ) ,
1200
+ extra_args : self . data . flycheck_extraArgs . clone ( ) ,
1200
1201
extra_env : self . check_on_save_extra_env ( ) ,
1201
1202
} ,
1202
1203
}
1203
1204
}
1204
1205
1205
1206
pub fn check_on_save ( & self ) -> bool {
1206
- self . data . checkOnSave_enable
1207
+ self . data . checkOnSave
1207
1208
}
1208
1209
1209
1210
pub fn runnables ( & self ) -> RunnablesConfig {
@@ -1862,25 +1863,27 @@ fn get_field<T: DeserializeOwned>(
1862
1863
alias : Option < & ' static str > ,
1863
1864
default : & str ,
1864
1865
) -> T {
1865
- let default = serde_json:: from_str ( default) . unwrap ( ) ;
1866
1866
// XXX: check alias first, to work-around the VS Code where it pre-fills the
1867
1867
// defaults instead of sending an empty object.
1868
1868
alias
1869
1869
. into_iter ( )
1870
1870
. chain ( iter:: once ( field) )
1871
- . find_map ( move |field| {
1871
+ . filter_map ( move |field| {
1872
1872
let mut pointer = field. replace ( '_' , "/" ) ;
1873
1873
pointer. insert ( 0 , '/' ) ;
1874
- json. pointer_mut ( & pointer) . and_then ( |it| match serde_json:: from_value ( it. take ( ) ) {
1875
- Ok ( it) => Some ( it) ,
1876
- Err ( e) => {
1877
- tracing:: warn!( "Failed to deserialize config field at {}: {:?}" , pointer, e) ;
1878
- error_sink. push ( ( pointer, e) ) ;
1879
- None
1880
- }
1881
- } )
1874
+ json. pointer_mut ( & pointer)
1875
+ . map ( |it| serde_json:: from_value ( it. take ( ) ) . map_err ( |e| ( e, pointer) ) )
1876
+ } )
1877
+ . find ( Result :: is_ok)
1878
+ . and_then ( |res| match res {
1879
+ Ok ( it) => Some ( it) ,
1880
+ Err ( ( e, pointer) ) => {
1881
+ tracing:: warn!( "Failed to deserialize config field at {}: {:?}" , pointer, e) ;
1882
+ error_sink. push ( ( pointer, e) ) ;
1883
+ None
1884
+ }
1882
1885
} )
1883
- . unwrap_or ( default)
1886
+ . unwrap_or_else ( || serde_json :: from_str ( default) . unwrap ( ) )
1884
1887
}
1885
1888
1886
1889
fn schema ( fields : & [ ( & ' static str , & ' static str , & [ & str ] , & str ) ] ) -> serde_json:: Value {
@@ -1964,15 +1967,6 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
1964
1967
"type" : [ "null" , "array" ] ,
1965
1968
"items" : { "type" : "string" } ,
1966
1969
} ,
1967
- "MergeBehaviorDef" => set ! {
1968
- "type" : "string" ,
1969
- "enum" : [ "none" , "crate" , "module" ] ,
1970
- "enumDescriptions" : [
1971
- "Do not merge imports at all." ,
1972
- "Merge imports from the same crate into a single `use` statement." ,
1973
- "Merge imports from the same module into a single `use` statement."
1974
- ] ,
1975
- } ,
1976
1970
"ExprFillDefaultDef" => set ! {
1977
1971
"type" : "string" ,
1978
1972
"enum" : [ "todo" , "default" ] ,
0 commit comments