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:
bors[bot] 2021-06-05 12:29:52 +00:00 committed by GitHub
commit 5092d8c1ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 22 deletions

View file

@ -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<String>,
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)]

View file

@ -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)?,

View file

@ -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, &|_| {})?;

View file

@ -81,8 +81,7 @@ impl Metrics {
}
fn measure_analysis_stats_path(&mut self, name: &str, path: &str) -> Result<()> {
eprintln!("\nMeasuring analysis-stats/{}", name);
let output =
cmd!("./target/release/rust-analyzer --quiet analysis-stats --memory-usage {path}")
let output = cmd!("./target/release/rust-analyzer -q analysis-stats --memory-usage {path}")
.read()?;
for (metric, value, unit) in parse_metrics(&output) {
self.report(&format!("analysis-stats/{}/{}", name, metric), value, unit.into());