Skip to content

Commit ce08a72

Browse files
Panic if rustdoc is built more than once
This prevents silent regressions where rustdoc is accidentally compiled in more than one stage. We should always be building it just once (likely in the final stage).
1 parent e4c66af commit ce08a72

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/bootstrap/tool.rs

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::env;
33
use std::path::PathBuf;
44
use std::process::{Command, exit};
55
use std::collections::HashSet;
6+
use std::sync::Mutex;
67

78
use crate::Mode;
89
use crate::Compiler;
@@ -436,6 +437,7 @@ pub struct Rustdoc {
436437
pub compiler: Compiler,
437438
}
438439

440+
439441
impl Step for Rustdoc {
440442
type Output = PathBuf;
441443
const DEFAULT: bool = true;
@@ -452,6 +454,21 @@ impl Step for Rustdoc {
452454
}
453455

454456
fn run(self, builder: &Builder<'_>) -> PathBuf {
457+
lazy_static! {
458+
static ref BUILT_RUSTDOC_IN: Mutex<Vec<u32>> = Mutex::new(Vec::new());
459+
}
460+
{
461+
let mut built = BUILT_RUSTDOC_IN.lock().unwrap();
462+
if !built.contains(&self.compiler.stage) {
463+
built.push(self.compiler.stage);
464+
assert_eq!(
465+
built.len(),
466+
1,
467+
"Only ever build one copy of rustdoc per run, currently built in stages {:?}",
468+
built,
469+
);
470+
}
471+
}
455472
let target_compiler = self.compiler;
456473
if target_compiler.stage == 0 {
457474
if !target_compiler.is_snapshot(builder) {

0 commit comments

Comments
 (0)