Skip to content

Commit 6703d7a

Browse files
committed
Auto merge of #18328 - Veykril:veykril/push-zrzmmyqzqwyr, r=Veykril
fix: Fix CI running analysis-stats incorrectly against the standard libraries Fixes #18326
2 parents 8dd53a3 + e5af3ae commit 6703d7a

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ jobs:
104104
if: matrix.os == 'ubuntu-latest'
105105
run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats .
106106

107-
- name: Run analysis-stats on rust std library
107+
- name: Run analysis-stats on the rust standard libraries
108108
if: matrix.os == 'ubuntu-latest'
109109
env:
110-
RUSTC_BOOTSTRAP: 1
111-
run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std
110+
RUSTC_BOOTSTRAP: 1
111+
run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps --no-sysroot --no-test $(rustc --print sysroot)/lib/rustlib/src/rust/library/
112112

113113
- name: clippy
114114
if: matrix.os == 'windows-latest'

crates/project-model/src/tests.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ fn rust_project_is_proc_macro_has_proc_macro_dep() {
222222
}
223223

224224
#[test]
225-
// FIXME Remove the ignore
226-
#[ignore = "requires nightly until the sysroot ships a cargo workspace for library on stable"]
227225
fn smoke_test_real_sysroot_cargo() {
228226
let file_map = &mut FxHashMap::<AbsPathBuf, FileId>::default();
229227
let meta: Metadata = get_test_json_file("hello-world-metadata.json");
@@ -235,7 +233,6 @@ fn smoke_test_real_sysroot_cargo() {
235233
&Default::default(),
236234
);
237235
assert!(matches!(sysroot.mode(), SysrootMode::Workspace(_)));
238-
239236
let project_workspace = ProjectWorkspace {
240237
kind: ProjectWorkspaceKind::Cargo {
241238
cargo: cargo_workspace,

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::{
66
time::{SystemTime, UNIX_EPOCH},
77
};
88

9+
use cfg::{CfgAtom, CfgDiff};
910
use hir::{
1011
db::{DefDatabase, ExpandDatabase, HirDatabase},
1112
Adt, AssocItem, Crate, DefWithBody, HasSource, HirDisplay, HirFileIdExt, ImportPathConfig,
@@ -31,7 +32,7 @@ use itertools::Itertools;
3132
use load_cargo::{load_workspace, LoadCargoConfig, ProcMacroServerChoice};
3233
use oorandom::Rand32;
3334
use profile::{Bytes, StopWatch};
34-
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustLibSource};
35+
use project_model::{CargoConfig, CfgOverrides, ProjectManifest, ProjectWorkspace, RustLibSource};
3536
use rayon::prelude::*;
3637
use rustc_hash::{FxHashMap, FxHashSet};
3738
use syntax::{AstNode, SyntaxNode};
@@ -65,7 +66,11 @@ impl flags::AnalysisStats {
6566
false => Some(RustLibSource::Discover),
6667
},
6768
all_targets: true,
68-
set_test: true,
69+
set_test: !self.no_test,
70+
cfg_overrides: CfgOverrides {
71+
global: CfgDiff::new(vec![CfgAtom::Flag(hir::sym::miri.clone())], vec![]).unwrap(),
72+
selective: Default::default(),
73+
},
6974
..Default::default()
7075
};
7176
let no_progress = &|_| ();

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ xflags::xflags! {
7171
optional --with-deps
7272
/// Don't load sysroot crates (`std`, `core` & friends).
7373
optional --no-sysroot
74+
/// Don't set #[cfg(test)].
75+
optional --no-test
7476

7577
/// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis.
7678
optional --disable-build-scripts
@@ -233,6 +235,7 @@ pub struct AnalysisStats {
233235
pub only: Option<String>,
234236
pub with_deps: bool,
235237
pub no_sysroot: bool,
238+
pub no_test: bool,
236239
pub disable_build_scripts: bool,
237240
pub disable_proc_macros: bool,
238241
pub proc_macro_srv: Option<PathBuf>,

0 commit comments

Comments
 (0)