@@ -77,72 +77,6 @@ config_data! {
77
77
cachePriming_numThreads: NumThreads = NumThreads :: Physical ,
78
78
79
79
80
- /// Check all targets and tests (`--all-targets`). Defaults to
81
- /// `#rust-analyzer.cargo.allTargets#`.
82
- check_allTargets | checkOnSave_allTargets: Option <bool > = None ,
83
- /// Cargo command to use for `cargo check`.
84
- check_command | checkOnSave_command: String = "check" . to_owned( ) ,
85
- /// Extra arguments for `cargo check`.
86
- check_extraArgs | checkOnSave_extraArgs: Vec <String > = vec![ ] ,
87
- /// Extra environment variables that will be set when running `cargo check`.
88
- /// Extends `#rust-analyzer.cargo.extraEnv#`.
89
- check_extraEnv | checkOnSave_extraEnv: FxHashMap <String , String > = FxHashMap :: default ( ) ,
90
- /// List of features to activate. Defaults to
91
- /// `#rust-analyzer.cargo.features#`.
92
- ///
93
- /// Set to `"all"` to pass `--all-features` to Cargo.
94
- check_features | checkOnSave_features: Option <CargoFeaturesDef > = None ,
95
- /// List of `cargo check` (or other command specified in `check.command`) diagnostics to ignore.
96
- ///
97
- /// For example for `cargo check`: `dead_code`, `unused_imports`, `unused_variables`,...
98
- check_ignore: FxHashSet <String > = FxHashSet :: default ( ) ,
99
- /// Specifies the invocation strategy to use when running the check command.
100
- /// If `per_workspace` is set, the command will be executed for each workspace.
101
- /// If `once` is set, the command will be executed once.
102
- /// This config only has an effect when `#rust-analyzer.check.overrideCommand#`
103
- /// is set.
104
- check_invocationStrategy | checkOnSave_invocationStrategy: InvocationStrategy = InvocationStrategy :: PerWorkspace ,
105
- /// Whether to pass `--no-default-features` to Cargo. Defaults to
106
- /// `#rust-analyzer.cargo.noDefaultFeatures#`.
107
- check_noDefaultFeatures | checkOnSave_noDefaultFeatures: Option <bool > = None ,
108
- /// Override the command rust-analyzer uses instead of `cargo check` for
109
- /// diagnostics on save. The command is required to output json and
110
- /// should therefore include `--message-format=json` or a similar option
111
- /// (if your client supports the `colorDiagnosticOutput` experimental
112
- /// capability, you can use `--message-format=json-diagnostic-rendered-ansi`).
113
- ///
114
- /// If you're changing this because you're using some tool wrapping
115
- /// Cargo, you might also want to change
116
- /// `#rust-analyzer.cargo.buildScripts.overrideCommand#`.
117
- ///
118
- /// If there are multiple linked projects/workspaces, this command is invoked for
119
- /// each of them, with the working directory being the workspace root
120
- /// (i.e., the folder containing the `Cargo.toml`). This can be overwritten
121
- /// by changing `#rust-analyzer.check.invocationStrategy#`.
122
- ///
123
- /// If `$saved_file` is part of the command, rust-analyzer will pass
124
- /// the absolute path of the saved file to the provided command. This is
125
- /// intended to be used with non-Cargo build systems.
126
- /// Note that `$saved_file` is experimental and may be removed in the future.
127
- ///
128
- /// An example command would be:
129
- ///
130
- /// ```bash
131
- /// cargo check --workspace --message-format=json --all-targets
132
- /// ```
133
- /// .
134
- check_overrideCommand | checkOnSave_overrideCommand: Option <Vec <String >> = None ,
135
- /// Check for specific targets. Defaults to `#rust-analyzer.cargo.target#` if empty.
136
- ///
137
- /// Can be a single target, e.g. `"x86_64-unknown-linux-gnu"` or a list of targets, e.g.
138
- /// `["aarch64-apple-darwin", "x86_64-apple-darwin"]`.
139
- ///
140
- /// Aliased as `"checkOnSave.targets"`.
141
- check_targets | checkOnSave_targets | checkOnSave_target: Option <CheckOnSaveTargets > = None ,
142
- /// Whether `--workspace` should be passed to `cargo check`.
143
- /// If false, `-p <package>` will be passed instead.
144
- check_workspace: bool = true ,
145
-
146
80
/// List of rust-analyzer diagnostics to disable.
147
81
diagnostics_disabled: FxHashSet <String > = FxHashSet :: default ( ) ,
148
82
/// Whether to show native rust-analyzer diagnostics.
@@ -432,6 +366,73 @@ config_data! {
432
366
/// Run the check command for diagnostics on save.
433
367
checkOnSave | checkOnSave_enable: bool = true ,
434
368
369
+
370
+ /// Check all targets and tests (`--all-targets`). Defaults to
371
+ /// `#rust-analyzer.cargo.allTargets#`.
372
+ check_allTargets | checkOnSave_allTargets: Option <bool > = None ,
373
+ /// Cargo command to use for `cargo check`.
374
+ check_command | checkOnSave_command: String = "check" . to_owned( ) ,
375
+ /// Extra arguments for `cargo check`.
376
+ check_extraArgs | checkOnSave_extraArgs: Vec <String > = vec![ ] ,
377
+ /// Extra environment variables that will be set when running `cargo check`.
378
+ /// Extends `#rust-analyzer.cargo.extraEnv#`.
379
+ check_extraEnv | checkOnSave_extraEnv: FxHashMap <String , String > = FxHashMap :: default ( ) ,
380
+ /// List of features to activate. Defaults to
381
+ /// `#rust-analyzer.cargo.features#`.
382
+ ///
383
+ /// Set to `"all"` to pass `--all-features` to Cargo.
384
+ check_features | checkOnSave_features: Option <CargoFeaturesDef > = None ,
385
+ /// List of `cargo check` (or other command specified in `check.command`) diagnostics to ignore.
386
+ ///
387
+ /// For example for `cargo check`: `dead_code`, `unused_imports`, `unused_variables`,...
388
+ check_ignore: FxHashSet <String > = FxHashSet :: default ( ) ,
389
+ /// Specifies the invocation strategy to use when running the check command.
390
+ /// If `per_workspace` is set, the command will be executed for each workspace.
391
+ /// If `once` is set, the command will be executed once.
392
+ /// This config only has an effect when `#rust-analyzer.check.overrideCommand#`
393
+ /// is set.
394
+ check_invocationStrategy | checkOnSave_invocationStrategy: InvocationStrategy = InvocationStrategy :: PerWorkspace ,
395
+ /// Whether to pass `--no-default-features` to Cargo. Defaults to
396
+ /// `#rust-analyzer.cargo.noDefaultFeatures#`.
397
+ check_noDefaultFeatures | checkOnSave_noDefaultFeatures: Option <bool > = None ,
398
+ /// Override the command rust-analyzer uses instead of `cargo check` for
399
+ /// diagnostics on save. The command is required to output json and
400
+ /// should therefore include `--message-format=json` or a similar option
401
+ /// (if your client supports the `colorDiagnosticOutput` experimental
402
+ /// capability, you can use `--message-format=json-diagnostic-rendered-ansi`).
403
+ ///
404
+ /// If you're changing this because you're using some tool wrapping
405
+ /// Cargo, you might also want to change
406
+ /// `#rust-analyzer.cargo.buildScripts.overrideCommand#`.
407
+ ///
408
+ /// If there are multiple linked projects/workspaces, this command is invoked for
409
+ /// each of them, with the working directory being the workspace root
410
+ /// (i.e., the folder containing the `Cargo.toml`). This can be overwritten
411
+ /// by changing `#rust-analyzer.check.invocationStrategy#`.
412
+ ///
413
+ /// If `$saved_file` is part of the command, rust-analyzer will pass
414
+ /// the absolute path of the saved file to the provided command. This is
415
+ /// intended to be used with non-Cargo build systems.
416
+ /// Note that `$saved_file` is experimental and may be removed in the future.
417
+ ///
418
+ /// An example command would be:
419
+ ///
420
+ /// ```bash
421
+ /// cargo check --workspace --message-format=json --all-targets
422
+ /// ```
423
+ /// .
424
+ check_overrideCommand | checkOnSave_overrideCommand: Option <Vec <String >> = None ,
425
+ /// Check for specific targets. Defaults to `#rust-analyzer.cargo.target#` if empty.
426
+ ///
427
+ /// Can be a single target, e.g. `"x86_64-unknown-linux-gnu"` or a list of targets, e.g.
428
+ /// `["aarch64-apple-darwin", "x86_64-apple-darwin"]`.
429
+ ///
430
+ /// Aliased as `"checkOnSave.targets"`.
431
+ check_targets | checkOnSave_targets | checkOnSave_target: Option <CheckOnSaveTargets > = None ,
432
+ /// Whether `--workspace` should be passed to `cargo check`.
433
+ /// If false, `-p <package>` will be passed instead.
434
+ check_workspace: bool = true ,
435
+
435
436
/// Additional arguments to `rustfmt`.
436
437
rustfmt_extraArgs: Vec <String > = vec![ ] ,
437
438
/// Advanced option, fully override the command rust-analyzer uses for
@@ -1018,7 +1019,7 @@ impl Config {
1018
1019
config. source_root_parent_map = source_root_map;
1019
1020
}
1020
1021
1021
- if config. check_command ( ) . is_empty ( ) {
1022
+ if config. check_command ( None ) . is_empty ( ) {
1022
1023
config. validation_errors . 0 . push ( Arc :: new ( ConfigErrorInner :: Json {
1023
1024
config_key : "/check/command" . to_owned ( ) ,
1024
1025
error : serde_json:: Error :: custom ( "expected a non-empty string" ) ,
@@ -1721,12 +1722,12 @@ impl Config {
1721
1722
self . diagnostics_enable ( ) . to_owned ( )
1722
1723
}
1723
1724
1724
- pub fn diagnostics_map ( & self ) -> DiagnosticsMapConfig {
1725
+ pub fn diagnostics_map ( & self , source_root : Option < SourceRootId > ) -> DiagnosticsMapConfig {
1725
1726
DiagnosticsMapConfig {
1726
1727
remap_prefix : self . diagnostics_remapPrefix ( ) . clone ( ) ,
1727
1728
warnings_as_info : self . diagnostics_warningsAsInfo ( ) . clone ( ) ,
1728
1729
warnings_as_hint : self . diagnostics_warningsAsHint ( ) . clone ( ) ,
1729
- check_ignore : self . check_ignore ( ) . clone ( ) ,
1730
+ check_ignore : self . check_ignore ( source_root ) . clone ( ) ,
1730
1731
}
1731
1732
}
1732
1733
@@ -1740,13 +1741,13 @@ impl Config {
1740
1741
1741
1742
pub fn check_extra_args ( & self , source_root : Option < SourceRootId > ) -> Vec < String > {
1742
1743
let mut extra_args = self . extra_args ( source_root) . clone ( ) ;
1743
- extra_args. extend_from_slice ( self . check_extraArgs ( ) ) ;
1744
+ extra_args. extend_from_slice ( self . check_extraArgs ( source_root ) ) ;
1744
1745
extra_args
1745
1746
}
1746
1747
1747
1748
pub fn check_extra_env ( & self , source_root : Option < SourceRootId > ) -> FxHashMap < String , String > {
1748
1749
let mut extra_env = self . cargo_extraEnv ( source_root) . clone ( ) ;
1749
- extra_env. extend ( self . check_extraEnv ( ) . clone ( ) ) ;
1750
+ extra_env. extend ( self . check_extraEnv ( source_root ) . clone ( ) ) ;
1750
1751
extra_env
1751
1752
}
1752
1753
@@ -1871,8 +1872,8 @@ impl Config {
1871
1872
}
1872
1873
}
1873
1874
1874
- pub fn flycheck_workspace ( & self ) -> bool {
1875
- * self . check_workspace ( )
1875
+ pub fn flycheck_workspace ( & self , source_root : Option < SourceRootId > ) -> bool {
1876
+ * self . check_workspace ( source_root )
1876
1877
}
1877
1878
1878
1879
pub ( crate ) fn cargo_test_options ( & self , source_root : Option < SourceRootId > ) -> CargoOptions {
@@ -1893,15 +1894,15 @@ impl Config {
1893
1894
}
1894
1895
1895
1896
pub ( crate ) fn flycheck ( & self , source_root : Option < SourceRootId > ) -> FlycheckConfig {
1896
- match & self . check_overrideCommand ( ) {
1897
+ match & self . check_overrideCommand ( source_root ) {
1897
1898
Some ( args) if !args. is_empty ( ) => {
1898
1899
let mut args = args. clone ( ) ;
1899
1900
let command = args. remove ( 0 ) ;
1900
1901
FlycheckConfig :: CustomCommand {
1901
1902
command,
1902
1903
args,
1903
1904
extra_env : self . check_extra_env ( source_root) ,
1904
- invocation_strategy : match self . check_invocationStrategy ( ) {
1905
+ invocation_strategy : match self . check_invocationStrategy ( source_root ) {
1905
1906
InvocationStrategy :: Once => crate :: flycheck:: InvocationStrategy :: Once ,
1906
1907
InvocationStrategy :: PerWorkspace => {
1907
1908
crate :: flycheck:: InvocationStrategy :: PerWorkspace
@@ -1910,10 +1911,10 @@ impl Config {
1910
1911
}
1911
1912
}
1912
1913
Some ( _) | None => FlycheckConfig :: CargoCommand {
1913
- command : self . check_command ( ) . clone ( ) ,
1914
+ command : self . check_command ( source_root ) . clone ( ) ,
1914
1915
options : CargoOptions {
1915
1916
target_triples : self
1916
- . check_targets ( )
1917
+ . check_targets ( source_root )
1917
1918
. clone ( )
1918
1919
. and_then ( |targets| match & targets. 0 [ ..] {
1919
1920
[ ] => None ,
@@ -1923,17 +1924,19 @@ impl Config {
1923
1924
self . cargo_target ( source_root) . clone ( ) . into_iter ( ) . collect ( )
1924
1925
} ) ,
1925
1926
all_targets : self
1926
- . check_allTargets ( )
1927
+ . check_allTargets ( source_root )
1927
1928
. unwrap_or ( * self . cargo_allTargets ( source_root) ) ,
1928
1929
no_default_features : self
1929
- . check_noDefaultFeatures ( )
1930
+ . check_noDefaultFeatures ( source_root )
1930
1931
. unwrap_or ( * self . cargo_noDefaultFeatures ( source_root) ) ,
1931
1932
all_features : matches ! (
1932
- self . check_features( ) . as_ref( ) . unwrap_or( self . cargo_features( source_root) ) ,
1933
+ self . check_features( source_root)
1934
+ . as_ref( )
1935
+ . unwrap_or( self . cargo_features( source_root) ) ,
1933
1936
CargoFeaturesDef :: All
1934
1937
) ,
1935
1938
features : match self
1936
- . check_features ( )
1939
+ . check_features ( source_root )
1937
1940
. clone ( )
1938
1941
. unwrap_or_else ( || self . cargo_features ( source_root) . clone ( ) )
1939
1942
{
0 commit comments