Skip to content

Commit 4363f9b

Browse files
committed
Auto merge of rust-lang#135040 - matthiaskrgr:rollup-34vsa8n, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#135016 (Ping me for rustc-dev-guide subtree changes on this repo) - rust-lang#135027 (Remove range-metadata amdgpu workaround) - rust-lang#135029 (Update mailmap) - rust-lang#135033 (try to dedup me in the mailmap) - rust-lang#135035 (Fix formatting command) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1b2745d + 666794e commit 4363f9b

File tree

4 files changed

+51
-29
lines changed

4 files changed

+51
-29
lines changed

Diff for: .mailmap

+5
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ Eduardo Broto <[email protected]>
189189
190190
Jacob Finkelman <[email protected]>
191191
192+
193+
194+
192195
193196
Elly Fong-Jones <[email protected]>
194197
@@ -654,6 +657,8 @@ Vitali Haravy <[email protected]> Vitali Haravy <humaneprogrammer@gmail
654657
Vitaly Shukela <[email protected]>
655658
Waffle Lapkin <[email protected]>
656659
660+
Weihang Lo <[email protected]>
661+
657662
658663
whitequark <[email protected]>
659664

Diff for: compiler/rustc_codegen_llvm/src/builder.rs

-8
Original file line numberDiff line numberDiff line change
@@ -610,14 +610,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
610610
}
611611

612612
fn range_metadata(&mut self, load: &'ll Value, range: WrappingRange) {
613-
if self.sess().target.arch == "amdgpu" {
614-
// amdgpu/LLVM does something weird and thinks an i64 value is
615-
// split into a v2i32, halving the bitwidth LLVM expects,
616-
// tripping an assertion. So, for now, just disable this
617-
// optimization.
618-
return;
619-
}
620-
621613
if self.cx.sess().opts.optimize == OptLevel::No {
622614
// Don't emit metadata we're not going to use
623615
return;

Diff for: src/bootstrap/src/core/build_steps/format.rs

+45-20
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,19 @@ use crate::core::builder::Builder;
1414
use crate::utils::exec::command;
1515
use crate::utils::helpers::{self, program_out_of_date, t};
1616

17-
fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl FnMut(bool) -> bool {
17+
#[must_use]
18+
enum RustfmtStatus {
19+
InProgress,
20+
Ok,
21+
Failed,
22+
}
23+
24+
fn rustfmt(
25+
src: &Path,
26+
rustfmt: &Path,
27+
paths: &[PathBuf],
28+
check: bool,
29+
) -> impl FnMut(bool) -> RustfmtStatus {
1830
let mut cmd = Command::new(rustfmt);
1931
// Avoid the submodule config paths from coming into play. We only allow a single global config
2032
// for the workspace for now.
@@ -26,30 +38,20 @@ fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl F
2638
cmd.arg("--check");
2739
}
2840
cmd.args(paths);
29-
let cmd_debug = format!("{cmd:?}");
3041
let mut cmd = cmd.spawn().expect("running rustfmt");
3142
// Poor man's async: return a closure that might wait for rustfmt's completion (depending on
3243
// the value of the `block` argument).
33-
move |block: bool| -> bool {
44+
move |block: bool| -> RustfmtStatus {
3445
let status = if !block {
3546
match cmd.try_wait() {
3647
Ok(Some(status)) => Ok(status),
37-
Ok(None) => return false,
48+
Ok(None) => return RustfmtStatus::InProgress,
3849
Err(err) => Err(err),
3950
}
4051
} else {
4152
cmd.wait()
4253
};
43-
if !status.unwrap().success() {
44-
eprintln!(
45-
"fmt error: Running `{}` failed.\nIf you're running `tidy`, \
46-
try again with `--bless`. Or, if you just want to format \
47-
code, run `./x.py fmt` instead.",
48-
cmd_debug,
49-
);
50-
crate::exit!(1);
51-
}
52-
true
54+
if status.unwrap().success() { RustfmtStatus::Ok } else { RustfmtStatus::Failed }
5355
}
5456
}
5557

@@ -240,6 +242,8 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) {
240242
// Spawn child processes on a separate thread so we can batch entries we have received from
241243
// ignore.
242244
let thread = std::thread::spawn(move || {
245+
let mut result = Ok(());
246+
243247
let mut children = VecDeque::new();
244248
while let Ok(path) = rx.recv() {
245249
// Try getting more paths from the channel to amortize the overhead of spawning
@@ -251,22 +255,38 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) {
251255

252256
// Poll completion before waiting.
253257
for i in (0..children.len()).rev() {
254-
if children[i](false) {
255-
children.swap_remove_back(i);
256-
break;
258+
match children[i](false) {
259+
RustfmtStatus::InProgress => {}
260+
RustfmtStatus::Failed => {
261+
result = Err(());
262+
children.swap_remove_back(i);
263+
break;
264+
}
265+
RustfmtStatus::Ok => {
266+
children.swap_remove_back(i);
267+
break;
268+
}
257269
}
258270
}
259271

260272
if children.len() >= max_processes {
261273
// Await oldest child.
262-
children.pop_front().unwrap()(true);
274+
match children.pop_front().unwrap()(true) {
275+
RustfmtStatus::InProgress | RustfmtStatus::Ok => {}
276+
RustfmtStatus::Failed => result = Err(()),
277+
}
263278
}
264279
}
265280

266281
// Await remaining children.
267282
for mut child in children {
268-
child(true);
283+
match child(true) {
284+
RustfmtStatus::InProgress | RustfmtStatus::Ok => {}
285+
RustfmtStatus::Failed => result = Err(()),
286+
}
269287
}
288+
289+
result
270290
});
271291

272292
let formatted_paths = Mutex::new(Vec::new());
@@ -299,7 +319,12 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) {
299319

300320
drop(tx);
301321

302-
thread.join().unwrap();
322+
let result = thread.join().unwrap();
323+
324+
if result.is_err() {
325+
crate::exit!(1);
326+
}
327+
303328
if !check {
304329
update_rustfmt_version(build);
305330
}

Diff for: triagebot.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ project-exploit-mitigations = [
12081208
"/src/doc/nomicon" = ["@ehuss"]
12091209
"/src/doc/reference" = ["@ehuss"]
12101210
"/src/doc/rust-by-example" = ["@ehuss"]
1211-
"/src/doc/rustc-dev-guide" = ["@kobzol"]
1211+
"/src/doc/rustc-dev-guide" = ["@kobzol", "@jieyouxu"]
12121212
"/src/doc/rustdoc" = ["rustdoc"]
12131213
"/src/doc/style-guide" = ["style-team"]
12141214
"/src/etc" = ["@Mark-Simulacrum"]

0 commit comments

Comments
 (0)