@@ -124,39 +124,40 @@ config_data! {
124124 /// Unsets `#[cfg(test)]` for the specified crates.
125125 cargo_unsetTest: Vec <String > = "[\" core\" ]" ,
126126
127+ /// Run the check command for diagnostics on save.
128+ checkOnSave | checkOnSave_enable: bool = "true" ,
129+
127130 /// Check all targets and tests (`--all-targets`).
128- checkOnSave_allTargets: bool = "true" ,
131+ check_allTargets | checkOnSave_allTargets: bool = "true" ,
129132 /// 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+ check_command | checkOnSave_command: String = "\" check\" " ,
133134 /// Extra arguments for `cargo check`.
134- checkOnSave_extraArgs: Vec <String > = "[]" ,
135+ check_extraArgs | checkOnSave_extraArgs: Vec <String > = "[]" ,
135136 /// Extra environment variables that will be set when running `cargo check`.
136137 /// Extends `#rust-analyzer.cargo.extraEnv#`.
137- checkOnSave_extraEnv: FxHashMap <String , String > = "{}" ,
138+ check_extraEnv | checkOnSave_extraEnv: FxHashMap <String , String > = "{}" ,
138139 /// List of features to activate. Defaults to
139140 /// `#rust-analyzer.cargo.features#`.
140141 ///
141142 /// Set to `"all"` to pass `--all-features` to Cargo.
142- checkOnSave_features: Option <CargoFeaturesDef > = "null" ,
143+ check_features | checkOnSave_features: Option <CargoFeaturesDef > = "null" ,
143144 /// Specifies the working directory for running checks.
144145 /// - "workspace": run checks for workspaces in the corresponding workspaces' root directories.
145146 // FIXME: Ideally we would support this in some way
146147 /// This falls back to "root" if `#rust-analyzer.cargo.checkOnSave.invocationStrategy#` is set to `once`.
147148 /// - "root": run checks in the project's root directory.
148149 /// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
149150 /// is set.
150- checkOnSave_invocationLocation: InvocationLocation = "\" workspace\" " ,
151+ check_invocationLocation | checkOnSave_invocationLocation: InvocationLocation = "\" workspace\" " ,
151152 /// Specifies the invocation strategy to use when running the checkOnSave command.
152153 /// If `per_workspace` is set, the command will be executed for each workspace.
153154 /// If `once` is set, the command will be executed once.
154155 /// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
155156 /// is set.
156- checkOnSave_invocationStrategy: InvocationStrategy = "\" per_workspace\" " ,
157+ check_invocationStrategy | checkOnSave_invocationStrategy: InvocationStrategy = "\" per_workspace\" " ,
157158 /// Whether to pass `--no-default-features` to Cargo. Defaults to
158159 /// `#rust-analyzer.cargo.noDefaultFeatures#`.
159- checkOnSave_noDefaultFeatures: Option <bool > = "null" ,
160+ check_noDefaultFeatures | checkOnSave_noDefaultFeatures: Option <bool > = "null" ,
160161 /// Override the command rust-analyzer uses instead of `cargo check` for
161162 /// diagnostics on save. The command is required to output json and
162163 /// should therefore include `--message-format=json` or a similar option.
@@ -175,14 +176,14 @@ config_data! {
175176 /// cargo check --workspace --message-format=json --all-targets
176177 /// ```
177178 /// .
178- checkOnSave_overrideCommand: Option <Vec <String >> = "null" ,
179+ check_overrideCommand | checkOnSave_overrideCommand: Option <Vec <String >> = "null" ,
179180 /// Check for specific targets. Defaults to `#rust-analyzer.cargo.target#` if empty.
180181 ///
181182 /// Can be a single target, e.g. `"x86_64-unknown-linux-gnu"` or a list of targets, e.g.
182183 /// `["aarch64-apple-darwin", "x86_64-apple-darwin"]`.
183184 ///
184185 /// Aliased as `"checkOnSave.targets"`.
185- checkOnSave_target | checkOnSave_targets: Option <CheckOnSaveTargets > = "null" ,
186+ check_targets | checkOnSave_targets | checkOnSave_target : Option <CheckOnSaveTargets > = "null" ,
186187
187188 /// Toggles the additional completions that automatically add imports when completed.
188189 /// Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.
@@ -791,9 +792,9 @@ impl Config {
791792
792793 fn validate ( & self , error_sink : & mut Vec < ( String , serde_json:: Error ) > ) {
793794 use serde:: de:: Error ;
794- if self . data . checkOnSave_command . is_empty ( ) {
795+ if self . data . check_command . is_empty ( ) {
795796 error_sink. push ( (
796- "/checkOnSave /command" . to_string ( ) ,
797+ "/check /command" . to_string ( ) ,
797798 serde_json:: Error :: custom ( "expected a non-empty string" ) ,
798799 ) ) ;
799800 }
@@ -1038,7 +1039,7 @@ impl Config {
10381039
10391040 pub fn check_on_save_extra_env ( & self ) -> FxHashMap < String , String > {
10401041 let mut extra_env = self . data . cargo_extraEnv . clone ( ) ;
1041- extra_env. extend ( self . data . checkOnSave_extraEnv . clone ( ) ) ;
1042+ extra_env. extend ( self . data . check_extraEnv . clone ( ) ) ;
10421043 extra_env
10431044 }
10441045
@@ -1150,21 +1151,21 @@ impl Config {
11501151 }
11511152
11521153 pub fn flycheck ( & self ) -> FlycheckConfig {
1153- match & self . data . checkOnSave_overrideCommand {
1154+ match & self . data . check_overrideCommand {
11541155 Some ( args) if !args. is_empty ( ) => {
11551156 let mut args = args. clone ( ) ;
11561157 let command = args. remove ( 0 ) ;
11571158 FlycheckConfig :: CustomCommand {
11581159 command,
11591160 args,
11601161 extra_env : self . check_on_save_extra_env ( ) ,
1161- invocation_strategy : match self . data . checkOnSave_invocationStrategy {
1162+ invocation_strategy : match self . data . check_invocationStrategy {
11621163 InvocationStrategy :: Once => flycheck:: InvocationStrategy :: Once ,
11631164 InvocationStrategy :: PerWorkspace => {
11641165 flycheck:: InvocationStrategy :: PerWorkspace
11651166 }
11661167 } ,
1167- invocation_location : match self . data . checkOnSave_invocationLocation {
1168+ invocation_location : match self . data . check_invocationLocation {
11681169 InvocationLocation :: Root => {
11691170 flycheck:: InvocationLocation :: Root ( self . root_path . clone ( ) )
11701171 }
@@ -1173,42 +1174,42 @@ impl Config {
11731174 }
11741175 }
11751176 Some ( _) | None => FlycheckConfig :: CargoCommand {
1176- command : self . data . checkOnSave_command . clone ( ) ,
1177+ command : self . data . check_command . clone ( ) ,
11771178 target_triples : self
11781179 . data
1179- . checkOnSave_target
1180+ . check_targets
11801181 . clone ( )
11811182 . and_then ( |targets| match & targets. 0 [ ..] {
11821183 [ ] => None ,
11831184 targets => Some ( targets. into ( ) ) ,
11841185 } )
11851186 . unwrap_or_else ( || self . data . cargo_target . clone ( ) . into_iter ( ) . collect ( ) ) ,
1186- all_targets : self . data . checkOnSave_allTargets ,
1187+ all_targets : self . data . check_allTargets ,
11871188 no_default_features : self
11881189 . data
1189- . checkOnSave_noDefaultFeatures
1190+ . check_noDefaultFeatures
11901191 . unwrap_or ( self . data . cargo_noDefaultFeatures ) ,
11911192 all_features : matches ! (
1192- self . data. checkOnSave_features . as_ref( ) . unwrap_or( & self . data. cargo_features) ,
1193+ self . data. check_features . as_ref( ) . unwrap_or( & self . data. cargo_features) ,
11931194 CargoFeaturesDef :: All
11941195 ) ,
11951196 features : match self
11961197 . data
1197- . checkOnSave_features
1198+ . check_features
11981199 . clone ( )
11991200 . unwrap_or_else ( || self . data . cargo_features . clone ( ) )
12001201 {
12011202 CargoFeaturesDef :: All => vec ! [ ] ,
12021203 CargoFeaturesDef :: Selected ( it) => it,
12031204 } ,
1204- extra_args : self . data . checkOnSave_extraArgs . clone ( ) ,
1205+ extra_args : self . data . check_extraArgs . clone ( ) ,
12051206 extra_env : self . check_on_save_extra_env ( ) ,
12061207 } ,
12071208 }
12081209 }
12091210
12101211 pub fn check_on_save ( & self ) -> bool {
1211- self . data . checkOnSave_enable
1212+ self . data . checkOnSave
12121213 }
12131214
12141215 pub fn runnables ( & self ) -> RunnablesConfig {
@@ -1886,35 +1887,30 @@ fn get_field<T: DeserializeOwned>(
18861887 alias : Option < & ' static str > ,
18871888 default : & str ,
18881889) -> T {
1889- let default = serde_json:: from_str ( default) . unwrap ( ) ;
18901890 // XXX: check alias first, to work-around the VS Code where it pre-fills the
18911891 // defaults instead of sending an empty object.
18921892 alias
18931893 . into_iter ( )
18941894 . chain ( iter:: once ( field) )
1895- . find_map ( move |field| {
1895+ . filter_map ( move |field| {
18961896 let mut pointer = field. replace ( '_' , "/" ) ;
18971897 pointer. insert ( 0 , '/' ) ;
1898- json. pointer_mut ( & pointer) . and_then ( |it| match serde_json:: from_value ( it. take ( ) ) {
1899- Ok ( it) => Some ( it) ,
1900- Err ( e) => {
1901- tracing:: warn!( "Failed to deserialize config field at {}: {:?}" , pointer, e) ;
1902- error_sink. push ( ( pointer, e) ) ;
1903- None
1904- }
1905- } )
1898+ json. pointer_mut ( & pointer)
1899+ . map ( |it| serde_json:: from_value ( it. take ( ) ) . map_err ( |e| ( e, pointer) ) )
1900+ } )
1901+ . find ( Result :: is_ok)
1902+ . and_then ( |res| match res {
1903+ Ok ( it) => Some ( it) ,
1904+ Err ( ( e, pointer) ) => {
1905+ tracing:: warn!( "Failed to deserialize config field at {}: {:?}" , pointer, e) ;
1906+ error_sink. push ( ( pointer, e) ) ;
1907+ None
1908+ }
19061909 } )
1907- . unwrap_or ( default)
1910+ . unwrap_or_else ( || serde_json :: from_str ( default) . unwrap ( ) )
19081911}
19091912
19101913fn schema ( fields : & [ ( & ' static str , & ' static str , & [ & str ] , & str ) ] ) -> serde_json:: Value {
1911- for ( ( f1, ..) , ( f2, ..) ) in fields. iter ( ) . zip ( & fields[ 1 ..] ) {
1912- fn key ( f : & str ) -> & str {
1913- f. splitn ( 2 , '_' ) . next ( ) . unwrap ( )
1914- }
1915- assert ! ( key( f1) <= key( f2) , "wrong field order: {f1:?} {f2:?}" ) ;
1916- }
1917-
19181914 let map = fields
19191915 . iter ( )
19201916 . map ( |( field, ty, doc, default) | {
@@ -1988,15 +1984,6 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
19881984 "type" : [ "null" , "array" ] ,
19891985 "items" : { "type" : "string" } ,
19901986 } ,
1991- "MergeBehaviorDef" => set ! {
1992- "type" : "string" ,
1993- "enum" : [ "none" , "crate" , "module" ] ,
1994- "enumDescriptions" : [
1995- "Do not merge imports at all." ,
1996- "Merge imports from the same crate into a single `use` statement." ,
1997- "Merge imports from the same module into a single `use` statement."
1998- ] ,
1999- } ,
20001987 "ExprFillDefaultDef" => set ! {
20011988 "type" : "string" ,
20021989 "enum" : [ "todo" , "default" ] ,
0 commit comments