Skip to content

Commit b661310

Browse files
committed
apply some nits and add coverage for downgraded_from
Signed-off-by: onur-ozkan <[email protected]>
1 parent fecb681 commit b661310

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ macro_rules! lint_any {
283283
}
284284

285285
fn run(self, builder: &Builder<'_>) -> Self::Output {
286-
let compiler = builder.compiler(builder.top_stage, builder.config.build, $mode == Mode::ToolRustc);
286+
let compiler = builder.compiler(builder.top_stage, builder.config.build, builder.top_stage > 0 && $mode == Mode::ToolRustc);
287287
let target = self.target;
288288

289289
builder.ensure(check::Rustc::new(target, builder).build_kind(Some(Kind::Check)));

src/bootstrap/src/core/build_steps/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ macro_rules! tool_doc {
951951
// Rustdoc needs the rustc sysroot available to build.
952952
// FIXME: is there a way to only ensure `check::Rustc` here? Last time I tried it failed
953953
// with strange errors, but only on a full bors test ...
954-
let _ = builder.compiler(compiler.stage, target, false);
954+
let _ = builder.compiler(compiler.stage, target, true);
955955
}
956956

957957
// Build cargo command.

src/bootstrap/src/core/build_steps/tool.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub fn prepare_tool_cargo(
180180
extra_features: &[String],
181181
) -> CargoCommand {
182182
// FIXME: remove stage check
183-
if mode == Mode::ToolRustc && !compiler.is_downgraded_already() && compiler.stage != 0 {
183+
if builder.top_stage > 0 && mode == Mode::ToolRustc && !compiler.is_downgraded_already() {
184184
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
185185
// we'd have stageN/bin/rustc and stageN/bin/$tool_name be effectively different stage
186186
// compilers, which isn't what we want.
@@ -630,8 +630,8 @@ impl Step for Rustdoc {
630630
let compiler = self.compiler;
631631
let target = compiler.host;
632632

633-
if compiler.stage == 0 {
634-
if !compiler.is_snapshot(builder) && !compiler.is_downgraded_already() {
633+
if compiler.stage == 0 && !compiler.is_downgraded_already() {
634+
if !compiler.is_snapshot(builder) {
635635
panic!("rustdoc in stage 0 must be snapshot rustdoc");
636636
}
637637
return builder.initial_rustdoc.clone();

src/bootstrap/src/core/builder/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1244,8 +1244,6 @@ impl<'a> Builder<'a> {
12441244

12451245
// FIXME: remove stage check
12461246
if stage > 0 && downgrade_for_rustc_tool {
1247-
assert!(stage > 0, "can't downgrade stage 0 compiler");
1248-
12491247
self.ensure(compile::Std::new(compiler, host));
12501248
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
12511249
// we'd have stageN/bin/rustc and stageN/bin/$tool_name be effectively different stage
@@ -1415,8 +1413,12 @@ impl<'a> Builder<'a> {
14151413
}
14161414

14171415
pub fn rustdoc(&self, mut compiler: Compiler) -> PathBuf {
1418-
// FIXME: remove stage check
1419-
if compiler.stage > 0 && !compiler.is_downgraded_already() {
1416+
if compiler.is_snapshot(self) && !compiler.is_downgraded_already() {
1417+
return self.initial_rustc.with_file_name(exe("rustdoc", compiler.host));
1418+
}
1419+
1420+
if !compiler.is_downgraded_already() {
1421+
assert!(compiler.stage > 0, "Can't use stage0 compiler for rustdoc");
14201422
compiler.downgrade();
14211423
}
14221424

src/bootstrap/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ impl std::hash::Hash for Compiler {
106106

107107
impl PartialEq for Compiler {
108108
fn eq(&self, other: &Self) -> bool {
109-
// FIXME: cover `downgraded_from` for test env
110109
self.stage == other.stage && self.host == other.host
110+
// We have coverage for `downgraded_from` in our unit tests
111+
&& (!cfg!(test) || self.downgraded_from == other.downgraded_from)
111112
}
112113
}
113114

0 commit comments

Comments
 (0)