@@ -152,6 +152,13 @@ config_data! {
152
152
// FIXME(@poliorcetics): move to multiple targets here too, but this will need more work
153
153
// than `checkOnSave_target`
154
154
cargo_target: Option <String > = "null" ,
155
+ /// Optional path to a rust-analyzer specific target directory.
156
+ /// This prevents rust-analyzer's `cargo check` and initial build-script and proc-macro
157
+ /// building from locking the `Cargo.lock` at the expense of duplicating build artifacts.
158
+ ///
159
+ /// Set to `true` to use a subdirectory of the existing target directory or
160
+ /// set to a path relative to the workspace to use that path.
161
+ cargo_targetDir | rust_analyzerTargetDir: Option <TargetDirectory > = "null" ,
155
162
/// Unsets the implicit `#[cfg(test)]` for the specified crates.
156
163
cargo_unsetTest: Vec <String > = "[\" core\" ]" ,
157
164
@@ -518,14 +525,6 @@ config_data! {
518
525
/// tests or binaries. For example, it may be `--release`.
519
526
runnables_extraArgs: Vec <String > = "[]" ,
520
527
521
- /// Optional path to a rust-analyzer specific target directory.
522
- /// This prevents rust-analyzer's `cargo check` from locking the `Cargo.lock`
523
- /// at the expense of duplicating build artifacts.
524
- ///
525
- /// Set to `true` to use a subdirectory of the existing target directory or
526
- /// set to a path relative to the workspace to use that path.
527
- rust_analyzerTargetDir: Option <TargetDirectory > = "null" ,
528
-
529
528
/// Path to the Cargo.toml of the rust compiler workspace, for usage in rustc_private
530
529
/// projects, or "discover" to try to automatically find it if the `rustc-dev` component
531
530
/// is installed.
@@ -1401,14 +1400,12 @@ impl Config {
1401
1400
}
1402
1401
}
1403
1402
1404
- // FIXME: This should be an AbsolutePathBuf
1405
1403
fn target_dir_from_config ( & self ) -> Option < PathBuf > {
1406
- self . data . rust_analyzerTargetDir . as_ref ( ) . and_then ( |target_dir| match target_dir {
1407
- TargetDirectory :: UseSubdirectory ( yes) if * yes => {
1408
- Some ( PathBuf :: from ( "target/rust-analyzer" ) )
1409
- }
1410
- TargetDirectory :: UseSubdirectory ( _) => None ,
1411
- TargetDirectory :: Directory ( dir) => Some ( dir. clone ( ) ) ,
1404
+ self . data . cargo_targetDir . as_ref ( ) . and_then ( |target_dir| match target_dir {
1405
+ TargetDirectory :: UseSubdirectory ( true ) => Some ( PathBuf :: from ( "target/rust-analyzer" ) ) ,
1406
+ TargetDirectory :: UseSubdirectory ( false ) => None ,
1407
+ TargetDirectory :: Directory ( dir) if dir. is_relative ( ) => Some ( dir. clone ( ) ) ,
1408
+ TargetDirectory :: Directory ( _) => None ,
1412
1409
} )
1413
1410
}
1414
1411
@@ -2745,7 +2742,7 @@ mod tests {
2745
2742
"rust" : { "analyzerTargetDir" : null }
2746
2743
} ) )
2747
2744
. unwrap ( ) ;
2748
- assert_eq ! ( config. data. rust_analyzerTargetDir , None ) ;
2745
+ assert_eq ! ( config. data. cargo_targetDir , None ) ;
2749
2746
assert ! (
2750
2747
matches!( config. flycheck( ) , FlycheckConfig :: CargoCommand { target_dir, .. } if target_dir. is_none( ) )
2751
2748
) ;
@@ -2764,10 +2761,7 @@ mod tests {
2764
2761
"rust" : { "analyzerTargetDir" : true }
2765
2762
} ) )
2766
2763
. unwrap ( ) ;
2767
- assert_eq ! (
2768
- config. data. rust_analyzerTargetDir,
2769
- Some ( TargetDirectory :: UseSubdirectory ( true ) )
2770
- ) ;
2764
+ assert_eq ! ( config. data. cargo_targetDir, Some ( TargetDirectory :: UseSubdirectory ( true ) ) ) ;
2771
2765
assert ! (
2772
2766
matches!( config. flycheck( ) , FlycheckConfig :: CargoCommand { target_dir, .. } if target_dir == Some ( PathBuf :: from( "target/rust-analyzer" ) ) )
2773
2767
) ;
@@ -2787,7 +2781,7 @@ mod tests {
2787
2781
} ) )
2788
2782
. unwrap ( ) ;
2789
2783
assert_eq ! (
2790
- config. data. rust_analyzerTargetDir ,
2784
+ config. data. cargo_targetDir ,
2791
2785
Some ( TargetDirectory :: Directory ( PathBuf :: from( "other_folder" ) ) )
2792
2786
) ;
2793
2787
assert ! (
0 commit comments