@@ -124,9 +124,67 @@ config_data! {
124
124
/// Unsets `#[cfg(test)]` for the specified crates.
125
125
cargo_unsetTest: Vec <String > = "[\" core\" ]" ,
126
126
127
- /// Run the flycheck command for diagnostics on save.
127
+ /// Run the check command for diagnostics on save.
128
128
checkOnSave | checkOnSave_enable: bool = "true" ,
129
129
130
+ /// Check all targets and tests (`--all-targets`).
131
+ check_allTargets | checkOnSave_allTargets: bool = "true" ,
132
+ /// Cargo command to use for `cargo check`.
133
+ check_command | checkOnSave_command: String = "\" check\" " ,
134
+ /// Extra arguments for `cargo check`.
135
+ check_extraArgs | checkOnSave_extraArgs: Vec <String > = "[]" ,
136
+ /// Extra environment variables that will be set when running `cargo check`.
137
+ /// Extends `#rust-analyzer.cargo.extraEnv#`.
138
+ check_extraEnv | checkOnSave_extraEnv: FxHashMap <String , String > = "{}" ,
139
+ /// List of features to activate. Defaults to
140
+ /// `#rust-analyzer.cargo.features#`.
141
+ ///
142
+ /// Set to `"all"` to pass `--all-features` to Cargo.
143
+ check_features | checkOnSave_features: Option <CargoFeaturesDef > = "null" ,
144
+ /// Specifies the working directory for running checks.
145
+ /// - "workspace": run checks for workspaces in the corresponding workspaces' root directories.
146
+ // FIXME: Ideally we would support this in some way
147
+ /// This falls back to "root" if `#rust-analyzer.cargo.checkOnSave.invocationStrategy#` is set to `once`.
148
+ /// - "root": run checks in the project's root directory.
149
+ /// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
150
+ /// is set.
151
+ check_invocationLocation | checkOnSave_invocationLocation: InvocationLocation = "\" workspace\" " ,
152
+ /// Specifies the invocation strategy to use when running the checkOnSave command.
153
+ /// If `per_workspace` is set, the command will be executed for each workspace.
154
+ /// If `once` is set, the command will be executed once.
155
+ /// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
156
+ /// is set.
157
+ check_invocationStrategy | checkOnSave_invocationStrategy: InvocationStrategy = "\" per_workspace\" " ,
158
+ /// Whether to pass `--no-default-features` to Cargo. Defaults to
159
+ /// `#rust-analyzer.cargo.noDefaultFeatures#`.
160
+ check_noDefaultFeatures | checkOnSave_noDefaultFeatures: Option <bool > = "null" ,
161
+ /// Override the command rust-analyzer uses instead of `cargo check` for
162
+ /// diagnostics on save. The command is required to output json and
163
+ /// should therefore include `--message-format=json` or a similar option.
164
+ ///
165
+ /// If you're changing this because you're using some tool wrapping
166
+ /// Cargo, you might also want to change
167
+ /// `#rust-analyzer.cargo.buildScripts.overrideCommand#`.
168
+ ///
169
+ /// If there are multiple linked projects, this command is invoked for
170
+ /// each of them, with the working directory being the project root
171
+ /// (i.e., the folder containing the `Cargo.toml`).
172
+ ///
173
+ /// An example command would be:
174
+ ///
175
+ /// ```bash
176
+ /// cargo check --workspace --message-format=json --all-targets
177
+ /// ```
178
+ /// .
179
+ check_overrideCommand | checkOnSave_overrideCommand: Option <Vec <String >> = "null" ,
180
+ /// Check for specific targets. Defaults to `#rust-analyzer.cargo.target#` if empty.
181
+ ///
182
+ /// Can be a single target, e.g. `"x86_64-unknown-linux-gnu"` or a list of targets, e.g.
183
+ /// `["aarch64-apple-darwin", "x86_64-apple-darwin"]`.
184
+ ///
185
+ /// Aliased as `"checkOnSave.targets"`.
186
+ check_targets | checkOnSave_targets | checkOnSave_target: Option <CheckOnSaveTargets > = "null" ,
187
+
130
188
/// Toggles the additional completions that automatically add imports when completed.
131
189
/// Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.
132
190
completion_autoimport_enable: bool = "true" ,
@@ -211,64 +269,6 @@ config_data! {
211
269
/// Controls file watching implementation.
212
270
files_watcher: FilesWatcherDef = "\" client\" " ,
213
271
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
-
272
272
/// Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords.
273
273
highlightRelated_breakPoints_enable: bool = "true" ,
274
274
/// Enables highlighting of all exit points while the cursor is on any `return`, `?`, `fn`, or return type arrow (`->`).
@@ -768,9 +768,9 @@ impl Config {
768
768
769
769
fn validate ( & self , error_sink : & mut Vec < ( String , serde_json:: Error ) > ) {
770
770
use serde:: de:: Error ;
771
- if self . data . flycheck_command . is_empty ( ) {
771
+ if self . data . check_command . is_empty ( ) {
772
772
error_sink. push ( (
773
- "/flycheck /command" . to_string ( ) ,
773
+ "/check /command" . to_string ( ) ,
774
774
serde_json:: Error :: custom ( "expected a non-empty string" ) ,
775
775
) ) ;
776
776
}
@@ -1015,7 +1015,7 @@ impl Config {
1015
1015
1016
1016
pub fn check_on_save_extra_env ( & self ) -> FxHashMap < String , String > {
1017
1017
let mut extra_env = self . data . cargo_extraEnv . clone ( ) ;
1018
- extra_env. extend ( self . data . flycheck_extraEnv . clone ( ) ) ;
1018
+ extra_env. extend ( self . data . check_extraEnv . clone ( ) ) ;
1019
1019
extra_env
1020
1020
}
1021
1021
@@ -1127,21 +1127,21 @@ impl Config {
1127
1127
}
1128
1128
1129
1129
pub fn flycheck ( & self ) -> FlycheckConfig {
1130
- match & self . data . flycheck_overrideCommand {
1130
+ match & self . data . check_overrideCommand {
1131
1131
Some ( args) if !args. is_empty ( ) => {
1132
1132
let mut args = args. clone ( ) ;
1133
1133
let command = args. remove ( 0 ) ;
1134
1134
FlycheckConfig :: CustomCommand {
1135
1135
command,
1136
1136
args,
1137
1137
extra_env : self . check_on_save_extra_env ( ) ,
1138
- invocation_strategy : match self . data . flycheck_invocationStrategy {
1138
+ invocation_strategy : match self . data . check_invocationStrategy {
1139
1139
InvocationStrategy :: Once => flycheck:: InvocationStrategy :: Once ,
1140
1140
InvocationStrategy :: PerWorkspace => {
1141
1141
flycheck:: InvocationStrategy :: PerWorkspace
1142
1142
}
1143
1143
} ,
1144
- invocation_location : match self . data . flycheck_invocationLocation {
1144
+ invocation_location : match self . data . check_invocationLocation {
1145
1145
InvocationLocation :: Root => {
1146
1146
flycheck:: InvocationLocation :: Root ( self . root_path . clone ( ) )
1147
1147
}
@@ -1150,35 +1150,35 @@ impl Config {
1150
1150
}
1151
1151
}
1152
1152
Some ( _) | None => FlycheckConfig :: CargoCommand {
1153
- command : self . data . flycheck_command . clone ( ) ,
1153
+ command : self . data . check_command . clone ( ) ,
1154
1154
target_triples : self
1155
1155
. data
1156
- . flycheck_targets
1156
+ . check_targets
1157
1157
. clone ( )
1158
1158
. and_then ( |targets| match & targets. 0 [ ..] {
1159
1159
[ ] => None ,
1160
1160
targets => Some ( targets. into ( ) ) ,
1161
1161
} )
1162
1162
. unwrap_or_else ( || self . data . cargo_target . clone ( ) . into_iter ( ) . collect ( ) ) ,
1163
- all_targets : self . data . flycheck_allTargets ,
1163
+ all_targets : self . data . check_allTargets ,
1164
1164
no_default_features : self
1165
1165
. data
1166
- . flycheck_noDefaultFeatures
1166
+ . check_noDefaultFeatures
1167
1167
. unwrap_or ( self . data . cargo_noDefaultFeatures ) ,
1168
1168
all_features : matches ! (
1169
- self . data. flycheck_features . as_ref( ) . unwrap_or( & self . data. cargo_features) ,
1169
+ self . data. check_features . as_ref( ) . unwrap_or( & self . data. cargo_features) ,
1170
1170
CargoFeaturesDef :: All
1171
1171
) ,
1172
1172
features : match self
1173
1173
. data
1174
- . flycheck_features
1174
+ . check_features
1175
1175
. clone ( )
1176
1176
. unwrap_or_else ( || self . data . cargo_features . clone ( ) )
1177
1177
{
1178
1178
CargoFeaturesDef :: All => vec ! [ ] ,
1179
1179
CargoFeaturesDef :: Selected ( it) => it,
1180
1180
} ,
1181
- extra_args : self . data . flycheck_extraArgs . clone ( ) ,
1181
+ extra_args : self . data . check_extraArgs . clone ( ) ,
1182
1182
extra_env : self . check_on_save_extra_env ( ) ,
1183
1183
} ,
1184
1184
}
@@ -1847,13 +1847,6 @@ fn get_field<T: DeserializeOwned>(
1847
1847
}
1848
1848
1849
1849
fn schema ( fields : & [ ( & ' static str , & ' static str , & [ & str ] , & str ) ] ) -> serde_json:: Value {
1850
- for ( ( f1, ..) , ( f2, ..) ) in fields. iter ( ) . zip ( & fields[ 1 ..] ) {
1851
- fn key ( f : & str ) -> & str {
1852
- f. splitn ( 2 , '_' ) . next ( ) . unwrap ( )
1853
- }
1854
- assert ! ( key( f1) <= key( f2) , "wrong field order: {:?} {:?}" , f1, f2) ;
1855
- }
1856
-
1857
1850
let map = fields
1858
1851
. iter ( )
1859
1852
. map ( |( field, ty, doc, default) | {
0 commit comments