Skip to content

Commit 15e7855

Browse files
committed
Replace Step::DEFAULT and default_condition with is_default_step
1 parent 1751dce commit 15e7855

File tree

15 files changed

+509
-308
lines changed

15 files changed

+509
-308
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ impl Std {
3737

3838
impl Step for Std {
3939
type Output = BuildStamp;
40-
const DEFAULT: bool = true;
4140

4241
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
4342
let mut run = run;
@@ -48,6 +47,10 @@ impl Step for Std {
4847
run.path("library")
4948
}
5049

50+
fn is_default_step(_builder: &Builder<'_>) -> bool {
51+
true
52+
}
53+
5154
fn make_run(run: RunConfig<'_>) {
5255
if !run.builder.download_rustc() && run.builder.config.skip_std_check_if_no_download_rustc {
5356
eprintln!(
@@ -310,12 +313,15 @@ impl Rustc {
310313
impl Step for Rustc {
311314
type Output = BuildStamp;
312315
const IS_HOST: bool = true;
313-
const DEFAULT: bool = true;
314316

315317
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
316318
run.crate_or_deps("rustc-main").path("compiler")
317319
}
318320

321+
fn is_default_step(_builder: &Builder<'_>) -> bool {
322+
true
323+
}
324+
319325
fn make_run(run: RunConfig<'_>) {
320326
let crates = run.make_run_crates(Alias::Compiler);
321327
run.builder.ensure(Rustc::new(run.builder, run.target, crates));
@@ -510,14 +516,16 @@ pub struct CraneliftCodegenBackend {
510516

511517
impl Step for CraneliftCodegenBackend {
512518
type Output = ();
513-
514519
const IS_HOST: bool = true;
515-
const DEFAULT: bool = true;
516520

517521
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
518522
run.alias("rustc_codegen_cranelift").alias("cg_clif")
519523
}
520524

525+
fn is_default_step(_builder: &Builder<'_>) -> bool {
526+
true
527+
}
528+
521529
fn make_run(run: RunConfig<'_>) {
522530
run.builder.ensure(CraneliftCodegenBackend {
523531
build_compiler: prepare_compiler_for_check(run.builder, run.target, Mode::Codegen),
@@ -580,14 +588,16 @@ pub struct GccCodegenBackend {
580588

581589
impl Step for GccCodegenBackend {
582590
type Output = ();
583-
584591
const IS_HOST: bool = true;
585-
const DEFAULT: bool = true;
586592

587593
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
588594
run.alias("rustc_codegen_gcc").alias("cg_gcc")
589595
}
590596

597+
fn is_default_step(_builder: &Builder<'_>) -> bool {
598+
true
599+
}
600+
591601
fn make_run(run: RunConfig<'_>) {
592602
run.builder.ensure(GccCodegenBackend {
593603
build_compiler: prepare_compiler_for_check(run.builder, run.target, Mode::Codegen),
@@ -665,13 +675,16 @@ macro_rules! tool_check_step {
665675
impl Step for $name {
666676
type Output = ();
667677
const IS_HOST: bool = true;
668-
/// Most of the tool-checks using this macro are run by default.
669-
const DEFAULT: bool = true $( && $default )?;
670678

671679
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
672680
run.paths(&[ $path, $( $alt_path ),* ])
673681
}
674682

683+
fn is_default_step(_builder: &Builder<'_>) -> bool {
684+
// Most of the tool-checks using this macro are run by default.
685+
true $( && const { $default } )?
686+
}
687+
675688
fn make_run(run: RunConfig<'_>) {
676689
let target = run.target;
677690
let mode: Mode = $mode;

src/bootstrap/src/core/build_steps/clean.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@ use crate::{Build, Compiler, Kind, Mode, Subcommand};
1818
pub struct CleanAll {}
1919

2020
impl Step for CleanAll {
21-
const DEFAULT: bool = true;
2221
type Output = ();
2322

23+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
24+
// Only runs as the default `./x clean` step; cannot be selected explicitly.
25+
run.never()
26+
}
27+
28+
fn is_default_step(_builder: &Builder<'_>) -> bool {
29+
true
30+
}
31+
2432
fn make_run(run: RunConfig<'_>) {
2533
run.builder.ensure(CleanAll {})
2634
}
@@ -36,10 +44,6 @@ impl Step for CleanAll {
3644

3745
clean(builder.build, all, stage)
3846
}
39-
40-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
41-
run.never() // handled by DEFAULT
42-
}
4347
}
4448

4549
macro_rules! clean_crate_tree {

src/bootstrap/src/core/build_steps/clippy.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,15 @@ impl Std {
170170

171171
impl Step for Std {
172172
type Output = ();
173-
const DEFAULT: bool = true;
174173

175174
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
176175
run.crate_or_deps("sysroot").path("library")
177176
}
178177

178+
fn is_default_step(_builder: &Builder<'_>) -> bool {
179+
true
180+
}
181+
179182
fn make_run(run: RunConfig<'_>) {
180183
let crates = std_crates_for_run_make(&run);
181184
let config = LintConfig::new(run.builder);
@@ -253,12 +256,15 @@ impl Rustc {
253256
impl Step for Rustc {
254257
type Output = ();
255258
const IS_HOST: bool = true;
256-
const DEFAULT: bool = true;
257259

258260
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
259261
run.crate_or_deps("rustc-main").path("compiler")
260262
}
261263

264+
fn is_default_step(_builder: &Builder<'_>) -> bool {
265+
true
266+
}
267+
262268
fn make_run(run: RunConfig<'_>) {
263269
let builder = run.builder;
264270
let crates = run.make_run_crates(Alias::Compiler);
@@ -398,7 +404,7 @@ macro_rules! lint_any {
398404
$path:expr,
399405
$readable_name:expr,
400406
$mode:expr
401-
$(,lint_by_default = $lint_by_default:expr)*
407+
$(, lint_by_default = $lint_by_default:expr )?
402408
;
403409
)+) => {
404410
$(
@@ -412,12 +418,15 @@ macro_rules! lint_any {
412418

413419
impl Step for $name {
414420
type Output = ();
415-
const DEFAULT: bool = if false $(|| $lint_by_default)* { true } else { false };
416421

417422
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
418423
run.path($path)
419424
}
420425

426+
fn is_default_step(_builder: &Builder<'_>) -> bool {
427+
false $( || const { $lint_by_default } )?
428+
}
429+
421430
fn make_run(run: RunConfig<'_>) {
422431
let config = LintConfig::new(run.builder);
423432
run.builder.ensure($name {
@@ -510,12 +519,15 @@ pub struct CI {
510519

511520
impl Step for CI {
512521
type Output = ();
513-
const DEFAULT: bool = false;
514522

515523
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
516524
run.alias("ci")
517525
}
518526

527+
fn is_default_step(_builder: &Builder<'_>) -> bool {
528+
false
529+
}
530+
519531
fn make_run(run: RunConfig<'_>) {
520532
let config = LintConfig::new(run.builder);
521533
run.builder.ensure(CI { target: run.target, config });

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,14 @@ impl Step for Std {
113113
/// Build stamp of std, if it was indeed built or uplifted.
114114
type Output = Option<BuildStamp>;
115115

116-
const DEFAULT: bool = true;
117-
118116
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
119117
run.crate_or_deps("sysroot").path("library")
120118
}
121119

120+
fn is_default_step(_builder: &Builder<'_>) -> bool {
121+
true
122+
}
123+
122124
fn make_run(run: RunConfig<'_>) {
123125
let crates = std_crates_for_run_make(&run);
124126
let builder = run.builder;
@@ -1011,9 +1013,7 @@ impl Rustc {
10111013

10121014
impl Step for Rustc {
10131015
type Output = BuiltRustc;
1014-
10151016
const IS_HOST: bool = true;
1016-
const DEFAULT: bool = false;
10171017

10181018
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
10191019
let mut crates = run.builder.in_tree_crates("rustc-main", None);
@@ -1028,6 +1028,10 @@ impl Step for Rustc {
10281028
run.crates(crates)
10291029
}
10301030

1031+
fn is_default_step(_builder: &Builder<'_>) -> bool {
1032+
false
1033+
}
1034+
10311035
fn make_run(run: RunConfig<'_>) {
10321036
// If only `compiler` was passed, do not run this step.
10331037
// Instead the `Assemble` step will take care of compiling Rustc.

0 commit comments

Comments
 (0)