Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor the rustfmt setting in config.toml #78842

Merged
merged 1 commit into from
Nov 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,11 +913,18 @@ impl Config {
set(&mut config.missing_tools, t.missing_tools);
}

// Cargo does not provide a RUSTFMT environment variable, so we
// synthesize it manually. Note that we also later check the config.toml
// and set this to that path if necessary.
let rustfmt = config.initial_rustc.with_file_name(exe("rustfmt", config.build));
config.initial_rustfmt = if rustfmt.exists() { Some(rustfmt) } else { None };
config.initial_rustfmt = config.initial_rustfmt.or_else({
let build = config.build;
let initial_rustc = &config.initial_rustc;

move || {
// Cargo does not provide a RUSTFMT environment variable, so we
// synthesize it manually.
let rustfmt = initial_rustc.with_file_name(exe("rustfmt", build));

if rustfmt.exists() { Some(rustfmt) } else { None }
}
});

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