about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 07:44:09 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 07:44:09 -0500
commitb9e4174d8cf03fdcd0f9f128422b1f565d6b6607 (patch)
tree4b389ee2c006c80eaaeccaf9cc68229b8b2f3dc5 /src/bootstrap
parentdddd8724271a2a38ce552f5b1062a7ea070ec126 (diff)
downloadrust-b9e4174d8cf03fdcd0f9f128422b1f565d6b6607.tar.gz
rust-b9e4174d8cf03fdcd0f9f128422b1f565d6b6607.zip
Do not run if rustfmt.toml does not exist
distcheck (and generally publishing tarballs) will not package
rustfmt.toml and we for now still support running tidy etc in those
tarballs.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/format.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bootstrap/format.rs b/src/bootstrap/format.rs
index e253e525526..c8ae2f4e688 100644
--- a/src/bootstrap/format.rs
+++ b/src/bootstrap/format.rs
@@ -37,8 +37,13 @@ pub fn format(build: &Build, check: bool) {
     builder.add_defaults();
     builder.select("rust");
     let matcher = builder.build().unwrap();
-
-    let rustfmt_config = t!(std::fs::read_to_string(build.src.join("rustfmt.toml")));
+    let rustfmt_config = build.src.join("rustfmt.toml");
+    if !rustfmt_config.exists() {
+        eprintln!("Not running formatting checks; rustfmt.toml does not exist.");
+        eprintln!("This may happen in distributed tarballs.");
+        return;
+    }
+    let rustfmt_config = t!(std::fs::read_to_string(&rustfmt_config));
     let rustfmt_config: RustfmtConfig = t!(toml::from_str(&rustfmt_config));
     let mut ignore_fmt = ignore::overrides::OverrideBuilder::new(&build.src);
     for ignore in rustfmt_config.ignore {