Skip to content
/ rust Public
forked from rust-lang/rust

Commit 483ef5f

Browse files
committed
Auto merge of rust-lang#114066 - matthiaskrgr:fmt_args_inline_bootstrap, r=WaffleLapkin
bootstrap: inline format!() args (0) r? `@WaffleLapkin`
2 parents 4c9ac1e + a0503a8 commit 483ef5f

23 files changed

+162
-174
lines changed

src/bootstrap/bin/main.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn main() {
6767
`cp config.example.toml config.toml`"
6868
);
6969
} else if let Some(suggestion) = &changelog_suggestion {
70-
println!("{}", suggestion);
70+
println!("{suggestion}");
7171
}
7272

7373
let pre_commit = config.src.join(".git").join("hooks").join("pre-commit");
@@ -80,7 +80,7 @@ fn main() {
8080
`cp config.example.toml config.toml`"
8181
);
8282
} else if let Some(suggestion) = &changelog_suggestion {
83-
println!("{}", suggestion);
83+
println!("{suggestion}");
8484
}
8585

8686
// 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> {
107107
let suggestion = if let Some(seen) = config.changelog_seen {
108108
if seen != VERSION {
109109
msg.push_str("warning: there have been changes to x.py since you last updated.\n");
110-
format!("update `config.toml` to use `changelog-seen = {}` instead", VERSION)
110+
format!("update `config.toml` to use `changelog-seen = {VERSION}` instead")
111111
} else {
112112
return None;
113113
}
114114
} else {
115115
msg.push_str("warning: x.py has made several changes recently you may want to look at\n");
116-
format!("add `changelog-seen = {}` at the top of `config.toml`", VERSION)
116+
format!("add `changelog-seen = {VERSION}` at the top of `config.toml`")
117117
};
118118

119119
msg.push_str("help: consider looking at the changes in `src/bootstrap/CHANGELOG.md`\n");

src/bootstrap/bin/rustc.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn main() {
120120

121121
// Override linker if necessary.
122122
if let Ok(host_linker) = env::var("RUSTC_HOST_LINKER") {
123-
cmd.arg(format!("-Clinker={}", host_linker));
123+
cmd.arg(format!("-Clinker={host_linker}"));
124124
}
125125
if env::var_os("RUSTC_HOST_FUSE_LD_LLD").is_some() {
126126
cmd.arg("-Clink-args=-fuse-ld=lld");
@@ -206,11 +206,11 @@ fn main() {
206206
env::vars().filter(|(k, _)| k.starts_with("RUST") || k.starts_with("CARGO"));
207207
let prefix = if is_test { "[RUSTC-SHIM] rustc --test" } else { "[RUSTC-SHIM] rustc" };
208208
let prefix = match crate_name {
209-
Some(crate_name) => format!("{} {}", prefix, crate_name),
209+
Some(crate_name) => format!("{prefix} {crate_name}"),
210210
None => prefix.to_string(),
211211
};
212212
for (i, (k, v)) in rust_env_vars.enumerate() {
213-
eprintln!("{} env[{}]: {:?}={:?}", prefix, i, k, v);
213+
eprintln!("{prefix} env[{i}]: {k:?}={v:?}");
214214
}
215215
eprintln!("{} working directory: {}", prefix, env::current_dir().unwrap().display());
216216
eprintln!(
@@ -220,13 +220,13 @@ fn main() {
220220
env::join_paths(&dylib_path).unwrap(),
221221
cmd,
222222
);
223-
eprintln!("{} sysroot: {:?}", prefix, sysroot);
224-
eprintln!("{} libdir: {:?}", prefix, libdir);
223+
eprintln!("{prefix} sysroot: {sysroot:?}");
224+
eprintln!("{prefix} libdir: {libdir:?}");
225225
}
226226

227227
let start = Instant::now();
228228
let (child, status) = {
229-
let errmsg = format!("\nFailed to run:\n{:?}\n-------------", cmd);
229+
let errmsg = format!("\nFailed to run:\n{cmd:?}\n-------------");
230230
let mut child = cmd.spawn().expect(&errmsg);
231231
let status = child.wait().expect(&errmsg);
232232
(child, status)
@@ -259,7 +259,7 @@ fn main() {
259259
// should run on success, after this block.
260260
}
261261
if verbose > 0 {
262-
println!("\nDid not run successfully: {}\n{:?}\n-------------", status, cmd);
262+
println!("\nDid not run successfully: {status}\n{cmd:?}\n-------------");
263263
}
264264

265265
if let Some(mut on_fail) = on_fail {
@@ -271,7 +271,7 @@ fn main() {
271271
match status.code() {
272272
Some(i) => std::process::exit(i),
273273
None => {
274-
eprintln!("rustc exited with {}", status);
274+
eprintln!("rustc exited with {status}");
275275
std::process::exit(0xfe);
276276
}
277277
}
@@ -396,21 +396,20 @@ fn format_rusage_data(_child: Child) -> Option<String> {
396396
let minflt = rusage.ru_minflt;
397397
let majflt = rusage.ru_majflt;
398398
if minflt != 0 || majflt != 0 {
399-
init_str.push_str(&format!(" page reclaims: {} page faults: {}", minflt, majflt));
399+
init_str.push_str(&format!(" page reclaims: {minflt} page faults: {majflt}"));
400400
}
401401

402402
let inblock = rusage.ru_inblock;
403403
let oublock = rusage.ru_oublock;
404404
if inblock != 0 || oublock != 0 {
405-
init_str.push_str(&format!(" fs block inputs: {} fs block outputs: {}", inblock, oublock));
405+
init_str.push_str(&format!(" fs block inputs: {inblock} fs block outputs: {oublock}"));
406406
}
407407

408408
let nvcsw = rusage.ru_nvcsw;
409409
let nivcsw = rusage.ru_nivcsw;
410410
if nvcsw != 0 || nivcsw != 0 {
411411
init_str.push_str(&format!(
412-
" voluntary ctxt switches: {} involuntary ctxt switches: {}",
413-
nvcsw, nivcsw
412+
" voluntary ctxt switches: {nvcsw} involuntary ctxt switches: {nivcsw}"
414413
));
415414
}
416415

src/bootstrap/bin/rustdoc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn main() {
6262
}
6363
if let Ok(no_threads) = env::var("RUSTDOC_LLD_NO_THREADS") {
6464
cmd.arg("-Clink-arg=-fuse-ld=lld");
65-
cmd.arg(format!("-Clink-arg=-Wl,{}", no_threads));
65+
cmd.arg(format!("-Clink-arg=-Wl,{no_threads}"));
6666
}
6767
// Cargo doesn't pass RUSTDOCFLAGS to proc_macros:
6868
// https://github.com/rust-lang/cargo/issues/4423
@@ -82,12 +82,12 @@ fn main() {
8282
env::join_paths(&dylib_path).unwrap(),
8383
cmd,
8484
);
85-
eprintln!("sysroot: {:?}", sysroot);
86-
eprintln!("libdir: {:?}", libdir);
85+
eprintln!("sysroot: {sysroot:?}");
86+
eprintln!("libdir: {libdir:?}");
8787
}
8888

8989
std::process::exit(match cmd.status() {
9090
Ok(s) => s.code().unwrap_or(1),
91-
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
91+
Err(e) => panic!("\n\nfailed to run {cmd:?}: {e}\n\n"),
9292
})
9393
}

src/bootstrap/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ use std::env;
33
fn main() {
44
let host = env::var("HOST").unwrap();
55
println!("cargo:rerun-if-changed=build.rs");
6-
println!("cargo:rustc-env=BUILD_TRIPLE={}", host);
6+
println!("cargo:rustc-env=BUILD_TRIPLE={host}");
77
}

src/bootstrap/builder.rs

+19-20
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl StepDescription {
319319
fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
320320
if builder.config.exclude.iter().any(|e| pathset.has(&e, builder.kind)) {
321321
if !matches!(builder.config.dry_run, DryRun::SelfCheck) {
322-
println!("Skipping {:?} because it is excluded", pathset);
322+
println!("Skipping {pathset:?} because it is excluded");
323323
}
324324
return true;
325325
}
@@ -473,8 +473,7 @@ impl<'a> ShouldRun<'a> {
473473
// `compiler` and `library` folders respectively.
474474
assert!(
475475
self.kind == Kind::Setup || !self.builder.src.join(alias).exists(),
476-
"use `builder.path()` for real paths: {}",
477-
alias
476+
"use `builder.path()` for real paths: {alias}"
478477
);
479478
self.paths.insert(PathSet::Set(
480479
std::iter::once(TaskPath { path: alias.into(), kind: Some(self.kind) }).collect(),
@@ -1283,7 +1282,7 @@ impl<'a> Builder<'a> {
12831282
out_dir.join(target.triple).join("doc")
12841283
}
12851284
}
1286-
_ => panic!("doc mode {:?} not expected", mode),
1285+
_ => panic!("doc mode {mode:?} not expected"),
12871286
};
12881287
let rustdoc = self.rustdoc(compiler);
12891288
self.clear_if_dirty(&my_out, &rustdoc);
@@ -1637,15 +1636,15 @@ impl<'a> Builder<'a> {
16371636
// so. Note that this is definitely a hack, and we should likely
16381637
// flesh out rpath support more fully in the future.
16391638
rustflags.arg("-Zosx-rpath-install-name");
1640-
Some(format!("-Wl,-rpath,@loader_path/../{}", libdir))
1639+
Some(format!("-Wl,-rpath,@loader_path/../{libdir}"))
16411640
} else if !target.contains("windows") && !target.contains("aix") {
16421641
rustflags.arg("-Clink-args=-Wl,-z,origin");
1643-
Some(format!("-Wl,-rpath,$ORIGIN/../{}", libdir))
1642+
Some(format!("-Wl,-rpath,$ORIGIN/../{libdir}"))
16441643
} else {
16451644
None
16461645
};
16471646
if let Some(rpath) = rpath {
1648-
rustflags.arg(&format!("-Clink-args={}", rpath));
1647+
rustflags.arg(&format!("-Clink-args={rpath}"));
16491648
}
16501649
}
16511650

@@ -1659,7 +1658,7 @@ impl<'a> Builder<'a> {
16591658

16601659
if let Some(target_linker) = self.linker(target) {
16611660
let target = crate::envify(&target.triple);
1662-
cargo.env(&format!("CARGO_TARGET_{}_LINKER", target), target_linker);
1661+
cargo.env(&format!("CARGO_TARGET_{target}_LINKER"), target_linker);
16631662
}
16641663
if self.is_fuse_ld_lld(target) {
16651664
rustflags.arg("-Clink-args=-fuse-ld=lld");
@@ -1895,24 +1894,24 @@ impl<'a> Builder<'a> {
18951894
};
18961895
let triple_underscored = target.triple.replace("-", "_");
18971896
let cc = ccacheify(&self.cc(target));
1898-
cargo.env(format!("CC_{}", triple_underscored), &cc);
1897+
cargo.env(format!("CC_{triple_underscored}"), &cc);
18991898

19001899
let cflags = self.cflags(target, GitRepo::Rustc, CLang::C).join(" ");
1901-
cargo.env(format!("CFLAGS_{}", triple_underscored), &cflags);
1900+
cargo.env(format!("CFLAGS_{triple_underscored}"), &cflags);
19021901

19031902
if let Some(ar) = self.ar(target) {
19041903
let ranlib = format!("{} s", ar.display());
19051904
cargo
1906-
.env(format!("AR_{}", triple_underscored), ar)
1907-
.env(format!("RANLIB_{}", triple_underscored), ranlib);
1905+
.env(format!("AR_{triple_underscored}"), ar)
1906+
.env(format!("RANLIB_{triple_underscored}"), ranlib);
19081907
}
19091908

19101909
if let Ok(cxx) = self.cxx(target) {
19111910
let cxx = ccacheify(&cxx);
19121911
let cxxflags = self.cflags(target, GitRepo::Rustc, CLang::Cxx).join(" ");
19131912
cargo
1914-
.env(format!("CXX_{}", triple_underscored), &cxx)
1915-
.env(format!("CXXFLAGS_{}", triple_underscored), cxxflags);
1913+
.env(format!("CXX_{triple_underscored}"), &cxx)
1914+
.env(format!("CXXFLAGS_{triple_underscored}"), cxxflags);
19161915
}
19171916
}
19181917

@@ -2025,15 +2024,15 @@ impl<'a> Builder<'a> {
20252024
if let Some(limit) = limit {
20262025
if stage == 0 || self.config.default_codegen_backend().unwrap_or_default() == "llvm"
20272026
{
2028-
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={}", limit));
2027+
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={limit}"));
20292028
}
20302029
}
20312030
}
20322031

20332032
if matches!(mode, Mode::Std) {
20342033
if let Some(mir_opt_level) = self.config.rust_validate_mir_opts {
20352034
rustflags.arg("-Zvalidate-mir");
2036-
rustflags.arg(&format!("-Zmir-opt-level={}", mir_opt_level));
2035+
rustflags.arg(&format!("-Zmir-opt-level={mir_opt_level}"));
20372036
}
20382037
// Always enable inlining MIR when building the standard library.
20392038
// Without this flag, MIR inlining is disabled when incremental compilation is enabled.
@@ -2065,9 +2064,9 @@ impl<'a> Builder<'a> {
20652064
continue;
20662065
}
20672066
let mut out = String::new();
2068-
out += &format!("\n\nCycle in build detected when adding {:?}\n", step);
2067+
out += &format!("\n\nCycle in build detected when adding {step:?}\n");
20692068
for el in stack.iter().rev() {
2070-
out += &format!("\t{:?}\n", el);
2069+
out += &format!("\t{el:?}\n");
20712070
}
20722071
panic!("{}", out);
20732072
}
@@ -2094,7 +2093,7 @@ impl<'a> Builder<'a> {
20942093
};
20952094

20962095
if self.config.print_step_timings && !self.config.dry_run() {
2097-
let step_string = format!("{:?}", step);
2096+
let step_string = format!("{step:?}");
20982097
let brace_index = step_string.find("{").unwrap_or(0);
20992098
let type_string = type_name::<S>();
21002099
println!(
@@ -2174,7 +2173,7 @@ impl<'a> Builder<'a> {
21742173
let path = path.as_ref();
21752174
self.info(&format!("Opening doc {}", path.display()));
21762175
if let Err(err) = opener::open(path) {
2177-
self.info(&format!("{}\n", err));
2176+
self.info(&format!("{err}\n"));
21782177
}
21792178
}
21802179
}

src/bootstrap/cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ where
7575
{
7676
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
7777
let s: &U = &*self;
78-
f.write_fmt(format_args!("{:?}", s))
78+
f.write_fmt(format_args!("{s:?}"))
7979
}
8080
}
8181

@@ -236,7 +236,7 @@ impl Cache {
236236
.or_insert_with(|| Box::new(HashMap::<S, S::Output>::new()))
237237
.downcast_mut::<HashMap<S, S::Output>>()
238238
.expect("invalid type mapped");
239-
assert!(!stepcache.contains_key(&step), "processing {:?} a second time", step);
239+
assert!(!stepcache.contains_key(&step), "processing {step:?} a second time");
240240
stepcache.insert(step, value);
241241
}
242242

src/bootstrap/cc_detect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ fn set_compiler(
196196
'0'..='6' => {}
197197
_ => return,
198198
}
199-
let alternative = format!("e{}", gnu_compiler);
199+
let alternative = format!("e{gnu_compiler}");
200200
if Command::new(&alternative).output().is_ok() {
201201
cfg.compiler(alternative);
202202
}

src/bootstrap/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl Step for CodegenBackend {
322322
);
323323
cargo
324324
.arg("--manifest-path")
325-
.arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend)));
325+
.arg(builder.src.join(format!("compiler/rustc_codegen_{backend}/Cargo.toml")));
326326
rustc_cargo_env(builder, &mut cargo, target, compiler.stage);
327327

328328
let _guard = builder.msg_check(&backend, target);
@@ -525,5 +525,5 @@ fn codegen_backend_stamp(
525525
) -> PathBuf {
526526
builder
527527
.cargo_out(compiler, Mode::Codegen, target)
528-
.join(format!(".librustc_codegen_{}-check.stamp", backend))
528+
.join(format!(".librustc_codegen_{backend}-check.stamp"))
529529
}

0 commit comments

Comments
 (0)