diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6d3e488bb0..5cf4a8fd43 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -104,11 +104,11 @@ jobs: if: matrix.os == 'ubuntu-latest' run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats . - - name: Run analysis-stats on rust std library + - name: Run analysis-stats on the rust standard libraries if: matrix.os == 'ubuntu-latest' env: - RUSTC_BOOTSTRAP: 1 - run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std + RUSTC_BOOTSTRAP: 1 + run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps --no-sysroot --no-test $(rustc --print sysroot)/lib/rustlib/src/rust/library/ - name: clippy if: matrix.os == 'windows-latest' diff --git a/crates/project-model/src/tests.rs b/crates/project-model/src/tests.rs index 5099697a69..ef115494a8 100644 --- a/crates/project-model/src/tests.rs +++ b/crates/project-model/src/tests.rs @@ -222,8 +222,6 @@ fn rust_project_is_proc_macro_has_proc_macro_dep() { } #[test] -// FIXME Remove the ignore -#[ignore = "requires nightly until the sysroot ships a cargo workspace for library on stable"] fn smoke_test_real_sysroot_cargo() { let file_map = &mut FxHashMap::::default(); let meta: Metadata = get_test_json_file("hello-world-metadata.json"); @@ -235,7 +233,6 @@ fn smoke_test_real_sysroot_cargo() { &Default::default(), ); assert!(matches!(sysroot.mode(), SysrootMode::Workspace(_))); - let project_workspace = ProjectWorkspace { kind: ProjectWorkspaceKind::Cargo { cargo: cargo_workspace, diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index c216461427..51c81a0d1a 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -6,6 +6,7 @@ use std::{ time::{SystemTime, UNIX_EPOCH}, }; +use cfg::{CfgAtom, CfgDiff}; use hir::{ db::{DefDatabase, ExpandDatabase, HirDatabase}, Adt, AssocItem, Crate, DefWithBody, HasSource, HirDisplay, HirFileIdExt, ImportPathConfig, @@ -31,7 +32,7 @@ use itertools::Itertools; use load_cargo::{load_workspace, LoadCargoConfig, ProcMacroServerChoice}; use oorandom::Rand32; use profile::{Bytes, StopWatch}; -use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustLibSource}; +use project_model::{CargoConfig, CfgOverrides, ProjectManifest, ProjectWorkspace, RustLibSource}; use rayon::prelude::*; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::{AstNode, SyntaxNode}; @@ -65,7 +66,11 @@ impl flags::AnalysisStats { false => Some(RustLibSource::Discover), }, all_targets: true, - set_test: true, + set_test: !self.no_test, + cfg_overrides: CfgOverrides { + global: CfgDiff::new(vec![CfgAtom::Flag(hir::sym::miri.clone())], vec![]).unwrap(), + selective: Default::default(), + }, ..Default::default() }; let no_progress = &|_| (); diff --git a/crates/rust-analyzer/src/cli/flags.rs b/crates/rust-analyzer/src/cli/flags.rs index 60d621b214..ff24602144 100644 --- a/crates/rust-analyzer/src/cli/flags.rs +++ b/crates/rust-analyzer/src/cli/flags.rs @@ -71,6 +71,8 @@ xflags::xflags! { optional --with-deps /// Don't load sysroot crates (`std`, `core` & friends). optional --no-sysroot + /// Don't set #[cfg(test)]. + optional --no-test /// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis. optional --disable-build-scripts @@ -233,6 +235,7 @@ pub struct AnalysisStats { pub only: Option, pub with_deps: bool, pub no_sysroot: bool, + pub no_test: bool, pub disable_build_scripts: bool, pub disable_proc_macros: bool, pub proc_macro_srv: Option,