Skip to content

Commit d843de5

Browse files
authored
Rollup merge of rust-lang#88011 - jyn514:check-all-targets, r=Mark-Simulacrum
Enable `--all-targets` for `x.py check` unconditionally Now that Cargo deduplicates diagnostics from different targets, this doesn't flood the console with duplicate errors. Note that this doesn't add `--all-targets` in `Builder::cargo` directly because `impl Step for Std` actually wants to omit `--all-targets` the first time while it's still building libtest. When passed `--all-targets`, this warns that the option isn't needed, but still continues to compile. Fixes rust-lang#87846. r? `@Mark-Simulacrum`
2 parents 21102b1 + c6f4eed commit d843de5

File tree

3 files changed

+36
-42
lines changed

3 files changed

+36
-42
lines changed

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ impl<'a> Builder<'a> {
578578
pub fn new(build: &Build) -> Builder<'_> {
579579
let (kind, paths) = match build.config.cmd {
580580
Subcommand::Build { ref paths } => (Kind::Build, &paths[..]),
581-
Subcommand::Check { ref paths, all_targets: _ } => (Kind::Check, &paths[..]),
581+
Subcommand::Check { ref paths } => (Kind::Check, &paths[..]),
582582
Subcommand::Clippy { ref paths, .. } => (Kind::Clippy, &paths[..]),
583583
Subcommand::Fix { ref paths } => (Kind::Fix, &paths[..]),
584584
Subcommand::Doc { ref paths, .. } => (Kind::Doc, &paths[..]),

src/bootstrap/check.rs

+29-37
Original file line numberDiff line numberDiff line change
@@ -113,38 +113,35 @@ impl Step for Std {
113113
// since we initialize with an empty sysroot.
114114
//
115115
// Currently only the "libtest" tree of crates does this.
116+
let mut cargo = builder.cargo(
117+
compiler,
118+
Mode::Std,
119+
SourceType::InTree,
120+
target,
121+
cargo_subcommand(builder.kind),
122+
);
123+
cargo.arg("--all-targets");
124+
std_cargo(builder, target, compiler.stage, &mut cargo);
116125

117-
if let Subcommand::Check { all_targets: true, .. } = builder.config.cmd {
118-
let mut cargo = builder.cargo(
119-
compiler,
120-
Mode::Std,
121-
SourceType::InTree,
122-
target,
123-
cargo_subcommand(builder.kind),
124-
);
125-
std_cargo(builder, target, compiler.stage, &mut cargo);
126-
cargo.arg("--all-targets");
127-
128-
// Explicitly pass -p for all dependencies krates -- this will force cargo
129-
// to also check the tests/benches/examples for these crates, rather
130-
// than just the leaf crate.
131-
for krate in builder.in_tree_crates("test", Some(target)) {
132-
cargo.arg("-p").arg(krate.name);
133-
}
134-
135-
builder.info(&format!(
136-
"Checking stage{} std test/bench/example targets ({} -> {})",
137-
builder.top_stage, &compiler.host, target
138-
));
139-
run_cargo(
140-
builder,
141-
cargo,
142-
args(builder),
143-
&libstd_test_stamp(builder, compiler, target),
144-
vec![],
145-
true,
146-
);
126+
// Explicitly pass -p for all dependencies krates -- this will force cargo
127+
// to also check the tests/benches/examples for these crates, rather
128+
// than just the leaf crate.
129+
for krate in builder.in_tree_crates("test", Some(target)) {
130+
cargo.arg("-p").arg(krate.name);
147131
}
132+
133+
builder.info(&format!(
134+
"Checking stage{} std test/bench/example targets ({} -> {})",
135+
builder.top_stage, &compiler.host, target
136+
));
137+
run_cargo(
138+
builder,
139+
cargo,
140+
args(builder),
141+
&libstd_test_stamp(builder, compiler, target),
142+
vec![],
143+
true,
144+
);
148145
}
149146
}
150147

@@ -195,9 +192,7 @@ impl Step for Rustc {
195192
cargo_subcommand(builder.kind),
196193
);
197194
rustc_cargo(builder, &mut cargo, target);
198-
if let Subcommand::Check { all_targets: true, .. } = builder.config.cmd {
199-
cargo.arg("--all-targets");
200-
}
195+
cargo.arg("--all-targets");
201196

202197
// Explicitly pass -p for all compiler krates -- this will force cargo
203198
// to also check the tests/benches/examples for these crates, rather
@@ -318,10 +313,7 @@ macro_rules! tool_check_step {
318313
$source_type,
319314
&[],
320315
);
321-
322-
if let Subcommand::Check { all_targets: true, .. } = builder.config.cmd {
323-
cargo.arg("--all-targets");
324-
}
316+
cargo.arg("--all-targets");
325317

326318
// Enable internal lints for clippy and rustdoc
327319
// NOTE: this doesn't enable lints for any other tools unless they explicitly add `#![warn(rustc::internal)]`

src/bootstrap/flags.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ pub enum Subcommand {
7878
paths: Vec<PathBuf>,
7979
},
8080
Check {
81-
// Whether to run checking over all targets (e.g., unit / integration
82-
// tests).
83-
all_targets: bool,
8481
paths: Vec<PathBuf>,
8582
},
8683
Clippy {
@@ -553,7 +550,12 @@ Arguments:
553550
let cmd = match subcommand.as_str() {
554551
"build" | "b" => Subcommand::Build { paths },
555552
"check" | "c" => {
556-
Subcommand::Check { paths, all_targets: matches.opt_present("all-targets") }
553+
if matches.opt_present("all-targets") {
554+
eprintln!(
555+
"Warning: --all-targets is now on by default and does not need to be passed explicitly."
556+
);
557+
}
558+
Subcommand::Check { paths }
557559
}
558560
"clippy" => Subcommand::Clippy { paths, fix: matches.opt_present("fix") },
559561
"fix" => Subcommand::Fix { paths },

0 commit comments

Comments
 (0)