Do not allow building anything on stage 0

This commit is contained in:
Jakub Beránek 2025-06-16 17:12:42 +02:00
parent 9e08d8769d
commit ac8920fa4c
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
2 changed files with 7 additions and 2 deletions

View file

@ -1,7 +1,6 @@
# These defaults are meant for contributors to the standard library and documentation.
[build]
bench-stage = 1
build-stage = 1
check-stage = 1
test-stage = 1

View file

@ -1023,7 +1023,7 @@ impl Config {
|| install_stage.is_some()
|| check_stage.is_some()
|| bench_stage.is_some();
// See https://github.com/rust-lang/compiler-team/issues/326
config.stage = match config.cmd {
Subcommand::Check { .. } => flags_stage.or(check_stage).unwrap_or(0),
Subcommand::Clippy { .. } | Subcommand::Fix => flags_stage.or(check_stage).unwrap_or(1),
@ -1051,6 +1051,12 @@ impl Config {
| Subcommand::Vendor { .. } => flags_stage.unwrap_or(0),
};
// Now check that the selected stage makes sense, and if not, print a warning and end
if let (0, Subcommand::Build) = (config.stage, &config.cmd) {
eprintln!("WARNING: cannot build anything on stage 0. Use at least stage 1.");
exit!(1);
}
// CI should always run stage 2 builds, unless it specifically states otherwise
#[cfg(not(test))]
if flags_stage.is_none() && config.is_running_on_ci {