diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 876fd2906449..80b83c959c64 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -37,7 +37,7 @@ use crate::utils::helpers::{self, exe, output, t}; /// /// WARNING: Be cautious when adding paths to this list. If a path that influences the compiler build /// is added here, it will cause bootstrap to skip necessary rebuilds, which may lead to risky results. -const RUSTC_IF_UNCHANGED_ALLOWED_PATHS: &[&str] = &[ +pub(crate) const RUSTC_IF_UNCHANGED_ALLOWED_PATHS: &[&str] = &[ ":!.github", ":!.clang-format", ":!.editorconfig", diff --git a/src/bootstrap/src/core/config/tests.rs b/src/bootstrap/src/core/config/tests.rs index 2611b6cf51bb..f482dff05471 100644 --- a/src/bootstrap/src/core/config/tests.rs +++ b/src/bootstrap/src/core/config/tests.rs @@ -8,7 +8,7 @@ use clap::CommandFactory; use serde::Deserialize; use super::flags::Flags; -use super::{ChangeIdWrapper, Config}; +use super::{ChangeIdWrapper, Config, RUSTC_IF_UNCHANGED_ALLOWED_PATHS}; use crate::core::build_steps::clippy::get_clippy_rules_in_order; use crate::core::build_steps::llvm; use crate::core::config::{LldMode, Target, TargetSelection, TomlConfig}; @@ -352,3 +352,18 @@ fn parse_rust_std_features_empty() { fn parse_rust_std_features_invalid() { parse("rust.std-features = \"backtrace\""); } + +#[test] +fn check_rustc_if_unchanged_paths() { + let config = parse(""); + let normalised_allowed_paths: Vec<_> = RUSTC_IF_UNCHANGED_ALLOWED_PATHS + .iter() + .map(|t| { + t.strip_prefix(":!").expect(&format!("{t} doesn't have ':!' prefix, but it should.")) + }) + .collect(); + + for p in normalised_allowed_paths { + assert!(config.src.join(p).exists(), "{p} doesn't exist."); + } +}