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

Rollup of 6 pull requests #125663

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ead02ba
NVPTX: Avoid PassMode::Direct for args in C abi
May 10, 2024
f63931b
Cleanup custom mingw in CI
ChrisDenton May 26, 2024
19cfe8d
Add "Setup Python" action to github-hosted runners
ChrisDenton May 26, 2024
ede62b8
Add an intrinsic for `ptr::metadata`
scottmcm Apr 21, 2024
ce8f37b
Add custom mir support for `PtrMetadata`
scottmcm May 25, 2024
0f9e4d6
Add Miri tests for `PtrMetadata` UB
scottmcm May 26, 2024
f931290
Update description of install-mingw
ChrisDenton May 27, 2024
713ddc2
Add Miri smoke pass test for ptr_metadata intrinsic
scottmcm May 27, 2024
bcfa67d
Remove out-of-date comment.
nnethercote May 22, 2024
5673337
Add `assert_not_contains` to `run-make-support` library
GuillaumeGomez May 27, 2024
404d47e
Migrate `run-make/allow-warnings-cmdline-stability` to `rmake.rs`
GuillaumeGomez May 26, 2024
4702a1c
Fix comments.
nnethercote May 28, 2024
f1b0ca0
Don't format `tests/run-make/*/rmake.rs`.
nnethercote May 28, 2024
50a5da1
EvalCtxt::tcx() -> EvalCtxt::interner()
compiler-errors May 19, 2024
f494036
Make ProofTreeBuilder actually generic over interner
compiler-errors May 19, 2024
2c5a26b
Rollup merge of #117671 - kjetilkjeka:nvptx_c_abi_avoid_direct, r=dav…
matthiaskrgr May 28, 2024
f96ce48
Rollup merge of #124251 - scottmcm:unop-ptr-metadata, r=oli-obk
matthiaskrgr May 28, 2024
df3b962
Rollup merge of #125573 - GuillaumeGomez:migrate-allow-warnings-cmdli…
matthiaskrgr May 28, 2024
1c51557
Rollup merge of #125590 - ChrisDenton:mingw-ci-3, r=Kobzol
matthiaskrgr May 28, 2024
87cd582
Rollup merge of #125598 - compiler-errors:proof-tree-builder, r=lcnr
matthiaskrgr May 28, 2024
2c7d9ce
Rollup merge of #125637 - nnethercote:rustfmt-fixes, r=GuillaumeGomez
matthiaskrgr May 28, 2024
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
Prev Previous commit
Next Next commit
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.
  • Loading branch information
nnethercote committed May 28, 2024
commit 4702a1c345f1c13e13bdbe9bb3fdb81d6f866d85
14 changes: 7 additions & 7 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ version = "Two"
use_small_heuristics = "Max"
merge_derives = false

# tidy only checks files which are not ignored, each entry follows gitignore style
# Files to ignore. Each entry uses gitignore syntax.
ignore = [
"/build/",
"/*-build/",
"/build-*/",
"/vendor/",

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

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

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

# these are ignored by a standard cargo fmt run
# These are ignored by a standard cargo fmt run.
"compiler/rustc_codegen_cranelift/scripts",
"compiler/rustc_codegen_cranelift/example/gen_block_iterate.rs", # uses edition 2024
]
31 changes: 17 additions & 14 deletions src/bootstrap/src/core/build_steps/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use std::sync::mpsc::SyncSender;

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

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

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

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

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

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

if children.len() >= max_processes {
// await oldest child
// Await oldest child.
children.pop_front().unwrap()(true);
}
}

// await remaining children
// Await remaining children.
for mut child in children {
child(true);
}
Expand Down