Skip to content

Commit 4702a1c

Browse files
committed
Fix comments.
Some are too long, some aren't complete sentences, some are complete sentences but don't bother with an upper case letter at the start. All annoying and hurt readability.
1 parent bcfa67d commit 4702a1c

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

rustfmt.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ version = "Two"
33
use_small_heuristics = "Max"
44
merge_derives = false
55

6-
# tidy only checks files which are not ignored, each entry follows gitignore style
6+
# Files to ignore. Each entry uses gitignore syntax.
77
ignore = [
88
"/build/",
99
"/*-build/",
1010
"/build-*/",
1111
"/vendor/",
1212

13-
# tests for now are not formatted, as they are sometimes pretty-printing constrained
14-
# (and generally rustfmt can move around comments in UI-testing incompatible ways)
13+
# Tests for now are not formatted, as they are sometimes pretty-printing constrained
14+
# (and generally rustfmt can move around comments in UI-testing incompatible ways).
1515
"/tests/*",
1616

17-
# but we still want to format rmake.rs files in tests/run-make/ so we need to do this
18-
# dance to avoid the parent directory from being excluded
17+
# But we still want to format rmake.rs files in tests/run-make/ so we need to do this
18+
# dance to avoid the parent directory from being excluded.
1919
"!/tests/run-make/",
2020
"/tests/run-make/*/*.rs",
2121
"!/tests/run-make/*/rmake.rs",
2222

23-
# do not format submodules
23+
# Do not format submodules.
2424
# FIXME: sync submodule list with tidy/bootstrap/etc
2525
# tidy/src/walk.rs:filter_dirs
2626
"library/backtrace",
@@ -42,7 +42,7 @@ ignore = [
4242
"src/tools/rustc-perf",
4343
"src/tools/rustfmt",
4444

45-
# these are ignored by a standard cargo fmt run
45+
# These are ignored by a standard cargo fmt run.
4646
"compiler/rustc_codegen_cranelift/scripts",
4747
"compiler/rustc_codegen_cranelift/example/gen_block_iterate.rs", # uses edition 2024
4848
]

src/bootstrap/src/core/build_steps/format.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use std::sync::mpsc::SyncSender;
1212

1313
fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl FnMut(bool) -> bool {
1414
let mut cmd = Command::new(rustfmt);
15-
// avoid the submodule config paths from coming into play,
16-
// we only allow a single global config for the workspace for now
15+
// Avoid the submodule config paths from coming into play. We only allow a single global config
16+
// for the workspace for now.
1717
cmd.arg("--config-path").arg(&src.canonicalize().unwrap());
1818
cmd.arg("--edition").arg("2021");
1919
cmd.arg("--unstable-features");
@@ -24,7 +24,7 @@ fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl F
2424
cmd.args(paths);
2525
let cmd_debug = format!("{cmd:?}");
2626
let mut cmd = cmd.spawn().expect("running rustfmt");
27-
// poor man's async: return a closure that'll wait for rustfmt's completion
27+
// Poor man's async: return a closure that'll wait for rustfmt's completion.
2828
move |block: bool| -> bool {
2929
if !block {
3030
match cmd.try_wait() {
@@ -72,7 +72,7 @@ fn verify_rustfmt_version(build: &Builder<'_>) -> bool {
7272
!program_out_of_date(&stamp_file, &version)
7373
}
7474

75-
/// Updates the last rustfmt version used
75+
/// Updates the last rustfmt version used.
7676
fn update_rustfmt_version(build: &Builder<'_>) {
7777
let Some((version, stamp_file)) = get_rustfmt_version(build) else {
7878
return;
@@ -168,9 +168,10 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
168168
untracked_count += 1;
169169
fmt_override.add(&format!("!/{untracked_path}")).expect(untracked_path);
170170
}
171-
// Only check modified files locally to speed up runtime.
172-
// We still check all files in CI to avoid bugs in `get_modified_rs_files` letting regressions slip through;
173-
// we also care about CI time less since this is still very fast compared to building the compiler.
171+
// Only check modified files locally to speed up runtime. We still check all files in
172+
// CI to avoid bugs in `get_modified_rs_files` letting regressions slip through; we
173+
// also care about CI time less since this is still very fast compared to building the
174+
// compiler.
174175
if !CiEnv::is_ci() && paths.is_empty() {
175176
match get_modified_rs_files(build) {
176177
Ok(Some(files)) => {
@@ -275,21 +276,23 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
275276
.overrides(fmt_override)
276277
.build_parallel();
277278

278-
// there is a lot of blocking involved in spawning a child process and reading files to format.
279-
// spawn more processes than available concurrency to keep the CPU busy
279+
// There is a lot of blocking involved in spawning a child process and reading files to format.
280+
// Spawn more processes than available concurrency to keep the CPU busy.
280281
let max_processes = build.jobs() as usize * 2;
281282

282-
// spawn child processes on a separate thread so we can batch entries we have received from ignore
283+
// Spawn child processes on a separate thread so we can batch entries we have received from
284+
// ignore.
283285
let thread = std::thread::spawn(move || {
284286
let mut children = VecDeque::new();
285287
while let Ok(path) = rx.recv() {
286-
// try getting more paths from the channel to amortize the overhead of spawning processes
288+
// Try getting more paths from the channel to amortize the overhead of spawning
289+
// processes.
287290
let paths: Vec<_> = rx.try_iter().take(63).chain(std::iter::once(path)).collect();
288291

289292
let child = rustfmt(&src, &rustfmt_path, paths.as_slice(), check);
290293
children.push_back(child);
291294

292-
// poll completion before waiting
295+
// Poll completion before waiting.
293296
for i in (0..children.len()).rev() {
294297
if children[i](false) {
295298
children.swap_remove_back(i);
@@ -298,12 +301,12 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
298301
}
299302

300303
if children.len() >= max_processes {
301-
// await oldest child
304+
// Await oldest child.
302305
children.pop_front().unwrap()(true);
303306
}
304307
}
305308

306-
// await remaining children
309+
// Await remaining children.
307310
for mut child in children {
308311
child(true);
309312
}

0 commit comments

Comments
 (0)