1 use std::path::PathBuf;
4 pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
7 let root_path: PathBuf = std::env::args_os().nth(1).expect("need path to root of repo").into();
8 let version_path = root_path.join("src").join("version");
9 let version_str = t!(std::fs::read_to_string(&version_path), version_path);
10 let version_str = version_str.trim();
14 walk::filter_dirs(path)
15 // We exempt these as they require the placeholder
16 // for their operation
17 || path.ends_with("compiler/rustc_attr/src/builtin.rs")
18 || path.ends_with("src/tools/tidy/src/features/version.rs")
19 || path.ends_with("src/tools/replace-version-placeholder")
21 &mut |entry, contents| {
22 if !contents.contains(VERSION_PLACEHOLDER) {
25 let new_contents = contents.replace(VERSION_PLACEHOLDER, version_str);
26 let path = entry.path();
27 t!(std::fs::write(&path, new_contents), path);