Skip to content

Commit 5092d8c

Browse files
bors[bot]lnicola
andauthored
Merge #9147
9147: internal: enable proc macros and build scripts in cli r=flodiebold a=lnicola Co-authored-by: Laurențiu Nicola <[email protected]>
2 parents 4c54ec1 + 1848436 commit 5092d8c

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

crates/rust-analyzer/src/bin/flags.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ xflags::xflags! {
6767
/// Don't load sysroot crates (`std`, `core` & friends).
6868
optional --no-sysroot
6969

70-
/// Load OUT_DIR values by running `cargo check` before analysis.
71-
optional --load-output-dirs
72-
/// Use proc-macro-srv for proc-macro expanding.
73-
optional --with-proc-macro
70+
/// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis.
71+
optional --disable-build-scripts
72+
/// Don't use expand proc macros.
73+
optional --disable-proc-macros
7474
/// Only resolve names, don't run type inference.
7575
optional --skip-inference
7676
}
@@ -79,10 +79,10 @@ xflags::xflags! {
7979
/// Directory with Cargo.toml.
8080
required path: PathBuf
8181
{
82-
/// Load OUT_DIR values by running `cargo check` before analysis.
83-
optional --load-output-dirs
84-
/// Use proc-macro-srv for proc-macro expanding.
85-
optional --with-proc-macro
82+
/// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis.
83+
optional --disable-build-scripts
84+
/// Don't use expand proc macros.
85+
optional --disable-proc-macros
8686
}
8787

8888
cmd ssr
@@ -158,17 +158,17 @@ pub struct AnalysisStats {
158158
pub only: Option<String>,
159159
pub with_deps: bool,
160160
pub no_sysroot: bool,
161-
pub load_output_dirs: bool,
162-
pub with_proc_macro: bool,
161+
pub disable_build_scripts: bool,
162+
pub disable_proc_macros: bool,
163163
pub skip_inference: bool,
164164
}
165165

166166
#[derive(Debug)]
167167
pub struct Diagnostics {
168168
pub path: PathBuf,
169169

170-
pub load_output_dirs: bool,
171-
pub with_proc_macro: bool,
170+
pub disable_build_scripts: bool,
171+
pub disable_proc_macros: bool,
172172
}
173173

174174
#[derive(Debug)]

crates/rust-analyzer/src/bin/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ fn try_main() -> Result<()> {
9191
with_deps: cmd.with_deps,
9292
no_sysroot: cmd.no_sysroot,
9393
path: cmd.path,
94-
load_output_dirs: cmd.load_output_dirs,
95-
with_proc_macro: cmd.with_proc_macro,
94+
enable_build_scripts: !cmd.disable_build_scripts,
95+
enable_proc_macros: !cmd.disable_proc_macros,
9696
skip_inference: cmd.skip_inference,
9797
}
9898
.run(verbosity)?,
9999

100100
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)?
102102
}
103103
flags::RustAnalyzerCmd::Ssr(cmd) => cli::apply_ssr_rules(cmd.rule)?,
104104
flags::RustAnalyzerCmd::Search(cmd) => cli::search_for_patterns(cmd.pattern, cmd.debug)?,

crates/rust-analyzer/src/cli/analysis_stats.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ pub struct AnalysisStatsCmd {
5151
pub with_deps: bool,
5252
pub no_sysroot: bool,
5353
pub path: PathBuf,
54-
pub load_output_dirs: bool,
55-
pub with_proc_macro: bool,
54+
pub enable_build_scripts: bool,
55+
pub enable_proc_macros: bool,
5656
pub skip_inference: bool,
5757
}
5858

@@ -67,9 +67,9 @@ impl AnalysisStatsCmd {
6767
let mut cargo_config = CargoConfig::default();
6868
cargo_config.no_sysroot = self.no_sysroot;
6969
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,
7171
wrap_rustc: false,
72-
with_proc_macro: self.with_proc_macro,
72+
with_proc_macro: self.enable_proc_macros,
7373
};
7474
let (host, vfs, _proc_macro) =
7575
load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;

xtask/src/metrics.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ impl Metrics {
8181
}
8282
fn measure_analysis_stats_path(&mut self, name: &str, path: &str) -> Result<()> {
8383
eprintln!("\nMeasuring analysis-stats/{}", name);
84-
let output =
85-
cmd!("./target/release/rust-analyzer --quiet analysis-stats --memory-usage {path}")
86-
.read()?;
84+
let output = cmd!("./target/release/rust-analyzer -q analysis-stats --memory-usage {path}")
85+
.read()?;
8786
for (metric, value, unit) in parse_metrics(&output) {
8887
self.report(&format!("analysis-stats/{}/{}", name, metric), value, unit.into());
8988
}

0 commit comments

Comments
 (0)