Skip to content

Commit 8cae2f1

Browse files
committed
Honor the rustfmt setting in config.toml
Prior to this, setting the rustfmt configuration was ignored: ``` % mkdir example % cd example % ../configure --set build.rustfmt=/usr/bin/true % ../x.py fmt ./x.py fmt is not supported on this channel failed to run: /Users/shep/Projects/rust/example/build/bootstrap/debug/bootstrap fmt Build completed unsuccessfully in 0:00:01 ``` And after: ``` % ../x.py fmt Build completed successfully in 0:00:11 ```
1 parent 0256d06 commit 8cae2f1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/bootstrap/config.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -913,11 +913,18 @@ impl Config {
913913
set(&mut config.missing_tools, t.missing_tools);
914914
}
915915

916-
// Cargo does not provide a RUSTFMT environment variable, so we
917-
// synthesize it manually. Note that we also later check the config.toml
918-
// and set this to that path if necessary.
919-
let rustfmt = config.initial_rustc.with_file_name(exe("rustfmt", config.build));
920-
config.initial_rustfmt = if rustfmt.exists() { Some(rustfmt) } else { None };
916+
config.initial_rustfmt = config.initial_rustfmt.or_else({
917+
let build = config.build;
918+
let initial_rustc = &config.initial_rustc;
919+
920+
move || {
921+
// Cargo does not provide a RUSTFMT environment variable, so we
922+
// synthesize it manually.
923+
let rustfmt = initial_rustc.with_file_name(exe("rustfmt", build));
924+
925+
if rustfmt.exists() { Some(rustfmt) } else { None }
926+
}
927+
});
921928

922929
// Now that we've reached the end of our configuration, infer the
923930
// default values for all options that we haven't otherwise stored yet.

0 commit comments

Comments
 (0)