Skip to content

Commit 58bda47

Browse files
committed
fmt_override is a better name since we are also adding files to whitelist
1 parent 79709e5 commit 58bda47

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/bootstrap/format.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
113113
}
114114
let rustfmt_config = t!(std::fs::read_to_string(&rustfmt_config));
115115
let rustfmt_config: RustfmtConfig = t!(toml::from_str(&rustfmt_config));
116-
let mut ignore_fmt = ignore::overrides::OverrideBuilder::new(&build.src);
116+
let mut fmt_override = ignore::overrides::OverrideBuilder::new(&build.src);
117117
for ignore in rustfmt_config.ignore {
118-
ignore_fmt.add(&format!("!{ignore}")).expect(&ignore);
118+
fmt_override.add(&format!("!{ignore}")).expect(&ignore);
119119
}
120120
let git_available = match Command::new("git")
121121
.arg("--version")
@@ -161,38 +161,38 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
161161
// against anything like `compiler/rustc_foo/src/foo.rs`,
162162
// preventing the latter from being formatted.
163163
untracked_count += 1;
164-
ignore_fmt.add(&format!("!/{untracked_path}")).expect(&untracked_path);
164+
fmt_override.add(&format!("!/{untracked_path}")).expect(&untracked_path);
165165
}
166166
// Only check modified files locally to speed up runtime.
167167
// We still check all files in CI to avoid bugs in `get_modified_rs_files` letting regressions slip through;
168168
// we also care about CI time less since this is still very fast compared to building the compiler.
169169
if !CiEnv::is_ci() && paths.is_empty() {
170170
match get_modified_rs_files(build) {
171171
Ok(Some(files)) => {
172-
eprintln!("Found {:?} modified files", files);
173172
if files.len() <= 10 {
174173
for file in &files {
175174
println!("formatting modified file {file}");
176175
}
177-
}
178-
let pluralized = |count| if count > 1 { "files" } else { "file" };
179-
let untracked_msg = if untracked_count == 0 {
180-
"".to_string()
181176
} else {
182-
format!(
183-
", skipped {} untracked {}",
184-
untracked_count,
185-
pluralized(untracked_count),
186-
)
187-
};
188-
println!(
189-
"formatting {} modified {}{}",
190-
files.len(),
191-
pluralized(files.len()),
192-
untracked_msg
193-
);
177+
let pluralized = |count| if count > 1 { "files" } else { "file" };
178+
let untracked_msg = if untracked_count == 0 {
179+
"".to_string()
180+
} else {
181+
format!(
182+
", skipped {} untracked {}",
183+
untracked_count,
184+
pluralized(untracked_count),
185+
)
186+
};
187+
println!(
188+
"formatting {} modified {}{}",
189+
files.len(),
190+
pluralized(files.len()),
191+
untracked_msg
192+
);
193+
}
194194
for file in files {
195-
ignore_fmt.add(&format!("/{file}")).expect(&file);
195+
fmt_override.add(&format!("/{file}")).expect(&file);
196196
}
197197
}
198198
Ok(None) => {}
@@ -213,7 +213,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
213213
println!("Could not find usable git. Skipping git-aware format checks");
214214
}
215215

216-
let ignore_fmt = ignore_fmt.build().unwrap();
216+
let fmt_override = fmt_override.build().unwrap();
217217

218218
let rustfmt_path = build.initial_rustfmt().unwrap_or_else(|| {
219219
eprintln!("./x.py fmt is not supported on this channel");
@@ -269,7 +269,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
269269
None => WalkBuilder::new(src.clone()),
270270
}
271271
.types(matcher)
272-
.overrides(ignore_fmt)
272+
.overrides(fmt_override)
273273
.build_parallel();
274274

275275
// there is a lot of blocking involved in spawning a child process and reading files to format.

0 commit comments

Comments
 (0)