Skip to content

Commit aa76aab

Browse files
committed
./x clippy ci --fix
1 parent 41e7396 commit aa76aab

File tree

16 files changed

+39
-40
lines changed

16 files changed

+39
-40
lines changed

src/bootstrap/src/bin/rustc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ fn main() {
5858
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
5959
let on_fail = env::var_os("RUSTC_ON_FAIL").map(Command::new);
6060

61-
let rustc_real = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
62-
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
61+
let rustc_real = env::var_os(rustc).unwrap_or_else(|| panic!("{rustc:?} was not set"));
62+
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{libdir:?} was not set"));
6363
let mut dylib_path = dylib_path();
6464
dylib_path.insert(0, PathBuf::from(&libdir));
6565

src/bootstrap/src/core/build_steps/clean.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn clean_specific_stage(build: &Build, stage: u32) {
129129

130130
for entry in entries {
131131
let entry = t!(entry);
132-
let stage_prefix = format!("stage{}", stage);
132+
let stage_prefix = format!("stage{stage}");
133133

134134
// if current entry is not related with the target stage, continue
135135
if !entry.file_name().to_str().unwrap_or("").contains(&stage_prefix) {

src/bootstrap/src/core/build_steps/clippy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn lint_args(builder: &Builder<'_>, config: &LintConfig, ignored_rules: &[&str])
5959
let all_args = std::env::args().collect::<Vec<_>>();
6060
args.extend(get_clippy_rules_in_order(&all_args, config));
6161

62-
args.extend(ignored_rules.iter().map(|lint| format!("-Aclippy::{}", lint)));
62+
args.extend(ignored_rules.iter().map(|lint| format!("-Aclippy::{lint}")));
6363
args.extend(builder.config.free_args.clone());
6464
args
6565
}

src/bootstrap/src/core/build_steps/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ impl Step for Sysroot {
17711771
} else if builder.download_rustc() && compiler.stage != builder.top_stage {
17721772
host_dir.join("ci-rustc-sysroot")
17731773
} else {
1774-
host_dir.join(format!("stage{}", stage))
1774+
host_dir.join(format!("stage{stage}"))
17751775
}
17761776
};
17771777
let sysroot = sysroot_dir(compiler.stage);

src/bootstrap/src/core/build_steps/dist.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1403,14 +1403,14 @@ impl Step for CodegenBackend {
14031403
let backend = self.backend;
14041404

14051405
let mut tarball =
1406-
Tarball::new(builder, &format!("rustc-codegen-{}", backend), &compiler.host.triple);
1406+
Tarball::new(builder, &format!("rustc-codegen-{backend}"), &compiler.host.triple);
14071407
if backend == "cranelift" {
14081408
tarball.set_overlay(OverlayKind::RustcCodegenCranelift);
14091409
} else {
1410-
panic!("Unknown backend rustc_codegen_{}", backend);
1410+
panic!("Unknown backend rustc_codegen_{backend}");
14111411
}
14121412
tarball.is_preview(true);
1413-
tarball.add_legal_and_readme_to(format!("share/doc/rustc_codegen_{}", backend));
1413+
tarball.add_legal_and_readme_to(format!("share/doc/rustc_codegen_{backend}"));
14141414

14151415
let src = builder.sysroot(compiler);
14161416
let backends_src = builder.sysroot_codegen_backends(compiler);
@@ -1422,7 +1422,7 @@ impl Step for CodegenBackend {
14221422
// Don't use custom libdir here because ^lib/ will be resolved again with installer
14231423
let backends_dst = PathBuf::from("lib").join(backends_rel);
14241424

1425-
let backend_name = format!("rustc_codegen_{}", backend);
1425+
let backend_name = format!("rustc_codegen_{backend}");
14261426
let mut found_backend = false;
14271427
for backend in fs::read_dir(&backends_src).unwrap() {
14281428
let file_name = backend.unwrap().file_name();
@@ -1623,7 +1623,7 @@ impl Step for Extended {
16231623
let pkgbuild = |component: &str| {
16241624
let mut cmd = command("pkgbuild");
16251625
cmd.arg("--identifier")
1626-
.arg(format!("org.rust-lang.{}", component))
1626+
.arg(format!("org.rust-lang.{component}"))
16271627
.arg("--scripts")
16281628
.arg(pkg.join(component))
16291629
.arg("--nopayload")

src/bootstrap/src/core/build_steps/install.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn is_dir_writable_for_user(dir: &Path) -> bool {
5353
if e.kind() == std::io::ErrorKind::PermissionDenied {
5454
false
5555
} else {
56-
panic!("Failed the write access check for the current user. {}", e);
56+
panic!("Failed the write access check for the current user. {e}");
5757
}
5858
}
5959
}

src/bootstrap/src/core/build_steps/llvm.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,8 @@ fn get_var(var_base: &str, host: &str, target: &str) -> Option<OsString> {
870870
let kind = if host == target { "HOST" } else { "TARGET" };
871871
let target_u = target.replace('-', "_");
872872
env::var_os(format!("{var_base}_{target}"))
873-
.or_else(|| env::var_os(format!("{}_{}", var_base, target_u)))
874-
.or_else(|| env::var_os(format!("{}_{}", kind, var_base)))
873+
.or_else(|| env::var_os(format!("{var_base}_{target_u}")))
874+
.or_else(|| env::var_os(format!("{kind}_{var_base}")))
875875
.or_else(|| env::var_os(var_base))
876876
}
877877

@@ -944,7 +944,7 @@ impl Step for Enzyme {
944944
}
945945

946946
trace!(?target, "(re)building enzyme artifacts");
947-
builder.info(&format!("Building Enzyme for {}", target));
947+
builder.info(&format!("Building Enzyme for {target}"));
948948
t!(stamp.remove());
949949
let _time = helpers::timeit(builder);
950950
t!(fs::create_dir_all(&out_dir));
@@ -1229,10 +1229,10 @@ fn supported_sanitizers(
12291229
components
12301230
.iter()
12311231
.map(move |c| SanitizerRuntime {
1232-
cmake_target: format!("clang_rt.{}_{}_dynamic", c, os),
1232+
cmake_target: format!("clang_rt.{c}_{os}_dynamic"),
12331233
path: out_dir
1234-
.join(format!("build/lib/darwin/libclang_rt.{}_{}_dynamic.dylib", c, os)),
1235-
name: format!("librustc-{}_rt.{}.dylib", channel, c),
1234+
.join(format!("build/lib/darwin/libclang_rt.{c}_{os}_dynamic.dylib")),
1235+
name: format!("librustc-{channel}_rt.{c}.dylib"),
12361236
})
12371237
.collect()
12381238
};
@@ -1241,9 +1241,9 @@ fn supported_sanitizers(
12411241
components
12421242
.iter()
12431243
.map(move |c| SanitizerRuntime {
1244-
cmake_target: format!("clang_rt.{}-{}", c, arch),
1245-
path: out_dir.join(format!("build/lib/{}/libclang_rt.{}-{}.a", os, c, arch)),
1246-
name: format!("librustc-{}_rt.{}.a", channel, c),
1244+
cmake_target: format!("clang_rt.{c}-{arch}"),
1245+
path: out_dir.join(format!("build/lib/{os}/libclang_rt.{c}-{arch}.a")),
1246+
name: format!("librustc-{channel}_rt.{c}.a"),
12471247
})
12481248
.collect()
12491249
};
@@ -1362,8 +1362,8 @@ impl Step for CrtBeginEnd {
13621362
for obj in objs {
13631363
let base_name = unhashed_basename(&obj);
13641364
assert!(base_name == "crtbegin" || base_name == "crtend");
1365-
t!(fs::copy(&obj, out_dir.join(format!("{}S.o", base_name))));
1366-
t!(fs::rename(&obj, out_dir.join(format!("{}.o", base_name))));
1365+
t!(fs::copy(&obj, out_dir.join(format!("{base_name}S.o"))));
1366+
t!(fs::rename(&obj, out_dir.join(format!("{base_name}.o"))));
13671367
}
13681368

13691369
out_dir

src/bootstrap/src/core/build_steps/setup.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ Select which editor you would like to set up [default: None]: ";
552552

553553
let mut input = String::new();
554554
loop {
555-
print!("{}", prompt_str);
555+
print!("{prompt_str}");
556556
io::stdout().flush()?;
557557
io::stdin().read_line(&mut input)?;
558558

@@ -764,7 +764,7 @@ fn create_editor_settings_maybe(config: &Config, editor: &EditorKind) -> io::Res
764764
_ => "Created",
765765
};
766766
fs::write(&settings_path, editor.settings_template())?;
767-
println!("{verb} `{}`", settings_filename);
767+
println!("{verb} `{settings_filename}`");
768768
} else {
769769
println!("\n{}", editor.settings_template());
770770
}

src/bootstrap/src/core/build_steps/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1593,10 +1593,10 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
15931593
let build = builder.build.build;
15941594
compiler = builder.compiler(compiler.stage - 1, build);
15951595
let test_stage = compiler.stage + 1;
1596-
(test_stage, format!("stage{}-{}", test_stage, build))
1596+
(test_stage, format!("stage{test_stage}-{build}"))
15971597
} else {
15981598
let stage = compiler.stage;
1599-
(stage, format!("stage{}-{}", stage, target))
1599+
(stage, format!("stage{stage}-{target}"))
16001600
};
16011601

16021602
if suite.ends_with("fulldeps") {

src/bootstrap/src/core/builder/cargo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1278,5 +1278,5 @@ impl Builder<'_> {
12781278

12791279
pub fn cargo_profile_var(name: &str, config: &Config) -> String {
12801280
let profile = if config.rust_optimize.is_release() { "RELEASE" } else { "DEV" };
1281-
format!("CARGO_PROFILE_{}_{}", profile, name)
1281+
format!("CARGO_PROFILE_{profile}_{name}")
12821282
}

src/bootstrap/src/core/builder/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,8 @@ impl StepDescription {
504504
match std::path::absolute(p) {
505505
Ok(p) => p.strip_prefix(&builder.src).unwrap_or(&p).to_path_buf(),
506506
Err(e) => {
507-
eprintln!("ERROR: {:?}", e);
508-
panic!("Due to the above error, failed to resolve path: {:?}", p);
507+
eprintln!("ERROR: {e:?}");
508+
panic!("Due to the above error, failed to resolve path: {p:?}");
509509
}
510510
}
511511
})
@@ -694,8 +694,7 @@ impl<'a> ShouldRun<'a> {
694694
if !submodules_paths.iter().any(|sm_p| p.contains(sm_p)) {
695695
assert!(
696696
self.builder.src.join(p).exists(),
697-
"`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {}",
698-
p
697+
"`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {p}"
699698
);
700699
}
701700

src/bootstrap/src/core/config/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3042,7 +3042,7 @@ impl Config {
30423042
let actual_hash = recorded
30433043
.split_whitespace()
30443044
.nth(2)
3045-
.unwrap_or_else(|| panic!("unexpected output `{}`", recorded));
3045+
.unwrap_or_else(|| panic!("unexpected output `{recorded}`"));
30463046

30473047
if actual_hash == checked_out_hash {
30483048
// already checked out
@@ -3297,7 +3297,7 @@ impl Config {
32973297
}
32983298
StringOrBool::String(s) if s == "if-unchanged" => if_unchanged(),
32993299
StringOrBool::String(other) => {
3300-
panic!("unrecognized option for download-ci-llvm: {:?}", other)
3300+
panic!("unrecognized option for download-ci-llvm: {other:?}")
33013301
}
33023302
}
33033303
}

src/bootstrap/src/core/download.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Config {
5757
if self.dry_run() {
5858
return;
5959
}
60-
fs::remove_file(f).unwrap_or_else(|_| panic!("failed to remove {:?}", f));
60+
fs::remove_file(f).unwrap_or_else(|_| panic!("failed to remove {f:?}"));
6161
}
6262

6363
/// Create a temporary directory in `out` and return its path.
@@ -112,7 +112,7 @@ impl Config {
112112
// The latter one does not exist on NixOS when using tmpfs as root.
113113
let is_nixos = match File::open("/etc/os-release") {
114114
Err(e) if e.kind() == ErrorKind::NotFound => false,
115-
Err(e) => panic!("failed to access /etc/os-release: {}", e),
115+
Err(e) => panic!("failed to access /etc/os-release: {e}"),
116116
Ok(os_release) => BufReader::new(os_release).lines().any(|l| {
117117
let l = l.expect("reading /etc/os-release");
118118
matches!(l.trim(), "ID=nixos" | "ID='nixos'" | "ID=\"nixos\"")

src/bootstrap/src/core/sanity.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ pub fn check(build: &mut Build) {
117117
eprintln!(
118118
"\nYour system's libstdc++ version is too old for the `llvm.download-ci-llvm` option."
119119
);
120-
eprintln!("Current version detected: '{}'", version);
121-
eprintln!("Minimum required version: '{}'", LIBSTDCXX_MIN_VERSION_THRESHOLD);
120+
eprintln!("Current version detected: '{version}'");
121+
eprintln!("Minimum required version: '{LIBSTDCXX_MIN_VERSION_THRESHOLD}'");
122122
eprintln!(
123123
"Consider upgrading libstdc++ or disabling the `llvm.download-ci-llvm` option."
124124
);

src/bootstrap/src/utils/helpers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ pub fn start_process(cmd: &mut Command) -> impl FnOnce() -> String + use<> {
329329
Err(e) => fail(&format!("failed to execute command: {cmd:?}\nERROR: {e}")),
330330
};
331331

332-
let command = format!("{:?}", cmd);
332+
let command = format!("{cmd:?}");
333333

334334
move || {
335335
let output = child.wait_with_output().unwrap();
@@ -540,7 +540,7 @@ where
540540
use std::fmt::Write;
541541

542542
input.as_ref().iter().fold(String::with_capacity(input.as_ref().len() * 2), |mut acc, &byte| {
543-
write!(&mut acc, "{:02x}", byte).expect("Failed to write byte to the hex String.");
543+
write!(&mut acc, "{byte:02x}").expect("Failed to write byte to the hex String.");
544544
acc
545545
})
546546
}

src/bootstrap/src/utils/shared_helpers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn maybe_dump(dump_name: String, cmd: &Command) {
9090

9191
let mut file = OpenOptions::new().create(true).append(true).open(dump_file).unwrap();
9292

93-
let cmd_dump = format!("{:?}\n", cmd);
93+
let cmd_dump = format!("{cmd:?}\n");
9494
let cmd_dump = cmd_dump.replace(&env::var("BUILD_OUT").unwrap(), "${BUILD_OUT}");
9595
let cmd_dump = cmd_dump.replace(&env::var("CARGO_HOME").unwrap(), "${CARGO_HOME}");
9696

0 commit comments

Comments
 (0)