mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Merge #9147
9147: internal: enable proc macros and build scripts in cli r=flodiebold a=lnicola Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
commit
5092d8c1ae
4 changed files with 21 additions and 22 deletions
|
@ -67,10 +67,10 @@ xflags::xflags! {
|
||||||
/// Don't load sysroot crates (`std`, `core` & friends).
|
/// Don't load sysroot crates (`std`, `core` & friends).
|
||||||
optional --no-sysroot
|
optional --no-sysroot
|
||||||
|
|
||||||
/// Load OUT_DIR values by running `cargo check` before analysis.
|
/// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis.
|
||||||
optional --load-output-dirs
|
optional --disable-build-scripts
|
||||||
/// Use proc-macro-srv for proc-macro expanding.
|
/// Don't use expand proc macros.
|
||||||
optional --with-proc-macro
|
optional --disable-proc-macros
|
||||||
/// Only resolve names, don't run type inference.
|
/// Only resolve names, don't run type inference.
|
||||||
optional --skip-inference
|
optional --skip-inference
|
||||||
}
|
}
|
||||||
|
@ -79,10 +79,10 @@ xflags::xflags! {
|
||||||
/// Directory with Cargo.toml.
|
/// Directory with Cargo.toml.
|
||||||
required path: PathBuf
|
required path: PathBuf
|
||||||
{
|
{
|
||||||
/// Load OUT_DIR values by running `cargo check` before analysis.
|
/// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis.
|
||||||
optional --load-output-dirs
|
optional --disable-build-scripts
|
||||||
/// Use proc-macro-srv for proc-macro expanding.
|
/// Don't use expand proc macros.
|
||||||
optional --with-proc-macro
|
optional --disable-proc-macros
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd ssr
|
cmd ssr
|
||||||
|
@ -158,8 +158,8 @@ pub struct AnalysisStats {
|
||||||
pub only: Option<String>,
|
pub only: Option<String>,
|
||||||
pub with_deps: bool,
|
pub with_deps: bool,
|
||||||
pub no_sysroot: bool,
|
pub no_sysroot: bool,
|
||||||
pub load_output_dirs: bool,
|
pub disable_build_scripts: bool,
|
||||||
pub with_proc_macro: bool,
|
pub disable_proc_macros: bool,
|
||||||
pub skip_inference: bool,
|
pub skip_inference: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,8 +167,8 @@ pub struct AnalysisStats {
|
||||||
pub struct Diagnostics {
|
pub struct Diagnostics {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
|
|
||||||
pub load_output_dirs: bool,
|
pub disable_build_scripts: bool,
|
||||||
pub with_proc_macro: bool,
|
pub disable_proc_macros: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -91,14 +91,14 @@ fn try_main() -> Result<()> {
|
||||||
with_deps: cmd.with_deps,
|
with_deps: cmd.with_deps,
|
||||||
no_sysroot: cmd.no_sysroot,
|
no_sysroot: cmd.no_sysroot,
|
||||||
path: cmd.path,
|
path: cmd.path,
|
||||||
load_output_dirs: cmd.load_output_dirs,
|
enable_build_scripts: !cmd.disable_build_scripts,
|
||||||
with_proc_macro: cmd.with_proc_macro,
|
enable_proc_macros: !cmd.disable_proc_macros,
|
||||||
skip_inference: cmd.skip_inference,
|
skip_inference: cmd.skip_inference,
|
||||||
}
|
}
|
||||||
.run(verbosity)?,
|
.run(verbosity)?,
|
||||||
|
|
||||||
flags::RustAnalyzerCmd::Diagnostics(cmd) => {
|
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::Ssr(cmd) => cli::apply_ssr_rules(cmd.rule)?,
|
||||||
flags::RustAnalyzerCmd::Search(cmd) => cli::search_for_patterns(cmd.pattern, cmd.debug)?,
|
flags::RustAnalyzerCmd::Search(cmd) => cli::search_for_patterns(cmd.pattern, cmd.debug)?,
|
||||||
|
|
|
@ -51,8 +51,8 @@ pub struct AnalysisStatsCmd {
|
||||||
pub with_deps: bool,
|
pub with_deps: bool,
|
||||||
pub no_sysroot: bool,
|
pub no_sysroot: bool,
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub load_output_dirs: bool,
|
pub enable_build_scripts: bool,
|
||||||
pub with_proc_macro: bool,
|
pub enable_proc_macros: bool,
|
||||||
pub skip_inference: bool,
|
pub skip_inference: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +67,9 @@ impl AnalysisStatsCmd {
|
||||||
let mut cargo_config = CargoConfig::default();
|
let mut cargo_config = CargoConfig::default();
|
||||||
cargo_config.no_sysroot = self.no_sysroot;
|
cargo_config.no_sysroot = self.no_sysroot;
|
||||||
let load_cargo_config = LoadCargoConfig {
|
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,
|
wrap_rustc: false,
|
||||||
with_proc_macro: self.with_proc_macro,
|
with_proc_macro: self.enable_proc_macros,
|
||||||
};
|
};
|
||||||
let (host, vfs, _proc_macro) =
|
let (host, vfs, _proc_macro) =
|
||||||
load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
|
load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
|
|
|
@ -81,8 +81,7 @@ impl Metrics {
|
||||||
}
|
}
|
||||||
fn measure_analysis_stats_path(&mut self, name: &str, path: &str) -> Result<()> {
|
fn measure_analysis_stats_path(&mut self, name: &str, path: &str) -> Result<()> {
|
||||||
eprintln!("\nMeasuring analysis-stats/{}", name);
|
eprintln!("\nMeasuring analysis-stats/{}", name);
|
||||||
let output =
|
let output = cmd!("./target/release/rust-analyzer -q analysis-stats --memory-usage {path}")
|
||||||
cmd!("./target/release/rust-analyzer --quiet analysis-stats --memory-usage {path}")
|
|
||||||
.read()?;
|
.read()?;
|
||||||
for (metric, value, unit) in parse_metrics(&output) {
|
for (metric, value, unit) in parse_metrics(&output) {
|
||||||
self.report(&format!("analysis-stats/{}/{}", name, metric), value, unit.into());
|
self.report(&format!("analysis-stats/{}/{}", name, metric), value, unit.into());
|
||||||
|
|
Loading…
Reference in a new issue