aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenČ›iu Nicola <[email protected]>2021-06-05 12:03:56 +0100
committerLaurenČ›iu Nicola <[email protected]>2021-06-05 13:20:41 +0100
commit18484365e69de06f20c234d57888a4b13ad9442b (patch)
tree0beb1c4546c30ae9278d3b35e755d098453b2dfd
parentfec00f4e1309ce4a7635b06e255359211999e5b5 (diff)
Enable proc macros and build scripts by default in CLI
-rw-r--r--crates/rust-analyzer/src/bin/flags.rs24
-rw-r--r--crates/rust-analyzer/src/bin/main.rs6
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs8
-rw-r--r--xtask/src/metrics.rs5
4 files changed, 21 insertions, 22 deletions
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! {
67 /// Don't load sysroot crates (`std`, `core` & friends). 67 /// Don't load sysroot crates (`std`, `core` & friends).
68 optional --no-sysroot 68 optional --no-sysroot
69 69
70 /// Load OUT_DIR values by running `cargo check` before analysis. 70 /// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis.
71 optional --load-output-dirs 71 optional --disable-build-scripts
72 /// Use proc-macro-srv for proc-macro expanding. 72 /// Don't use expand proc macros.
73 optional --with-proc-macro 73 optional --disable-proc-macros
74 /// Only resolve names, don't run type inference. 74 /// Only resolve names, don't run type inference.
75 optional --skip-inference 75 optional --skip-inference
76 } 76 }
@@ -79,10 +79,10 @@ xflags::xflags! {
79 /// Directory with Cargo.toml. 79 /// Directory with Cargo.toml.
80 required path: PathBuf 80 required path: PathBuf
81 { 81 {
82 /// Load OUT_DIR values by running `cargo check` before analysis. 82 /// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis.
83 optional --load-output-dirs 83 optional --disable-build-scripts
84 /// Use proc-macro-srv for proc-macro expanding. 84 /// Don't use expand proc macros.
85 optional --with-proc-macro 85 optional --disable-proc-macros
86 } 86 }
87 87
88 cmd ssr 88 cmd ssr
@@ -158,8 +158,8 @@ pub struct AnalysisStats {
158 pub only: Option<String>, 158 pub only: Option<String>,
159 pub with_deps: bool, 159 pub with_deps: bool,
160 pub no_sysroot: bool, 160 pub no_sysroot: bool,
161 pub load_output_dirs: bool, 161 pub disable_build_scripts: bool,
162 pub with_proc_macro: bool, 162 pub disable_proc_macros: bool,
163 pub skip_inference: bool, 163 pub skip_inference: bool,
164} 164}
165 165
@@ -167,8 +167,8 @@ pub struct AnalysisStats {
167pub struct Diagnostics { 167pub struct Diagnostics {
168 pub path: PathBuf, 168 pub path: PathBuf,
169 169
170 pub load_output_dirs: bool, 170 pub disable_build_scripts: bool,
171 pub with_proc_macro: bool, 171 pub disable_proc_macros: bool,
172} 172}
173 173
174#[derive(Debug)] 174#[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<()> {
91 with_deps: cmd.with_deps, 91 with_deps: cmd.with_deps,
92 no_sysroot: cmd.no_sysroot, 92 no_sysroot: cmd.no_sysroot,
93 path: cmd.path, 93 path: cmd.path,
94 load_output_dirs: cmd.load_output_dirs, 94 enable_build_scripts: !cmd.disable_build_scripts,
95 with_proc_macro: cmd.with_proc_macro, 95 enable_proc_macros: !cmd.disable_proc_macros,
96 skip_inference: cmd.skip_inference, 96 skip_inference: cmd.skip_inference,
97 } 97 }
98 .run(verbosity)?, 98 .run(verbosity)?,
99 99
100 flags::RustAnalyzerCmd::Diagnostics(cmd) => { 100 flags::RustAnalyzerCmd::Diagnostics(cmd) => {
101 cli::diagnostics(&cmd.path, cmd.load_output_dirs, cmd.with_proc_macro)? 101 cli::diagnostics(&cmd.path, !cmd.disable_build_scripts, !cmd.disable_proc_macros)?
102 } 102 }
103 flags::RustAnalyzerCmd::Ssr(cmd) => cli::apply_ssr_rules(cmd.rule)?, 103 flags::RustAnalyzerCmd::Ssr(cmd) => cli::apply_ssr_rules(cmd.rule)?,
104 flags::RustAnalyzerCmd::Search(cmd) => cli::search_for_patterns(cmd.pattern, cmd.debug)?, 104 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 {
51 pub with_deps: bool, 51 pub with_deps: bool,
52 pub no_sysroot: bool, 52 pub no_sysroot: bool,
53 pub path: PathBuf, 53 pub path: PathBuf,
54 pub load_output_dirs: bool, 54 pub enable_build_scripts: bool,
55 pub with_proc_macro: bool, 55 pub enable_proc_macros: bool,
56 pub skip_inference: bool, 56 pub skip_inference: bool,
57} 57}
58 58
@@ -67,9 +67,9 @@ impl AnalysisStatsCmd {
67 let mut cargo_config = CargoConfig::default(); 67 let mut cargo_config = CargoConfig::default();
68 cargo_config.no_sysroot = self.no_sysroot; 68 cargo_config.no_sysroot = self.no_sysroot;
69 let load_cargo_config = LoadCargoConfig { 69 let load_cargo_config = LoadCargoConfig {
70 load_out_dirs_from_check: self.load_output_dirs, 70 load_out_dirs_from_check: self.enable_build_scripts,
71 wrap_rustc: false, 71 wrap_rustc: false,
72 with_proc_macro: self.with_proc_macro, 72 with_proc_macro: self.enable_proc_macros,
73 }; 73 };
74 let (host, vfs, _proc_macro) = 74 let (host, vfs, _proc_macro) =
75 load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?; 75 load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
diff --git a/xtask/src/metrics.rs b/xtask/src/metrics.rs
index b0b76b8aa..34679062f 100644
--- a/xtask/src/metrics.rs
+++ b/xtask/src/metrics.rs
@@ -81,9 +81,8 @@ impl Metrics {
81 } 81 }
82 fn measure_analysis_stats_path(&mut self, name: &str, path: &str) -> Result<()> { 82 fn measure_analysis_stats_path(&mut self, name: &str, path: &str) -> Result<()> {
83 eprintln!("\nMeasuring analysis-stats/{}", name); 83 eprintln!("\nMeasuring analysis-stats/{}", name);
84 let output = 84 let output = cmd!("./target/release/rust-analyzer -q analysis-stats --memory-usage {path}")
85 cmd!("./target/release/rust-analyzer --quiet analysis-stats --memory-usage {path}") 85 .read()?;
86 .read()?;
87 for (metric, value, unit) in parse_metrics(&output) { 86 for (metric, value, unit) in parse_metrics(&output) {
88 self.report(&format!("analysis-stats/{}/{}", name, metric), value, unit.into()); 87 self.report(&format!("analysis-stats/{}/{}", name, metric), value, unit.into());
89 } 88 }