Skip to content

Commit

Permalink
Do not run if rustfmt.toml does not exist
Browse files Browse the repository at this point in the history
distcheck (and generally publishing tarballs) will not package
rustfmt.toml and we for now still support running tidy etc in those
tarballs.
  • Loading branch information
Mark-Simulacrum committed Dec 22, 2019
1 parent dddd872 commit b9e4174
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/bootstrap/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b9e4174

Please sign in to comment.