1
Fork 0

Auto merge of #114066 - matthiaskrgr:fmt_args_inline_bootstrap, r=WaffleLapkin

bootstrap: inline format!() args (0)

r? `@WaffleLapkin`
This commit is contained in:
bors 2023-07-30 12:14:04 +00:00
commit 483ef5f4d8
23 changed files with 162 additions and 174 deletions

View file

@ -67,7 +67,7 @@ fn main() {
`cp config.example.toml config.toml`" `cp config.example.toml config.toml`"
); );
} else if let Some(suggestion) = &changelog_suggestion { } else if let Some(suggestion) = &changelog_suggestion {
println!("{}", suggestion); println!("{suggestion}");
} }
let pre_commit = config.src.join(".git").join("hooks").join("pre-commit"); let pre_commit = config.src.join(".git").join("hooks").join("pre-commit");
@ -80,7 +80,7 @@ fn main() {
`cp config.example.toml config.toml`" `cp config.example.toml config.toml`"
); );
} else if let Some(suggestion) = &changelog_suggestion { } else if let Some(suggestion) = &changelog_suggestion {
println!("{}", suggestion); println!("{suggestion}");
} }
// Give a warning if the pre-commit script is in pre-commit and not pre-push. // Give a warning if the pre-commit script is in pre-commit and not pre-push.
@ -107,13 +107,13 @@ fn check_version(config: &Config) -> Option<String> {
let suggestion = if let Some(seen) = config.changelog_seen { let suggestion = if let Some(seen) = config.changelog_seen {
if seen != VERSION { if seen != VERSION {
msg.push_str("warning: there have been changes to x.py since you last updated.\n"); msg.push_str("warning: there have been changes to x.py since you last updated.\n");
format!("update `config.toml` to use `changelog-seen = {}` instead", VERSION) format!("update `config.toml` to use `changelog-seen = {VERSION}` instead")
} else { } else {
return None; return None;
} }
} else { } else {
msg.push_str("warning: x.py has made several changes recently you may want to look at\n"); msg.push_str("warning: x.py has made several changes recently you may want to look at\n");
format!("add `changelog-seen = {}` at the top of `config.toml`", VERSION) format!("add `changelog-seen = {VERSION}` at the top of `config.toml`")
}; };
msg.push_str("help: consider looking at the changes in `src/bootstrap/CHANGELOG.md`\n"); msg.push_str("help: consider looking at the changes in `src/bootstrap/CHANGELOG.md`\n");

View file

@ -120,7 +120,7 @@ fn main() {
// Override linker if necessary. // Override linker if necessary.
if let Ok(host_linker) = env::var("RUSTC_HOST_LINKER") { if let Ok(host_linker) = env::var("RUSTC_HOST_LINKER") {
cmd.arg(format!("-Clinker={}", host_linker)); cmd.arg(format!("-Clinker={host_linker}"));
} }
if env::var_os("RUSTC_HOST_FUSE_LD_LLD").is_some() { if env::var_os("RUSTC_HOST_FUSE_LD_LLD").is_some() {
cmd.arg("-Clink-args=-fuse-ld=lld"); cmd.arg("-Clink-args=-fuse-ld=lld");
@ -206,11 +206,11 @@ fn main() {
env::vars().filter(|(k, _)| k.starts_with("RUST") || k.starts_with("CARGO")); env::vars().filter(|(k, _)| k.starts_with("RUST") || k.starts_with("CARGO"));
let prefix = if is_test { "[RUSTC-SHIM] rustc --test" } else { "[RUSTC-SHIM] rustc" }; let prefix = if is_test { "[RUSTC-SHIM] rustc --test" } else { "[RUSTC-SHIM] rustc" };
let prefix = match crate_name { let prefix = match crate_name {
Some(crate_name) => format!("{} {}", prefix, crate_name), Some(crate_name) => format!("{prefix} {crate_name}"),
None => prefix.to_string(), None => prefix.to_string(),
}; };
for (i, (k, v)) in rust_env_vars.enumerate() { for (i, (k, v)) in rust_env_vars.enumerate() {
eprintln!("{} env[{}]: {:?}={:?}", prefix, i, k, v); eprintln!("{prefix} env[{i}]: {k:?}={v:?}");
} }
eprintln!("{} working directory: {}", prefix, env::current_dir().unwrap().display()); eprintln!("{} working directory: {}", prefix, env::current_dir().unwrap().display());
eprintln!( eprintln!(
@ -220,13 +220,13 @@ fn main() {
env::join_paths(&dylib_path).unwrap(), env::join_paths(&dylib_path).unwrap(),
cmd, cmd,
); );
eprintln!("{} sysroot: {:?}", prefix, sysroot); eprintln!("{prefix} sysroot: {sysroot:?}");
eprintln!("{} libdir: {:?}", prefix, libdir); eprintln!("{prefix} libdir: {libdir:?}");
} }
let start = Instant::now(); let start = Instant::now();
let (child, status) = { let (child, status) = {
let errmsg = format!("\nFailed to run:\n{:?}\n-------------", cmd); let errmsg = format!("\nFailed to run:\n{cmd:?}\n-------------");
let mut child = cmd.spawn().expect(&errmsg); let mut child = cmd.spawn().expect(&errmsg);
let status = child.wait().expect(&errmsg); let status = child.wait().expect(&errmsg);
(child, status) (child, status)
@ -259,7 +259,7 @@ fn main() {
// should run on success, after this block. // should run on success, after this block.
} }
if verbose > 0 { if verbose > 0 {
println!("\nDid not run successfully: {}\n{:?}\n-------------", status, cmd); println!("\nDid not run successfully: {status}\n{cmd:?}\n-------------");
} }
if let Some(mut on_fail) = on_fail { if let Some(mut on_fail) = on_fail {
@ -271,7 +271,7 @@ fn main() {
match status.code() { match status.code() {
Some(i) => std::process::exit(i), Some(i) => std::process::exit(i),
None => { None => {
eprintln!("rustc exited with {}", status); eprintln!("rustc exited with {status}");
std::process::exit(0xfe); std::process::exit(0xfe);
} }
} }
@ -396,21 +396,20 @@ fn format_rusage_data(_child: Child) -> Option<String> {
let minflt = rusage.ru_minflt; let minflt = rusage.ru_minflt;
let majflt = rusage.ru_majflt; let majflt = rusage.ru_majflt;
if minflt != 0 || majflt != 0 { if minflt != 0 || majflt != 0 {
init_str.push_str(&format!(" page reclaims: {} page faults: {}", minflt, majflt)); init_str.push_str(&format!(" page reclaims: {minflt} page faults: {majflt}"));
} }
let inblock = rusage.ru_inblock; let inblock = rusage.ru_inblock;
let oublock = rusage.ru_oublock; let oublock = rusage.ru_oublock;
if inblock != 0 || oublock != 0 { if inblock != 0 || oublock != 0 {
init_str.push_str(&format!(" fs block inputs: {} fs block outputs: {}", inblock, oublock)); init_str.push_str(&format!(" fs block inputs: {inblock} fs block outputs: {oublock}"));
} }
let nvcsw = rusage.ru_nvcsw; let nvcsw = rusage.ru_nvcsw;
let nivcsw = rusage.ru_nivcsw; let nivcsw = rusage.ru_nivcsw;
if nvcsw != 0 || nivcsw != 0 { if nvcsw != 0 || nivcsw != 0 {
init_str.push_str(&format!( init_str.push_str(&format!(
" voluntary ctxt switches: {} involuntary ctxt switches: {}", " voluntary ctxt switches: {nvcsw} involuntary ctxt switches: {nivcsw}"
nvcsw, nivcsw
)); ));
} }

View file

@ -62,7 +62,7 @@ fn main() {
} }
if let Ok(no_threads) = env::var("RUSTDOC_LLD_NO_THREADS") { if let Ok(no_threads) = env::var("RUSTDOC_LLD_NO_THREADS") {
cmd.arg("-Clink-arg=-fuse-ld=lld"); cmd.arg("-Clink-arg=-fuse-ld=lld");
cmd.arg(format!("-Clink-arg=-Wl,{}", no_threads)); cmd.arg(format!("-Clink-arg=-Wl,{no_threads}"));
} }
// Cargo doesn't pass RUSTDOCFLAGS to proc_macros: // Cargo doesn't pass RUSTDOCFLAGS to proc_macros:
// https://github.com/rust-lang/cargo/issues/4423 // https://github.com/rust-lang/cargo/issues/4423
@ -82,12 +82,12 @@ fn main() {
env::join_paths(&dylib_path).unwrap(), env::join_paths(&dylib_path).unwrap(),
cmd, cmd,
); );
eprintln!("sysroot: {:?}", sysroot); eprintln!("sysroot: {sysroot:?}");
eprintln!("libdir: {:?}", libdir); eprintln!("libdir: {libdir:?}");
} }
std::process::exit(match cmd.status() { std::process::exit(match cmd.status() {
Ok(s) => s.code().unwrap_or(1), Ok(s) => s.code().unwrap_or(1),
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e), Err(e) => panic!("\n\nfailed to run {cmd:?}: {e}\n\n"),
}) })
} }

View file

@ -3,5 +3,5 @@ use std::env;
fn main() { fn main() {
let host = env::var("HOST").unwrap(); let host = env::var("HOST").unwrap();
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rustc-env=BUILD_TRIPLE={}", host); println!("cargo:rustc-env=BUILD_TRIPLE={host}");
} }

View file

@ -319,7 +319,7 @@ impl StepDescription {
fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool { fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
if builder.config.exclude.iter().any(|e| pathset.has(&e, builder.kind)) { if builder.config.exclude.iter().any(|e| pathset.has(&e, builder.kind)) {
if !matches!(builder.config.dry_run, DryRun::SelfCheck) { if !matches!(builder.config.dry_run, DryRun::SelfCheck) {
println!("Skipping {:?} because it is excluded", pathset); println!("Skipping {pathset:?} because it is excluded");
} }
return true; return true;
} }
@ -473,8 +473,7 @@ impl<'a> ShouldRun<'a> {
// `compiler` and `library` folders respectively. // `compiler` and `library` folders respectively.
assert!( assert!(
self.kind == Kind::Setup || !self.builder.src.join(alias).exists(), self.kind == Kind::Setup || !self.builder.src.join(alias).exists(),
"use `builder.path()` for real paths: {}", "use `builder.path()` for real paths: {alias}"
alias
); );
self.paths.insert(PathSet::Set( self.paths.insert(PathSet::Set(
std::iter::once(TaskPath { path: alias.into(), kind: Some(self.kind) }).collect(), std::iter::once(TaskPath { path: alias.into(), kind: Some(self.kind) }).collect(),
@ -1283,7 +1282,7 @@ impl<'a> Builder<'a> {
out_dir.join(target.triple).join("doc") out_dir.join(target.triple).join("doc")
} }
} }
_ => panic!("doc mode {:?} not expected", mode), _ => panic!("doc mode {mode:?} not expected"),
}; };
let rustdoc = self.rustdoc(compiler); let rustdoc = self.rustdoc(compiler);
self.clear_if_dirty(&my_out, &rustdoc); self.clear_if_dirty(&my_out, &rustdoc);
@ -1637,15 +1636,15 @@ impl<'a> Builder<'a> {
// so. Note that this is definitely a hack, and we should likely // so. Note that this is definitely a hack, and we should likely
// flesh out rpath support more fully in the future. // flesh out rpath support more fully in the future.
rustflags.arg("-Zosx-rpath-install-name"); rustflags.arg("-Zosx-rpath-install-name");
Some(format!("-Wl,-rpath,@loader_path/../{}", libdir)) Some(format!("-Wl,-rpath,@loader_path/../{libdir}"))
} else if !target.contains("windows") && !target.contains("aix") { } else if !target.contains("windows") && !target.contains("aix") {
rustflags.arg("-Clink-args=-Wl,-z,origin"); rustflags.arg("-Clink-args=-Wl,-z,origin");
Some(format!("-Wl,-rpath,$ORIGIN/../{}", libdir)) Some(format!("-Wl,-rpath,$ORIGIN/../{libdir}"))
} else { } else {
None None
}; };
if let Some(rpath) = rpath { if let Some(rpath) = rpath {
rustflags.arg(&format!("-Clink-args={}", rpath)); rustflags.arg(&format!("-Clink-args={rpath}"));
} }
} }
@ -1659,7 +1658,7 @@ impl<'a> Builder<'a> {
if let Some(target_linker) = self.linker(target) { if let Some(target_linker) = self.linker(target) {
let target = crate::envify(&target.triple); let target = crate::envify(&target.triple);
cargo.env(&format!("CARGO_TARGET_{}_LINKER", target), target_linker); cargo.env(&format!("CARGO_TARGET_{target}_LINKER"), target_linker);
} }
if self.is_fuse_ld_lld(target) { if self.is_fuse_ld_lld(target) {
rustflags.arg("-Clink-args=-fuse-ld=lld"); rustflags.arg("-Clink-args=-fuse-ld=lld");
@ -1895,24 +1894,24 @@ impl<'a> Builder<'a> {
}; };
let triple_underscored = target.triple.replace("-", "_"); let triple_underscored = target.triple.replace("-", "_");
let cc = ccacheify(&self.cc(target)); let cc = ccacheify(&self.cc(target));
cargo.env(format!("CC_{}", triple_underscored), &cc); cargo.env(format!("CC_{triple_underscored}"), &cc);
let cflags = self.cflags(target, GitRepo::Rustc, CLang::C).join(" "); let cflags = self.cflags(target, GitRepo::Rustc, CLang::C).join(" ");
cargo.env(format!("CFLAGS_{}", triple_underscored), &cflags); cargo.env(format!("CFLAGS_{triple_underscored}"), &cflags);
if let Some(ar) = self.ar(target) { if let Some(ar) = self.ar(target) {
let ranlib = format!("{} s", ar.display()); let ranlib = format!("{} s", ar.display());
cargo cargo
.env(format!("AR_{}", triple_underscored), ar) .env(format!("AR_{triple_underscored}"), ar)
.env(format!("RANLIB_{}", triple_underscored), ranlib); .env(format!("RANLIB_{triple_underscored}"), ranlib);
} }
if let Ok(cxx) = self.cxx(target) { if let Ok(cxx) = self.cxx(target) {
let cxx = ccacheify(&cxx); let cxx = ccacheify(&cxx);
let cxxflags = self.cflags(target, GitRepo::Rustc, CLang::Cxx).join(" "); let cxxflags = self.cflags(target, GitRepo::Rustc, CLang::Cxx).join(" ");
cargo cargo
.env(format!("CXX_{}", triple_underscored), &cxx) .env(format!("CXX_{triple_underscored}"), &cxx)
.env(format!("CXXFLAGS_{}", triple_underscored), cxxflags); .env(format!("CXXFLAGS_{triple_underscored}"), cxxflags);
} }
} }
@ -2025,7 +2024,7 @@ impl<'a> Builder<'a> {
if let Some(limit) = limit { if let Some(limit) = limit {
if stage == 0 || self.config.default_codegen_backend().unwrap_or_default() == "llvm" if stage == 0 || self.config.default_codegen_backend().unwrap_or_default() == "llvm"
{ {
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={}", limit)); rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={limit}"));
} }
} }
} }
@ -2033,7 +2032,7 @@ impl<'a> Builder<'a> {
if matches!(mode, Mode::Std) { if matches!(mode, Mode::Std) {
if let Some(mir_opt_level) = self.config.rust_validate_mir_opts { if let Some(mir_opt_level) = self.config.rust_validate_mir_opts {
rustflags.arg("-Zvalidate-mir"); rustflags.arg("-Zvalidate-mir");
rustflags.arg(&format!("-Zmir-opt-level={}", mir_opt_level)); rustflags.arg(&format!("-Zmir-opt-level={mir_opt_level}"));
} }
// Always enable inlining MIR when building the standard library. // Always enable inlining MIR when building the standard library.
// Without this flag, MIR inlining is disabled when incremental compilation is enabled. // Without this flag, MIR inlining is disabled when incremental compilation is enabled.
@ -2065,9 +2064,9 @@ impl<'a> Builder<'a> {
continue; continue;
} }
let mut out = String::new(); let mut out = String::new();
out += &format!("\n\nCycle in build detected when adding {:?}\n", step); out += &format!("\n\nCycle in build detected when adding {step:?}\n");
for el in stack.iter().rev() { for el in stack.iter().rev() {
out += &format!("\t{:?}\n", el); out += &format!("\t{el:?}\n");
} }
panic!("{}", out); panic!("{}", out);
} }
@ -2094,7 +2093,7 @@ impl<'a> Builder<'a> {
}; };
if self.config.print_step_timings && !self.config.dry_run() { if self.config.print_step_timings && !self.config.dry_run() {
let step_string = format!("{:?}", step); let step_string = format!("{step:?}");
let brace_index = step_string.find("{").unwrap_or(0); let brace_index = step_string.find("{").unwrap_or(0);
let type_string = type_name::<S>(); let type_string = type_name::<S>();
println!( println!(
@ -2174,7 +2173,7 @@ impl<'a> Builder<'a> {
let path = path.as_ref(); let path = path.as_ref();
self.info(&format!("Opening doc {}", path.display())); self.info(&format!("Opening doc {}", path.display()));
if let Err(err) = opener::open(path) { if let Err(err) = opener::open(path) {
self.info(&format!("{}\n", err)); self.info(&format!("{err}\n"));
} }
} }
} }

View file

@ -75,7 +75,7 @@ where
{ {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s: &U = &*self; let s: &U = &*self;
f.write_fmt(format_args!("{:?}", s)) f.write_fmt(format_args!("{s:?}"))
} }
} }
@ -236,7 +236,7 @@ impl Cache {
.or_insert_with(|| Box::new(HashMap::<S, S::Output>::new())) .or_insert_with(|| Box::new(HashMap::<S, S::Output>::new()))
.downcast_mut::<HashMap<S, S::Output>>() .downcast_mut::<HashMap<S, S::Output>>()
.expect("invalid type mapped"); .expect("invalid type mapped");
assert!(!stepcache.contains_key(&step), "processing {:?} a second time", step); assert!(!stepcache.contains_key(&step), "processing {step:?} a second time");
stepcache.insert(step, value); stepcache.insert(step, value);
} }

View file

@ -196,7 +196,7 @@ fn set_compiler(
'0'..='6' => {} '0'..='6' => {}
_ => return, _ => return,
} }
let alternative = format!("e{}", gnu_compiler); let alternative = format!("e{gnu_compiler}");
if Command::new(&alternative).output().is_ok() { if Command::new(&alternative).output().is_ok() {
cfg.compiler(alternative); cfg.compiler(alternative);
} }

View file

@ -322,7 +322,7 @@ impl Step for CodegenBackend {
); );
cargo cargo
.arg("--manifest-path") .arg("--manifest-path")
.arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend))); .arg(builder.src.join(format!("compiler/rustc_codegen_{backend}/Cargo.toml")));
rustc_cargo_env(builder, &mut cargo, target, compiler.stage); rustc_cargo_env(builder, &mut cargo, target, compiler.stage);
let _guard = builder.msg_check(&backend, target); let _guard = builder.msg_check(&backend, target);
@ -525,5 +525,5 @@ fn codegen_backend_stamp(
) -> PathBuf { ) -> PathBuf {
builder builder
.cargo_out(compiler, Mode::Codegen, target) .cargo_out(compiler, Mode::Codegen, target)
.join(format!(".librustc_codegen_{}-check.stamp", backend)) .join(format!(".librustc_codegen_{backend}-check.stamp"))
} }

View file

@ -815,7 +815,7 @@ impl Step for Rustc {
let is_collecting = if let Some(path) = &builder.config.rust_profile_generate { let is_collecting = if let Some(path) = &builder.config.rust_profile_generate {
if compiler.stage == 1 { if compiler.stage == 1 {
cargo.rustflag(&format!("-Cprofile-generate={}", path)); cargo.rustflag(&format!("-Cprofile-generate={path}"));
// Apparently necessary to avoid overflowing the counters during // Apparently necessary to avoid overflowing the counters during
// a Cargo build profile // a Cargo build profile
cargo.rustflag("-Cllvm-args=-vp-counters-per-site=4"); cargo.rustflag("-Cllvm-args=-vp-counters-per-site=4");
@ -825,7 +825,7 @@ impl Step for Rustc {
} }
} else if let Some(path) = &builder.config.rust_profile_use { } else if let Some(path) = &builder.config.rust_profile_use {
if compiler.stage == 1 { if compiler.stage == 1 {
cargo.rustflag(&format!("-Cprofile-use={}", path)); cargo.rustflag(&format!("-Cprofile-use={path}"));
cargo.rustflag("-Cllvm-args=-pgo-warn-missing-function"); cargo.rustflag("-Cllvm-args=-pgo-warn-missing-function");
true true
} else { } else {
@ -858,7 +858,7 @@ impl Step for Rustc {
RustcLto::Fat => "fat", RustcLto::Fat => "fat",
_ => unreachable!(), _ => unreachable!(),
}; };
cargo.rustflag(&format!("-Clto={}", lto_type)); cargo.rustflag(&format!("-Clto={lto_type}"));
cargo.rustflag("-Cembed-bitcode=yes"); cargo.rustflag("-Cembed-bitcode=yes");
} }
RustcLto::ThinLocal => { /* Do nothing, this is the default */ } RustcLto::ThinLocal => { /* Do nothing, this is the default */ }
@ -1192,7 +1192,7 @@ impl Step for CodegenBackend {
let mut cargo = builder.cargo(compiler, Mode::Codegen, SourceType::InTree, target, "build"); let mut cargo = builder.cargo(compiler, Mode::Codegen, SourceType::InTree, target, "build");
cargo cargo
.arg("--manifest-path") .arg("--manifest-path")
.arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend))); .arg(builder.src.join(format!("compiler/rustc_codegen_{backend}/Cargo.toml")));
rustc_cargo_env(builder, &mut cargo, target, compiler.stage); rustc_cargo_env(builder, &mut cargo, target, compiler.stage);
let tmp_stamp = out_dir.join(".tmp.stamp"); let tmp_stamp = out_dir.join(".tmp.stamp");
@ -1297,7 +1297,7 @@ fn codegen_backend_stamp(
) -> PathBuf { ) -> PathBuf {
builder builder
.cargo_out(compiler, Mode::Codegen, target) .cargo_out(compiler, Mode::Codegen, target)
.join(format!(".librustc_codegen_{}.stamp", backend)) .join(format!(".librustc_codegen_{backend}.stamp"))
} }
pub fn compiler_file( pub fn compiler_file(
@ -1312,7 +1312,7 @@ pub fn compiler_file(
} }
let mut cmd = Command::new(compiler); let mut cmd = Command::new(compiler);
cmd.args(builder.cflags(target, GitRepo::Rustc, c)); cmd.args(builder.cflags(target, GitRepo::Rustc, c));
cmd.arg(format!("-print-file-name={}", file)); cmd.arg(format!("-print-file-name={file}"));
let out = output(&mut cmd); let out = output(&mut cmd);
PathBuf::from(out.trim()) PathBuf::from(out.trim())
} }
@ -1836,10 +1836,10 @@ pub fn run_cargo(
}); });
let path_to_add = match max { let path_to_add = match max {
Some(triple) => triple.0.to_str().unwrap(), Some(triple) => triple.0.to_str().unwrap(),
None => panic!("no output generated for {:?} {:?}", prefix, extension), None => panic!("no output generated for {prefix:?} {extension:?}"),
}; };
if is_dylib(path_to_add) { if is_dylib(path_to_add) {
let candidate = format!("{}.lib", path_to_add); let candidate = format!("{path_to_add}.lib");
let candidate = PathBuf::from(candidate); let candidate = PathBuf::from(candidate);
if candidate.exists() { if candidate.exists() {
deps.push((candidate, DependencyType::Target)); deps.push((candidate, DependencyType::Target));
@ -1891,10 +1891,10 @@ pub fn stream_cargo(
cargo.arg(arg); cargo.arg(arg);
} }
builder.verbose(&format!("running: {:?}", cargo)); builder.verbose(&format!("running: {cargo:?}"));
let mut child = match cargo.spawn() { let mut child = match cargo.spawn() {
Ok(child) => child, Ok(child) => child,
Err(e) => panic!("failed to execute command: {:?}\nerror: {}", cargo, e), Err(e) => panic!("failed to execute command: {cargo:?}\nerror: {e}"),
}; };
// Spawn Cargo slurping up its JSON output. We'll start building up the // Spawn Cargo slurping up its JSON output. We'll start building up the
@ -1907,12 +1907,12 @@ pub fn stream_cargo(
Ok(msg) => { Ok(msg) => {
if builder.config.json_output { if builder.config.json_output {
// Forward JSON to stdout. // Forward JSON to stdout.
println!("{}", line); println!("{line}");
} }
cb(msg) cb(msg)
} }
// If this was informational, just print it out and continue // If this was informational, just print it out and continue
Err(_) => println!("{}", line), Err(_) => println!("{line}"),
} }
} }
@ -1920,9 +1920,8 @@ pub fn stream_cargo(
let status = t!(child.wait()); let status = t!(child.wait());
if builder.is_verbose() && !status.success() { if builder.is_verbose() && !status.success() {
eprintln!( eprintln!(
"command did not execute successfully: {:?}\n\ "command did not execute successfully: {cargo:?}\n\
expected success, got: {}", expected success, got: {status}"
cargo, status
); );
} }
status.success() status.success()

View file

@ -356,7 +356,7 @@ impl FromStr for LlvmLibunwind {
"no" => Ok(Self::No), "no" => Ok(Self::No),
"in-tree" => Ok(Self::InTree), "in-tree" => Ok(Self::InTree),
"system" => Ok(Self::System), "system" => Ok(Self::System),
invalid => Err(format!("Invalid value '{}' for rust.llvm-libunwind config.", invalid)), invalid => Err(format!("Invalid value '{invalid}' for rust.llvm-libunwind config.")),
} }
} }
} }
@ -420,7 +420,7 @@ impl std::str::FromStr for RustcLto {
"thin" => Ok(RustcLto::Thin), "thin" => Ok(RustcLto::Thin),
"fat" => Ok(RustcLto::Fat), "fat" => Ok(RustcLto::Fat),
"off" => Ok(RustcLto::Off), "off" => Ok(RustcLto::Off),
_ => Err(format!("Invalid value for rustc LTO: {}", s)), _ => Err(format!("Invalid value for rustc LTO: {s}")),
} }
} }
} }
@ -498,7 +498,7 @@ impl fmt::Display for TargetSelection {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.triple)?; write!(f, "{}", self.triple)?;
if let Some(file) = self.file { if let Some(file) = self.file {
write!(f, "({})", file)?; write!(f, "({file})")?;
} }
Ok(()) Ok(())
} }
@ -506,7 +506,7 @@ impl fmt::Display for TargetSelection {
impl fmt::Debug for TargetSelection { impl fmt::Debug for TargetSelection {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self) write!(f, "{self}")
} }
} }
@ -938,8 +938,7 @@ impl<'de> serde::de::Visitor<'de> for OptimizeVisitor {
fn format_optimize_error_msg(v: impl std::fmt::Display) -> String { fn format_optimize_error_msg(v: impl std::fmt::Display) -> String {
format!( format!(
r#"unrecognized option for rust optimize: "{}", expected one of 0, 1, 2, 3, "s", "z", true, false"#, r#"unrecognized option for rust optimize: "{v}", expected one of 0, 1, 2, 3, "s", "z", true, false"#
v
) )
} }
@ -1226,7 +1225,7 @@ impl Config {
include_path.push("src"); include_path.push("src");
include_path.push("bootstrap"); include_path.push("bootstrap");
include_path.push("defaults"); include_path.push("defaults");
include_path.push(format!("config.{}.toml", include)); include_path.push(format!("config.{include}.toml"));
let included_toml = get_toml(&include_path); let included_toml = get_toml(&include_path);
toml.merge(included_toml, ReplaceOpt::IgnoreDuplicate); toml.merge(included_toml, ReplaceOpt::IgnoreDuplicate);
} }
@ -1516,7 +1515,7 @@ impl Config {
let asserts = llvm_assertions.unwrap_or(false); let asserts = llvm_assertions.unwrap_or(false);
config.llvm_from_ci = match llvm.download_ci_llvm { config.llvm_from_ci = match llvm.download_ci_llvm {
Some(StringOrBool::String(s)) => { Some(StringOrBool::String(s)) => {
assert!(s == "if-available", "unknown option `{}` for download-ci-llvm", s); assert!(s == "if-available", "unknown option `{s}` for download-ci-llvm");
crate::llvm::is_ci_llvm_available(&config, asserts) crate::llvm::is_ci_llvm_available(&config, asserts)
} }
Some(StringOrBool::Bool(b)) => b, Some(StringOrBool::Bool(b)) => b,
@ -1750,7 +1749,7 @@ impl Config {
if self.dry_run() { if self.dry_run() {
return Ok(()); return Ok(());
} }
self.verbose(&format!("running: {:?}", cmd)); self.verbose(&format!("running: {cmd:?}"));
build_helper::util::try_run(cmd, self.is_verbose()) build_helper::util::try_run(cmd, self.is_verbose())
} }
@ -1790,10 +1789,10 @@ impl Config {
pub(crate) fn artifact_version_part(&self, commit: &str) -> String { pub(crate) fn artifact_version_part(&self, commit: &str) -> String {
let (channel, version) = if self.rust_info.is_managed_git_subrepository() { let (channel, version) = if self.rust_info.is_managed_git_subrepository() {
let mut channel = self.git(); let mut channel = self.git();
channel.arg("show").arg(format!("{}:src/ci/channel", commit)); channel.arg("show").arg(format!("{commit}:src/ci/channel"));
let channel = output(&mut channel); let channel = output(&mut channel);
let mut version = self.git(); let mut version = self.git();
version.arg("show").arg(format!("{}:src/version", commit)); version.arg("show").arg(format!("{commit}:src/version"));
let version = output(&mut version); let version = output(&mut version);
(channel.trim().to_owned(), version.trim().to_owned()) (channel.trim().to_owned(), version.trim().to_owned())
} else { } else {
@ -1810,10 +1809,10 @@ impl Config {
"help: consider using a git checkout or ensure these files are readable" "help: consider using a git checkout or ensure these files are readable"
); );
if let Err(channel) = channel { if let Err(channel) = channel {
eprintln!("reading {}/src/ci/channel failed: {:?}", src, channel); eprintln!("reading {src}/src/ci/channel failed: {channel:?}");
} }
if let Err(version) = version { if let Err(version) = version {
eprintln!("reading {}/src/version failed: {:?}", src, version); eprintln!("reading {src}/src/version failed: {version:?}");
} }
panic!(); panic!();
} }
@ -1939,7 +1938,7 @@ impl Config {
pub fn verbose(&self, msg: &str) { pub fn verbose(&self, msg: &str) {
if self.verbose > 0 { if self.verbose > 0 {
println!("{}", msg); println!("{msg}");
} }
} }
@ -2016,8 +2015,7 @@ impl Config {
{ {
let prev_version = format!("{}.{}.x", source_version.major, source_version.minor - 1); let prev_version = format!("{}.{}.x", source_version.major, source_version.minor - 1);
eprintln!( eprintln!(
"Unexpected rustc version: {}, we should use {}/{} to build source with {}", "Unexpected rustc version: {rustc_version}, we should use {prev_version}/{source_version} to build source with {source_version}"
rustc_version, prev_version, source_version, source_version
); );
exit!(1); exit!(1);
} }
@ -2031,7 +2029,7 @@ impl Config {
Some(StringOrBool::Bool(true)) => false, Some(StringOrBool::Bool(true)) => false,
Some(StringOrBool::String(s)) if s == "if-unchanged" => true, Some(StringOrBool::String(s)) if s == "if-unchanged" => true,
Some(StringOrBool::String(other)) => { Some(StringOrBool::String(other)) => {
panic!("unrecognized option for download-rustc: {}", other) panic!("unrecognized option for download-rustc: {other}")
} }
}; };

View file

@ -162,7 +162,7 @@ fn find_files(files: &[&str], path: &[PathBuf]) -> Vec<PathBuf> {
if let Some(file_path) = file_path { if let Some(file_path) = file_path {
found.push(file_path); found.push(file_path);
} else { } else {
panic!("Could not find '{}' in {:?}", file, path); panic!("Could not find '{file}' in {path:?}");
} }
} }
@ -1480,8 +1480,8 @@ impl Step for Extended {
rtf.push('}'); rtf.push('}');
fn filter(contents: &str, marker: &str) -> String { fn filter(contents: &str, marker: &str) -> String {
let start = format!("tool-{}-start", marker); let start = format!("tool-{marker}-start");
let end = format!("tool-{}-end", marker); let end = format!("tool-{marker}-end");
let mut lines = Vec::new(); let mut lines = Vec::new();
let mut omitted = false; let mut omitted = false;
for line in contents.lines() { for line in contents.lines() {
@ -1862,7 +1862,7 @@ impl Step for Extended {
builder.install(&etc.join("gfx/banner.bmp"), &exe, 0o644); builder.install(&etc.join("gfx/banner.bmp"), &exe, 0o644);
builder.install(&etc.join("gfx/dialogbg.bmp"), &exe, 0o644); builder.install(&etc.join("gfx/dialogbg.bmp"), &exe, 0o644);
builder.info(&format!("building `msi` installer with {:?}", light)); builder.info(&format!("building `msi` installer with {light:?}"));
let filename = format!("{}-{}.msi", pkgname(builder, "rust"), target.triple); let filename = format!("{}-{}.msi", pkgname(builder, "rust"), target.triple);
let mut cmd = Command::new(&light); let mut cmd = Command::new(&light);
cmd.arg("-nologo") cmd.arg("-nologo")
@ -1996,7 +1996,7 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
{ {
let mut cmd = Command::new(llvm_config); let mut cmd = Command::new(llvm_config);
cmd.arg("--libfiles"); cmd.arg("--libfiles");
builder.verbose(&format!("running {:?}", cmd)); builder.verbose(&format!("running {cmd:?}"));
let files = if builder.config.dry_run() { "".into() } else { output(&mut cmd) }; let files = if builder.config.dry_run() { "".into() } else { output(&mut cmd) };
let build_llvm_out = &builder.llvm_out(builder.config.build); let build_llvm_out = &builder.llvm_out(builder.config.build);
let target_llvm_out = &builder.llvm_out(target); let target_llvm_out = &builder.llvm_out(target);
@ -2175,7 +2175,7 @@ impl Step for LlvmTools {
/* run only if llvm-config isn't used */ /* run only if llvm-config isn't used */
if let Some(config) = builder.config.target_config.get(&target) { if let Some(config) = builder.config.target_config.get(&target) {
if let Some(ref _s) = config.llvm_config { if let Some(ref _s) = config.llvm_config {
builder.info(&format!("Skipping LlvmTools ({}): external LLVM", target)); builder.info(&format!("Skipping LlvmTools ({target}): external LLVM"));
return None; return None;
} }
} }
@ -2231,7 +2231,7 @@ impl Step for RustDev {
/* run only if llvm-config isn't used */ /* run only if llvm-config isn't used */
if let Some(config) = builder.config.target_config.get(&target) { if let Some(config) = builder.config.target_config.get(&target) {
if let Some(ref _s) = config.llvm_config { if let Some(ref _s) = config.llvm_config {
builder.info(&format!("Skipping RustDev ({}): external LLVM", target)); builder.info(&format!("Skipping RustDev ({target}): external LLVM"));
return None; return None;
} }
} }

View file

@ -147,7 +147,7 @@ impl<P: Step> Step for RustbookSrc<P> {
if !builder.config.dry_run() && !(up_to_date(&src, &index) || up_to_date(&rustbook, &index)) if !builder.config.dry_run() && !(up_to_date(&src, &index) || up_to_date(&rustbook, &index))
{ {
builder.info(&format!("Rustbook ({}) - {}", target, name)); builder.info(&format!("Rustbook ({target}) - {name}"));
let _ = fs::remove_dir_all(&out); let _ = fs::remove_dir_all(&out);
builder.run(rustbook_cmd.arg("build").arg(&src).arg("-d").arg(out)); builder.run(rustbook_cmd.arg("build").arg(&src).arg("-d").arg(out));
@ -219,7 +219,7 @@ impl Step for TheBook {
for edition in &["first-edition", "second-edition", "2018-edition"] { for edition in &["first-edition", "second-edition", "2018-edition"] {
builder.ensure(RustbookSrc { builder.ensure(RustbookSrc {
target, target,
name: INTERNER.intern_string(format!("book/{}", edition)), name: INTERNER.intern_string(format!("book/{edition}")),
src: INTERNER.intern_path(absolute_path.join(edition)), src: INTERNER.intern_path(absolute_path.join(edition)),
// There should only be one book that is marked as the parent for each target, so // There should only be one book that is marked as the parent for each target, so
// treat the other editions as not having a parent. // treat the other editions as not having a parent.
@ -966,7 +966,7 @@ impl Step for UnstableBookGen {
fn run(self, builder: &Builder<'_>) { fn run(self, builder: &Builder<'_>) {
let target = self.target; let target = self.target;
builder.info(&format!("Generating unstable book md files ({})", target)); builder.info(&format!("Generating unstable book md files ({target})"));
let out = builder.md_doc_out(target).join("unstable-book"); let out = builder.md_doc_out(target).join("unstable-book");
builder.create_dir(&out); builder.create_dir(&out);
builder.remove_dir(&out); builder.remove_dir(&out);

View file

@ -64,7 +64,7 @@ impl Config {
if self.dry_run() { if self.dry_run() {
return true; return true;
} }
self.verbose(&format!("running: {:?}", cmd)); self.verbose(&format!("running: {cmd:?}"));
check_run(cmd, self.is_verbose()) check_run(cmd, self.is_verbose())
} }
@ -206,7 +206,7 @@ impl Config {
} }
fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) { fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) {
println!("downloading {}", url); println!("downloading {url}");
// Try curl. If that fails and we are on windows, fallback to PowerShell. // Try curl. If that fails and we are on windows, fallback to PowerShell.
let mut curl = Command::new("curl"); let mut curl = Command::new("curl");
curl.args(&[ curl.args(&[
@ -248,7 +248,7 @@ impl Config {
} }
} }
if !help_on_error.is_empty() { if !help_on_error.is_empty() {
eprintln!("{}", help_on_error); eprintln!("{help_on_error}");
} }
crate::exit!(1); crate::exit!(1);
} }
@ -646,7 +646,7 @@ download-rustc = false
fn download_ci_llvm(&self, llvm_sha: &str) { fn download_ci_llvm(&self, llvm_sha: &str) {
let llvm_assertions = self.llvm_assertions; let llvm_assertions = self.llvm_assertions;
let cache_prefix = format!("llvm-{}-{}", llvm_sha, llvm_assertions); let cache_prefix = format!("llvm-{llvm_sha}-{llvm_assertions}");
let cache_dst = self.out.join("cache"); let cache_dst = self.out.join("cache");
let rustc_cache = cache_dst.join(cache_prefix); let rustc_cache = cache_dst.join(cache_prefix);
if !rustc_cache.exists() { if !rustc_cache.exists() {

View file

@ -189,7 +189,7 @@ impl Flags {
let build = Build::new(config); let build = Build::new(config);
let paths = Builder::get_help(&build, subcommand); let paths = Builder::get_help(&build, subcommand);
if let Some(s) = paths { if let Some(s) = paths {
println!("{}", s); println!("{s}");
} else { } else {
panic!("No paths available for subcommand `{}`", subcommand.as_str()); panic!("No paths available for subcommand `{}`", subcommand.as_str());
} }

View file

@ -22,7 +22,7 @@ fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl F
cmd.arg("--check"); cmd.arg("--check");
} }
cmd.args(paths); cmd.args(paths);
let cmd_debug = format!("{:?}", cmd); let cmd_debug = format!("{cmd:?}");
let mut cmd = cmd.spawn().expect("running rustfmt"); 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 { move |block: bool| -> bool {
@ -115,7 +115,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
let rustfmt_config: RustfmtConfig = t!(toml::from_str(&rustfmt_config)); let rustfmt_config: RustfmtConfig = t!(toml::from_str(&rustfmt_config));
let mut ignore_fmt = ignore::overrides::OverrideBuilder::new(&build.src); let mut ignore_fmt = ignore::overrides::OverrideBuilder::new(&build.src);
for ignore in rustfmt_config.ignore { for ignore in rustfmt_config.ignore {
ignore_fmt.add(&format!("!{}", ignore)).expect(&ignore); ignore_fmt.add(&format!("!{ignore}")).expect(&ignore);
} }
let git_available = match Command::new("git") let git_available = match Command::new("git")
.arg("--version") .arg("--version")
@ -153,13 +153,13 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
entry.split(' ').nth(1).expect("every git status entry should list a path") entry.split(' ').nth(1).expect("every git status entry should list a path")
}); });
for untracked_path in untracked_paths { for untracked_path in untracked_paths {
println!("skip untracked path {} during rustfmt invocations", untracked_path); println!("skip untracked path {untracked_path} during rustfmt invocations");
// The leading `/` makes it an exact match against the // The leading `/` makes it an exact match against the
// repository root, rather than a glob. Without that, if you // repository root, rather than a glob. Without that, if you
// have `foo.rs` in the repository root it will also match // have `foo.rs` in the repository root it will also match
// against anything like `compiler/rustc_foo/src/foo.rs`, // against anything like `compiler/rustc_foo/src/foo.rs`,
// preventing the latter from being formatted. // preventing the latter from being formatted.
ignore_fmt.add(&format!("!/{}", untracked_path)).expect(&untracked_path); ignore_fmt.add(&format!("!/{untracked_path}")).expect(&untracked_path);
} }
// Only check modified files locally to speed up runtime. // 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 still check all files in CI to avoid bugs in `get_modified_rs_files` letting regressions slip through;

View file

@ -484,7 +484,7 @@ impl Build {
.unwrap() .unwrap()
.trim(); .trim();
if local_release.split('.').take(2).eq(version.split('.').take(2)) { if local_release.split('.').take(2).eq(version.split('.').take(2)) {
build.verbose(&format!("auto-detected local-rebuild {}", local_release)); build.verbose(&format!("auto-detected local-rebuild {local_release}"));
build.local_rebuild = true; build.local_rebuild = true;
} }
@ -713,7 +713,7 @@ impl Build {
if failures.len() > 0 { if failures.len() > 0 {
eprintln!("\n{} command(s) did not execute successfully:\n", failures.len()); eprintln!("\n{} command(s) did not execute successfully:\n", failures.len());
for failure in failures.iter() { for failure in failures.iter() {
eprintln!(" - {}\n", failure); eprintln!(" - {failure}\n");
} }
exit!(1); exit!(1);
} }
@ -959,7 +959,7 @@ impl Build {
if self.config.dry_run() { if self.config.dry_run() {
return; return;
} }
self.verbose(&format!("running: {:?}", cmd)); self.verbose(&format!("running: {cmd:?}"));
run(cmd, self.is_verbose()) run(cmd, self.is_verbose())
} }
@ -968,7 +968,7 @@ impl Build {
if self.config.dry_run() { if self.config.dry_run() {
return; return;
} }
self.verbose(&format!("running: {:?}", cmd)); self.verbose(&format!("running: {cmd:?}"));
run_suppressed(cmd) run_suppressed(cmd)
} }
@ -980,10 +980,10 @@ impl Build {
return true; return true;
} }
if !self.fail_fast { if !self.fail_fast {
self.verbose(&format!("running: {:?}", cmd)); self.verbose(&format!("running: {cmd:?}"));
if !try_run_suppressed(cmd) { if !try_run_suppressed(cmd) {
let mut failures = self.delayed_failures.borrow_mut(); let mut failures = self.delayed_failures.borrow_mut();
failures.push(format!("{:?}", cmd)); failures.push(format!("{cmd:?}"));
return false; return false;
} }
} else { } else {
@ -998,7 +998,7 @@ impl Build {
#[allow(deprecated)] // can't use Build::try_run, that's us #[allow(deprecated)] // can't use Build::try_run, that's us
if self.config.try_run(cmd).is_err() { if self.config.try_run(cmd).is_err() {
let mut failures = self.delayed_failures.borrow_mut(); let mut failures = self.delayed_failures.borrow_mut();
failures.push(format!("{:?}", cmd)); failures.push(format!("{cmd:?}"));
return false; return false;
} }
} else { } else {
@ -1014,7 +1014,7 @@ impl Build {
/// Prints a message if this build is configured in more verbose mode than `level`. /// Prints a message if this build is configured in more verbose mode than `level`.
fn verbose_than(&self, level: usize, msg: &str) { fn verbose_than(&self, level: usize, msg: &str) {
if self.is_verbose_than(level) { if self.is_verbose_than(level) {
println!("{}", msg); println!("{msg}");
} }
} }
@ -1022,7 +1022,7 @@ impl Build {
match self.config.dry_run { match self.config.dry_run {
DryRun::SelfCheck => return, DryRun::SelfCheck => return,
DryRun::Disabled | DryRun::UserSelected => { DryRun::Disabled | DryRun::UserSelected => {
println!("{}", msg); println!("{msg}");
} }
} }
} }
@ -1147,7 +1147,7 @@ impl Build {
match which { match which {
GitRepo::Rustc => { GitRepo::Rustc => {
let sha = self.rust_sha().unwrap_or(&self.version); let sha = self.rust_sha().unwrap_or(&self.version);
Some(format!("/rustc/{}", sha)) Some(format!("/rustc/{sha}"))
} }
GitRepo::Llvm => Some(String::from("/rustc/llvm")), GitRepo::Llvm => Some(String::from("/rustc/llvm")),
} }
@ -1200,10 +1200,10 @@ impl Build {
let map = format!("{}={}", self.src.display(), map_to); let map = format!("{}={}", self.src.display(), map_to);
let cc = self.cc(target); let cc = self.cc(target);
if cc.ends_with("clang") || cc.ends_with("gcc") { if cc.ends_with("clang") || cc.ends_with("gcc") {
base.push(format!("-fdebug-prefix-map={}", map)); base.push(format!("-fdebug-prefix-map={map}"));
} else if cc.ends_with("clang-cl.exe") { } else if cc.ends_with("clang-cl.exe") {
base.push("-Xclang".into()); base.push("-Xclang".into());
base.push(format!("-fdebug-prefix-map={}", map)); base.push(format!("-fdebug-prefix-map={map}"));
} }
} }
base base
@ -1232,9 +1232,7 @@ impl Build {
} }
match self.cxx.borrow().get(&target) { match self.cxx.borrow().get(&target) {
Some(p) => Ok(p.path().into()), Some(p) => Ok(p.path().into()),
None => { None => Err(format!("target `{target}` is not configured as a host, only as a target")),
Err(format!("target `{}` is not configured as a host, only as a target", target))
}
} }
} }
@ -1277,7 +1275,7 @@ impl Build {
} }
let no_threads = util::lld_flag_no_threads(target.contains("windows")); let no_threads = util::lld_flag_no_threads(target.contains("windows"));
options[1] = Some(format!("-Clink-arg=-Wl,{}", no_threads)); options[1] = Some(format!("-Clink-arg=-Wl,{no_threads}"));
} }
IntoIterator::into_iter(options).flatten() IntoIterator::into_iter(options).flatten()
@ -1404,11 +1402,11 @@ impl Build {
if !self.config.omit_git_hash { if !self.config.omit_git_hash {
format!("{}-beta.{}", num, self.beta_prerelease_version()) format!("{}-beta.{}", num, self.beta_prerelease_version())
} else { } else {
format!("{}-beta", num) format!("{num}-beta")
} }
} }
"nightly" => format!("{}-nightly", num), "nightly" => format!("{num}-nightly"),
_ => format!("{}-dev", num), _ => format!("{num}-dev"),
} }
} }
@ -1456,7 +1454,7 @@ impl Build {
"stable" => num.to_string(), "stable" => num.to_string(),
"beta" => "beta".to_string(), "beta" => "beta".to_string(),
"nightly" => "nightly".to_string(), "nightly" => "nightly".to_string(),
_ => format!("{}-dev", num), _ => format!("{num}-dev"),
} }
} }
@ -1487,7 +1485,7 @@ impl Build {
/// Returns the `a.b.c` version that the given package is at. /// Returns the `a.b.c` version that the given package is at.
fn release_num(&self, package: &str) -> String { fn release_num(&self, package: &str) -> String {
let toml_file_name = self.src.join(&format!("src/tools/{}/Cargo.toml", package)); let toml_file_name = self.src.join(&format!("src/tools/{package}/Cargo.toml"));
let toml = t!(fs::read_to_string(&toml_file_name)); let toml = t!(fs::read_to_string(&toml_file_name));
for line in toml.lines() { for line in toml.lines() {
if let Some(stripped) = if let Some(stripped) =
@ -1497,7 +1495,7 @@ impl Build {
} }
} }
panic!("failed to find version in {}'s Cargo.toml", package) panic!("failed to find version in {package}'s Cargo.toml")
} }
/// Returns `true` if unstable features should be enabled for the compiler /// Returns `true` if unstable features should be enabled for the compiler
@ -1589,7 +1587,7 @@ impl Build {
if self.config.dry_run() { if self.config.dry_run() {
return; return;
} }
self.verbose_than(1, &format!("Copy {:?} to {:?}", src, dst)); self.verbose_than(1, &format!("Copy {src:?} to {dst:?}"));
if src == dst { if src == dst {
return; return;
} }
@ -1680,7 +1678,7 @@ impl Build {
return; return;
} }
let dst = dstdir.join(src.file_name().unwrap()); let dst = dstdir.join(src.file_name().unwrap());
self.verbose_than(1, &format!("Install {:?} to {:?}", src, dst)); self.verbose_than(1, &format!("Install {src:?} to {dst:?}"));
t!(fs::create_dir_all(dstdir)); t!(fs::create_dir_all(dstdir));
if !src.exists() { if !src.exists() {
panic!("Error: File \"{}\" not found!", src.display()); panic!("Error: File \"{}\" not found!", src.display());
@ -1714,7 +1712,7 @@ impl Build {
let iter = match fs::read_dir(dir) { let iter = match fs::read_dir(dir) {
Ok(v) => v, Ok(v) => v,
Err(_) if self.config.dry_run() => return vec![].into_iter(), Err(_) if self.config.dry_run() => return vec![].into_iter(),
Err(err) => panic!("could not read dir {:?}: {:?}", dir, err), Err(err) => panic!("could not read dir {dir:?}: {err:?}"),
}; };
iter.map(|e| t!(e)).collect::<Vec<_>>().into_iter() iter.map(|e| t!(e)).collect::<Vec<_>>().into_iter()
} }

View file

@ -500,8 +500,8 @@ impl Step for Llvm {
let version = output(cmd.arg("--version")); let version = output(cmd.arg("--version"));
let major = version.split('.').next().unwrap(); let major = version.split('.').next().unwrap();
let lib_name = match llvm_version_suffix { let lib_name = match llvm_version_suffix {
Some(s) => format!("libLLVM-{}{}.dylib", major, s), Some(s) => format!("libLLVM-{major}{s}.dylib"),
None => format!("libLLVM-{}.dylib", major), None => format!("libLLVM-{major}.dylib"),
}; };
let lib_llvm = out_dir.join("build").join("lib").join(lib_name); let lib_llvm = out_dir.join("build").join("lib").join(lib_name);
@ -529,7 +529,7 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
return; return;
} }
} }
panic!("\n\nbad LLVM version: {}, need >=15.0\n\n", version) panic!("\n\nbad LLVM version: {version}, need >=15.0\n\n")
} }
fn configure_cmake( fn configure_cmake(
@ -686,10 +686,10 @@ fn configure_cmake(
} }
} }
if builder.config.llvm_clang_cl.is_some() { if builder.config.llvm_clang_cl.is_some() {
cflags.push(&format!(" --target={}", target)); cflags.push(&format!(" --target={target}"));
} }
for flag in extra_compiler_flags { for flag in extra_compiler_flags {
cflags.push(&format!(" {}", flag)); cflags.push(&format!(" {flag}"));
} }
cfg.define("CMAKE_C_FLAGS", cflags); cfg.define("CMAKE_C_FLAGS", cflags);
let mut cxxflags: OsString = builder.cflags(target, GitRepo::Llvm, CLang::Cxx).join(" ").into(); let mut cxxflags: OsString = builder.cflags(target, GitRepo::Llvm, CLang::Cxx).join(" ").into();
@ -698,10 +698,10 @@ fn configure_cmake(
cxxflags.push(s); cxxflags.push(s);
} }
if builder.config.llvm_clang_cl.is_some() { if builder.config.llvm_clang_cl.is_some() {
cxxflags.push(&format!(" --target={}", target)); cxxflags.push(&format!(" --target={target}"));
} }
for flag in extra_compiler_flags { for flag in extra_compiler_flags {
cxxflags.push(&format!(" {}", flag)); cxxflags.push(&format!(" {flag}"));
} }
cfg.define("CMAKE_CXX_FLAGS", cxxflags); cfg.define("CMAKE_CXX_FLAGS", cxxflags);
if let Some(ar) = builder.ar(target) { if let Some(ar) = builder.ar(target) {
@ -772,7 +772,7 @@ fn configure_llvm(builder: &Builder<'_>, target: TargetSelection, cfg: &mut cmak
fn get_var(var_base: &str, host: &str, target: &str) -> Option<OsString> { fn get_var(var_base: &str, host: &str, target: &str) -> Option<OsString> {
let kind = if host == target { "HOST" } else { "TARGET" }; let kind = if host == target { "HOST" } else { "TARGET" };
let target_u = target.replace("-", "_"); let target_u = target.replace("-", "_");
env::var_os(&format!("{}_{}", var_base, target)) env::var_os(&format!("{var_base}_{target}"))
.or_else(|| env::var_os(&format!("{}_{}", var_base, target_u))) .or_else(|| env::var_os(&format!("{}_{}", var_base, target_u)))
.or_else(|| env::var_os(&format!("{}_{}", kind, var_base))) .or_else(|| env::var_os(&format!("{}_{}", kind, var_base)))
.or_else(|| env::var_os(var_base)) .or_else(|| env::var_os(var_base))

View file

@ -188,7 +188,7 @@ than building it.
// Externally configured LLVM requires FileCheck to exist // Externally configured LLVM requires FileCheck to exist
let filecheck = build.llvm_filecheck(build.build); let filecheck = build.llvm_filecheck(build.build);
if !filecheck.starts_with(&build.out) && !filecheck.exists() && build.config.codegen_tests { if !filecheck.starts_with(&build.out) && !filecheck.exists() && build.config.codegen_tests {
panic!("FileCheck executable {:?} does not exist", filecheck); panic!("FileCheck executable {filecheck:?} does not exist");
} }
} }

View file

@ -92,7 +92,7 @@ impl FromStr for Profile {
Ok(Profile::Tools) Ok(Profile::Tools)
} }
"none" => Ok(Profile::None), "none" => Ok(Profile::None),
_ => Err(format!("unknown profile: '{}'", s)), _ => Err(format!("unknown profile: '{s}'")),
} }
} }
} }
@ -167,7 +167,7 @@ pub fn setup(config: &Config, profile: Profile) {
println!("To get started, try one of the following commands:"); println!("To get started, try one of the following commands:");
for cmd in suggestions { for cmd in suggestions {
println!("- `x.py {}`", cmd); println!("- `x.py {cmd}`");
} }
if profile != Profile::Dist { if profile != Profile::Dist {
@ -208,9 +208,8 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) {
let settings = format!( let settings = format!(
"# Includes one of the default files in src/bootstrap/defaults\n\ "# Includes one of the default files in src/bootstrap/defaults\n\
profile = \"{}\"\n\ profile = \"{profile}\"\n\
changelog-seen = {}\n", changelog-seen = {VERSION}\n"
profile, VERSION
); );
t!(fs::write(path, settings)); t!(fs::write(path, settings));
@ -341,7 +340,7 @@ fn ensure_stage1_toolchain_placeholder_exists(stage_path: &str) -> bool {
return false; return false;
}; };
let pathbuf = pathbuf.join(format!("rustc{}", EXE_SUFFIX)); let pathbuf = pathbuf.join(format!("rustc{EXE_SUFFIX}"));
if pathbuf.exists() { if pathbuf.exists() {
return true; return true;
@ -394,7 +393,7 @@ pub fn interactive_path() -> io::Result<Profile> {
break match parse_with_abbrev(&input) { break match parse_with_abbrev(&input) {
Ok(profile) => profile, Ok(profile) => profile,
Err(err) => { Err(err) => {
eprintln!("error: {}", err); eprintln!("error: {err}");
eprintln!("note: press Ctrl+C to exit"); eprintln!("note: press Ctrl+C to exit");
continue; continue;
} }

View file

@ -309,7 +309,7 @@ impl<'a> Tarball<'a> {
let mut cmd = self.builder.tool_cmd(crate::tool::Tool::RustInstaller); let mut cmd = self.builder.tool_cmd(crate::tool::Tool::RustInstaller);
let package_name = self.package_name(); let package_name = self.package_name();
self.builder.info(&format!("Dist {}", package_name)); self.builder.info(&format!("Dist {package_name}"));
let _time = crate::util::timeit(self.builder); let _time = crate::util::timeit(self.builder);
build_cli(&self, &mut cmd); build_cli(&self, &mut cmd);
@ -344,7 +344,7 @@ impl<'a> Tarball<'a> {
.unwrap_or("gz"); .unwrap_or("gz");
GeneratedTarball { GeneratedTarball {
path: crate::dist::distdir(self.builder).join(format!("{}.tar.{}", package_name, ext)), path: crate::dist::distdir(self.builder).join(format!("{package_name}.tar.{ext}")),
decompressed_output, decompressed_output,
work: self.temp_dir, work: self.temp_dir,
} }

View file

@ -126,7 +126,7 @@ You can skip linkcheck with --exclude src/tools/linkchecker"
); );
} }
builder.info(&format!("Linkcheck ({})", host)); builder.info(&format!("Linkcheck ({host})"));
// Test the linkchecker itself. // Test the linkchecker itself.
let bootstrap_host = builder.config.build; let bootstrap_host = builder.config.build;
@ -557,7 +557,7 @@ impl Miri {
if builder.config.dry_run() { if builder.config.dry_run() {
String::new() String::new()
} else { } else {
builder.verbose(&format!("running: {:?}", cargo)); builder.verbose(&format!("running: {cargo:?}"));
let out = let out =
cargo.output().expect("We already ran `cargo miri setup` before and that worked"); cargo.output().expect("We already ran `cargo miri setup` before and that worked");
assert!(out.status.success(), "`cargo miri setup` returned with non-0 exit code"); assert!(out.status.success(), "`cargo miri setup` returned with non-0 exit code");
@ -565,7 +565,7 @@ impl Miri {
let stdout = String::from_utf8(out.stdout) let stdout = String::from_utf8(out.stdout)
.expect("`cargo miri setup` stdout is not valid UTF-8"); .expect("`cargo miri setup` stdout is not valid UTF-8");
let sysroot = stdout.trim_end(); let sysroot = stdout.trim_end();
builder.verbose(&format!("`cargo miri setup --print-sysroot` said: {:?}", sysroot)); builder.verbose(&format!("`cargo miri setup --print-sysroot` said: {sysroot:?}"));
sysroot.to_owned() sysroot.to_owned()
} }
} }
@ -2580,7 +2580,7 @@ impl Step for RemoteCopyLibs {
builder.ensure(compile::Std::new(compiler, target)); builder.ensure(compile::Std::new(compiler, target));
builder.info(&format!("REMOTE copy libs to emulator ({})", target)); builder.info(&format!("REMOTE copy libs to emulator ({target})"));
let server = builder.ensure(tool::RemoteTestServer { compiler, target }); let server = builder.ensure(tool::RemoteTestServer { compiler, target });

View file

@ -83,13 +83,13 @@ static NIGHTLY_TOOLS: &[(&str, &str)] = &[
fn print_error(tool: &str, submodule: &str) { fn print_error(tool: &str, submodule: &str) {
eprintln!(); eprintln!();
eprintln!("We detected that this PR updated '{}', but its tests failed.", tool); eprintln!("We detected that this PR updated '{tool}', but its tests failed.");
eprintln!(); eprintln!();
eprintln!("If you do intend to update '{}', please check the error messages above and", tool); eprintln!("If you do intend to update '{tool}', please check the error messages above and");
eprintln!("commit another update."); eprintln!("commit another update.");
eprintln!(); eprintln!();
eprintln!("If you do NOT intend to update '{}', please ensure you did not accidentally", tool); eprintln!("If you do NOT intend to update '{tool}', please ensure you did not accidentally");
eprintln!("change the submodule at '{}'. You may ask your reviewer for the", submodule); eprintln!("change the submodule at '{submodule}'. You may ask your reviewer for the");
eprintln!("proper steps."); eprintln!("proper steps.");
crate::exit!(3); crate::exit!(3);
} }
@ -105,7 +105,7 @@ fn check_changed_files(toolstates: &HashMap<Box<str>, ToolState>) {
let output = match output { let output = match output {
Ok(o) => o, Ok(o) => o,
Err(e) => { Err(e) => {
eprintln!("Failed to get changed files: {:?}", e); eprintln!("Failed to get changed files: {e:?}");
crate::exit!(1); crate::exit!(1);
} }
}; };
@ -114,12 +114,12 @@ fn check_changed_files(toolstates: &HashMap<Box<str>, ToolState>) {
for (tool, submodule) in STABLE_TOOLS.iter().chain(NIGHTLY_TOOLS.iter()) { for (tool, submodule) in STABLE_TOOLS.iter().chain(NIGHTLY_TOOLS.iter()) {
let changed = output.lines().any(|l| l.starts_with('M') && l.ends_with(submodule)); let changed = output.lines().any(|l| l.starts_with('M') && l.ends_with(submodule));
eprintln!("Verifying status of {}...", tool); eprintln!("Verifying status of {tool}...");
if !changed { if !changed {
continue; continue;
} }
eprintln!("This PR updated '{}', verifying if status is 'test-pass'...", submodule); eprintln!("This PR updated '{submodule}', verifying if status is 'test-pass'...");
if toolstates[*tool] != ToolState::TestPass { if toolstates[*tool] != ToolState::TestPass {
print_error(tool, submodule); print_error(tool, submodule);
} }
@ -172,7 +172,7 @@ impl Step for ToolStateCheck {
for (tool, _) in STABLE_TOOLS.iter().chain(NIGHTLY_TOOLS.iter()) { for (tool, _) in STABLE_TOOLS.iter().chain(NIGHTLY_TOOLS.iter()) {
if !toolstates.contains_key(*tool) { if !toolstates.contains_key(*tool) {
did_error = true; did_error = true;
eprintln!("error: Tool `{}` was not recorded in tool state.", tool); eprintln!("error: Tool `{tool}` was not recorded in tool state.");
} }
} }
@ -190,7 +190,7 @@ impl Step for ToolStateCheck {
if state != ToolState::TestPass { if state != ToolState::TestPass {
if !is_nightly { if !is_nightly {
did_error = true; did_error = true;
eprintln!("error: Tool `{}` should be test-pass but is {}", tool, state); eprintln!("error: Tool `{tool}` should be test-pass but is {state}");
} else if in_beta_week { } else if in_beta_week {
let old_state = old_toolstate let old_state = old_toolstate
.iter() .iter()
@ -200,17 +200,15 @@ impl Step for ToolStateCheck {
if state < old_state { if state < old_state {
did_error = true; did_error = true;
eprintln!( eprintln!(
"error: Tool `{}` has regressed from {} to {} during beta week.", "error: Tool `{tool}` has regressed from {old_state} to {state} during beta week."
tool, old_state, state
); );
} else { } else {
// This warning only appears in the logs, which most // This warning only appears in the logs, which most
// people won't read. It's mostly here for testing and // people won't read. It's mostly here for testing and
// debugging. // debugging.
eprintln!( eprintln!(
"warning: Tool `{}` is not test-pass (is `{}`), \ "warning: Tool `{tool}` is not test-pass (is `{state}`), \
this should be fixed before beta is branched.", this should be fixed before beta is branched."
tool, state
); );
} }
} }
@ -323,7 +321,7 @@ fn checkout_toolstate_repo() {
Err(_) => false, Err(_) => false,
}; };
if !success { if !success {
panic!("git clone unsuccessful (status: {:?})", status); panic!("git clone unsuccessful (status: {status:?})");
} }
} }
@ -336,7 +334,7 @@ fn prepare_toolstate_config(token: &str) {
Err(_) => false, Err(_) => false,
}; };
if !success { if !success {
panic!("git config key={} value={} failed (status: {:?})", key, value, status); panic!("git config key={key} value={value} failed (status: {status:?})");
} }
} }
@ -346,7 +344,7 @@ fn prepare_toolstate_config(token: &str) {
git_config("user.name", "Rust Toolstate Update"); git_config("user.name", "Rust Toolstate Update");
git_config("credential.helper", "store"); git_config("credential.helper", "store");
let credential = format!("https://{}:x-oauth-basic@github.com\n", token,); let credential = format!("https://{token}:x-oauth-basic@github.com\n",);
let git_credential_path = PathBuf::from(t!(env::var("HOME"))).join(".git-credentials"); let git_credential_path = PathBuf::from(t!(env::var("HOME"))).join(".git-credentials");
t!(fs::write(&git_credential_path, credential)); t!(fs::write(&git_credential_path, credential));
} }

View file

@ -46,9 +46,9 @@ pub use t;
/// executable for a particular target. /// executable for a particular target.
pub fn exe(name: &str, target: TargetSelection) -> String { pub fn exe(name: &str, target: TargetSelection) -> String {
if target.contains("windows") { if target.contains("windows") {
format!("{}.exe", name) format!("{name}.exe")
} else if target.contains("uefi") { } else if target.contains("uefi") {
format!("{}.efi", name) format!("{name}.efi")
} else { } else {
name.to_string() name.to_string()
} }
@ -161,9 +161,8 @@ pub fn forcing_clang_based_tests() -> bool {
other => { other => {
// Let's make sure typos don't go unnoticed // Let's make sure typos don't go unnoticed
panic!( panic!(
"Unrecognized option '{}' set in \ "Unrecognized option '{other}' set in \
RUSTBUILD_FORCE_CLANG_BASED_TESTS", RUSTBUILD_FORCE_CLANG_BASED_TESTS"
other
) )
} }
} }
@ -227,15 +226,14 @@ pub fn check_run(cmd: &mut Command, print_cmd_on_fail: bool) -> bool {
let status = match cmd.status() { let status = match cmd.status() {
Ok(status) => status, Ok(status) => status,
Err(e) => { Err(e) => {
println!("failed to execute command: {:?}\nerror: {}", cmd, e); println!("failed to execute command: {cmd:?}\nerror: {e}");
return false; return false;
} }
}; };
if !status.success() && print_cmd_on_fail { if !status.success() && print_cmd_on_fail {
println!( println!(
"\n\ncommand did not execute successfully: {:?}\n\ "\n\ncommand did not execute successfully: {cmd:?}\n\
expected success, got: {}\n\n", expected success, got: {status}\n\n"
cmd, status
); );
} }
status.success() status.success()
@ -250,7 +248,7 @@ pub fn run_suppressed(cmd: &mut Command) {
pub fn try_run_suppressed(cmd: &mut Command) -> bool { pub fn try_run_suppressed(cmd: &mut Command) -> bool {
let output = match cmd.output() { let output = match cmd.output() {
Ok(status) => status, Ok(status) => status,
Err(e) => fail(&format!("failed to execute command: {:?}\nerror: {}", cmd, e)), Err(e) => fail(&format!("failed to execute command: {cmd:?}\nerror: {e}")),
}; };
if !output.status.success() { if !output.status.success() {
println!( println!(
@ -283,7 +281,7 @@ pub fn make(host: &str) -> PathBuf {
pub fn output(cmd: &mut Command) -> String { pub fn output(cmd: &mut Command) -> String {
let output = match cmd.stderr(Stdio::inherit()).output() { let output = match cmd.stderr(Stdio::inherit()).output() {
Ok(status) => status, Ok(status) => status,
Err(e) => fail(&format!("failed to execute command: {:?}\nerror: {}", cmd, e)), Err(e) => fail(&format!("failed to execute command: {cmd:?}\nerror: {e}")),
}; };
if !output.status.success() { if !output.status.success() {
panic!( panic!(
@ -298,7 +296,7 @@ pub fn output(cmd: &mut Command) -> String {
pub fn output_result(cmd: &mut Command) -> Result<String, String> { pub fn output_result(cmd: &mut Command) -> Result<String, String> {
let output = match cmd.stderr(Stdio::inherit()).output() { let output = match cmd.stderr(Stdio::inherit()).output() {
Ok(status) => status, Ok(status) => status,
Err(e) => return Err(format!("failed to run command: {:?}: {}", cmd, e)), Err(e) => return Err(format!("failed to run command: {cmd:?}: {e}")),
}; };
if !output.status.success() { if !output.status.success() {
return Err(format!( return Err(format!(
@ -328,7 +326,7 @@ pub fn up_to_date(src: &Path, dst: &Path) -> bool {
let threshold = mtime(dst); let threshold = mtime(dst);
let meta = match fs::metadata(src) { let meta = match fs::metadata(src) {
Ok(meta) => meta, Ok(meta) => meta,
Err(e) => panic!("source {:?} failed to get metadata: {}", src, e), Err(e) => panic!("source {src:?} failed to get metadata: {e}"),
}; };
if meta.is_dir() { if meta.is_dir() {
dir_up_to_date(src, threshold) dir_up_to_date(src, threshold)