From 18484365e69de06f20c234d57888a4b13ad9442b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Sat, 5 Jun 2021 14:03:56 +0300 Subject: Enable proc macros and build scripts by default in CLI --- crates/rust-analyzer/src/bin/flags.rs | 24 ++++++++++++------------ crates/rust-analyzer/src/bin/main.rs | 6 +++--- crates/rust-analyzer/src/cli/analysis_stats.rs | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/bin/flags.rs b/crates/rust-analyzer/src/bin/flags.rs index 63953098a..19173241b 100644 --- a/crates/rust-analyzer/src/bin/flags.rs +++ b/crates/rust-analyzer/src/bin/flags.rs @@ -67,10 +67,10 @@ xflags::xflags! { /// Don't load sysroot crates (`std`, `core` & friends). optional --no-sysroot - /// Load OUT_DIR values by running `cargo check` before analysis. - optional --load-output-dirs - /// Use proc-macro-srv for proc-macro expanding. - optional --with-proc-macro + /// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis. + optional --disable-build-scripts + /// Don't use expand proc macros. + optional --disable-proc-macros /// Only resolve names, don't run type inference. optional --skip-inference } @@ -79,10 +79,10 @@ xflags::xflags! { /// Directory with Cargo.toml. required path: PathBuf { - /// Load OUT_DIR values by running `cargo check` before analysis. - optional --load-output-dirs - /// Use proc-macro-srv for proc-macro expanding. - optional --with-proc-macro + /// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis. + optional --disable-build-scripts + /// Don't use expand proc macros. + optional --disable-proc-macros } cmd ssr @@ -158,8 +158,8 @@ pub struct AnalysisStats { pub only: Option, pub with_deps: bool, pub no_sysroot: bool, - pub load_output_dirs: bool, - pub with_proc_macro: bool, + pub disable_build_scripts: bool, + pub disable_proc_macros: bool, pub skip_inference: bool, } @@ -167,8 +167,8 @@ pub struct AnalysisStats { pub struct Diagnostics { pub path: PathBuf, - pub load_output_dirs: bool, - pub with_proc_macro: bool, + pub disable_build_scripts: bool, + pub disable_proc_macros: bool, } #[derive(Debug)] diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index 2b842d393..afc96505f 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs @@ -91,14 +91,14 @@ fn try_main() -> Result<()> { with_deps: cmd.with_deps, no_sysroot: cmd.no_sysroot, path: cmd.path, - load_output_dirs: cmd.load_output_dirs, - with_proc_macro: cmd.with_proc_macro, + enable_build_scripts: !cmd.disable_build_scripts, + enable_proc_macros: !cmd.disable_proc_macros, skip_inference: cmd.skip_inference, } .run(verbosity)?, flags::RustAnalyzerCmd::Diagnostics(cmd) => { - cli::diagnostics(&cmd.path, cmd.load_output_dirs, cmd.with_proc_macro)? + cli::diagnostics(&cmd.path, !cmd.disable_build_scripts, !cmd.disable_proc_macros)? } flags::RustAnalyzerCmd::Ssr(cmd) => cli::apply_ssr_rules(cmd.rule)?, flags::RustAnalyzerCmd::Search(cmd) => cli::search_for_patterns(cmd.pattern, cmd.debug)?, diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index 14dbbb20d..5364e907c 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -51,8 +51,8 @@ pub struct AnalysisStatsCmd { pub with_deps: bool, pub no_sysroot: bool, pub path: PathBuf, - pub load_output_dirs: bool, - pub with_proc_macro: bool, + pub enable_build_scripts: bool, + pub enable_proc_macros: bool, pub skip_inference: bool, } @@ -67,9 +67,9 @@ impl AnalysisStatsCmd { let mut cargo_config = CargoConfig::default(); cargo_config.no_sysroot = self.no_sysroot; let load_cargo_config = LoadCargoConfig { - load_out_dirs_from_check: self.load_output_dirs, + load_out_dirs_from_check: self.enable_build_scripts, wrap_rustc: false, - with_proc_macro: self.with_proc_macro, + with_proc_macro: self.enable_proc_macros, }; let (host, vfs, _proc_macro) = load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?; -- cgit v1.2.3