./x clippy ci --fix

This commit is contained in:
Pietro Albini 2025-05-10 10:55:10 +02:00
parent 27cca0db9b
commit 8e4b1c89f4
No known key found for this signature in database
GPG Key ID: 3E06ABE80BAAF19C
16 changed files with 39 additions and 40 deletions

View File

@ -58,8 +58,8 @@ fn main() {
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
let on_fail = env::var_os("RUSTC_ON_FAIL").map(Command::new);
let rustc_real = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
let rustc_real = env::var_os(rustc).unwrap_or_else(|| panic!("{rustc:?} was not set"));
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{libdir:?} was not set"));
let mut dylib_path = dylib_path();
dylib_path.insert(0, PathBuf::from(&libdir));

View File

@ -129,7 +129,7 @@ fn clean_specific_stage(build: &Build, stage: u32) {
for entry in entries {
let entry = t!(entry);
let stage_prefix = format!("stage{}", stage);
let stage_prefix = format!("stage{stage}");
// if current entry is not related with the target stage, continue
if !entry.file_name().to_str().unwrap_or("").contains(&stage_prefix) {

View File

@ -59,7 +59,7 @@ fn lint_args(builder: &Builder<'_>, config: &LintConfig, ignored_rules: &[&str])
let all_args = std::env::args().collect::<Vec<_>>();
args.extend(get_clippy_rules_in_order(&all_args, config));
args.extend(ignored_rules.iter().map(|lint| format!("-Aclippy::{}", lint)));
args.extend(ignored_rules.iter().map(|lint| format!("-Aclippy::{lint}")));
args.extend(builder.config.free_args.clone());
args
}

View File

@ -1771,7 +1771,7 @@ impl Step for Sysroot {
} else if builder.download_rustc() && compiler.stage != builder.top_stage {
host_dir.join("ci-rustc-sysroot")
} else {
host_dir.join(format!("stage{}", stage))
host_dir.join(format!("stage{stage}"))
}
};
let sysroot = sysroot_dir(compiler.stage);

View File

@ -1403,14 +1403,14 @@ impl Step for CodegenBackend {
let backend = self.backend;
let mut tarball =
Tarball::new(builder, &format!("rustc-codegen-{}", backend), &compiler.host.triple);
Tarball::new(builder, &format!("rustc-codegen-{backend}"), &compiler.host.triple);
if backend == "cranelift" {
tarball.set_overlay(OverlayKind::RustcCodegenCranelift);
} else {
panic!("Unknown backend rustc_codegen_{}", backend);
panic!("Unknown backend rustc_codegen_{backend}");
}
tarball.is_preview(true);
tarball.add_legal_and_readme_to(format!("share/doc/rustc_codegen_{}", backend));
tarball.add_legal_and_readme_to(format!("share/doc/rustc_codegen_{backend}"));
let src = builder.sysroot(compiler);
let backends_src = builder.sysroot_codegen_backends(compiler);
@ -1422,7 +1422,7 @@ impl Step for CodegenBackend {
// Don't use custom libdir here because ^lib/ will be resolved again with installer
let backends_dst = PathBuf::from("lib").join(backends_rel);
let backend_name = format!("rustc_codegen_{}", backend);
let backend_name = format!("rustc_codegen_{backend}");
let mut found_backend = false;
for backend in fs::read_dir(&backends_src).unwrap() {
let file_name = backend.unwrap().file_name();
@ -1623,7 +1623,7 @@ impl Step for Extended {
let pkgbuild = |component: &str| {
let mut cmd = command("pkgbuild");
cmd.arg("--identifier")
.arg(format!("org.rust-lang.{}", component))
.arg(format!("org.rust-lang.{component}"))
.arg("--scripts")
.arg(pkg.join(component))
.arg("--nopayload")

View File

@ -53,7 +53,7 @@ fn is_dir_writable_for_user(dir: &Path) -> bool {
if e.kind() == std::io::ErrorKind::PermissionDenied {
false
} else {
panic!("Failed the write access check for the current user. {}", e);
panic!("Failed the write access check for the current user. {e}");
}
}
}

View File

@ -870,8 +870,8 @@ fn get_var(var_base: &str, host: &str, target: &str) -> Option<OsString> {
let kind = if host == target { "HOST" } else { "TARGET" };
let target_u = target.replace('-', "_");
env::var_os(format!("{var_base}_{target}"))
.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!("{var_base}_{target_u}")))
.or_else(|| env::var_os(format!("{kind}_{var_base}")))
.or_else(|| env::var_os(var_base))
}
@ -944,7 +944,7 @@ impl Step for Enzyme {
}
trace!(?target, "(re)building enzyme artifacts");
builder.info(&format!("Building Enzyme for {}", target));
builder.info(&format!("Building Enzyme for {target}"));
t!(stamp.remove());
let _time = helpers::timeit(builder);
t!(fs::create_dir_all(&out_dir));
@ -1229,10 +1229,10 @@ fn supported_sanitizers(
components
.iter()
.map(move |c| SanitizerRuntime {
cmake_target: format!("clang_rt.{}_{}_dynamic", c, os),
cmake_target: format!("clang_rt.{c}_{os}_dynamic"),
path: out_dir
.join(format!("build/lib/darwin/libclang_rt.{}_{}_dynamic.dylib", c, os)),
name: format!("librustc-{}_rt.{}.dylib", channel, c),
.join(format!("build/lib/darwin/libclang_rt.{c}_{os}_dynamic.dylib")),
name: format!("librustc-{channel}_rt.{c}.dylib"),
})
.collect()
};
@ -1241,9 +1241,9 @@ fn supported_sanitizers(
components
.iter()
.map(move |c| SanitizerRuntime {
cmake_target: format!("clang_rt.{}-{}", c, arch),
path: out_dir.join(format!("build/lib/{}/libclang_rt.{}-{}.a", os, c, arch)),
name: format!("librustc-{}_rt.{}.a", channel, c),
cmake_target: format!("clang_rt.{c}-{arch}"),
path: out_dir.join(format!("build/lib/{os}/libclang_rt.{c}-{arch}.a")),
name: format!("librustc-{channel}_rt.{c}.a"),
})
.collect()
};
@ -1362,8 +1362,8 @@ impl Step for CrtBeginEnd {
for obj in objs {
let base_name = unhashed_basename(&obj);
assert!(base_name == "crtbegin" || base_name == "crtend");
t!(fs::copy(&obj, out_dir.join(format!("{}S.o", base_name))));
t!(fs::rename(&obj, out_dir.join(format!("{}.o", base_name))));
t!(fs::copy(&obj, out_dir.join(format!("{base_name}S.o"))));
t!(fs::rename(&obj, out_dir.join(format!("{base_name}.o"))));
}
out_dir

View File

@ -552,7 +552,7 @@ Select which editor you would like to set up [default: None]: ";
let mut input = String::new();
loop {
print!("{}", prompt_str);
print!("{prompt_str}");
io::stdout().flush()?;
io::stdin().read_line(&mut input)?;
@ -764,7 +764,7 @@ fn create_editor_settings_maybe(config: &Config, editor: &EditorKind) -> io::Res
_ => "Created",
};
fs::write(&settings_path, editor.settings_template())?;
println!("{verb} `{}`", settings_filename);
println!("{verb} `{settings_filename}`");
} else {
println!("\n{}", editor.settings_template());
}

View File

@ -1593,10 +1593,10 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
let build = builder.build.build;
compiler = builder.compiler(compiler.stage - 1, build);
let test_stage = compiler.stage + 1;
(test_stage, format!("stage{}-{}", test_stage, build))
(test_stage, format!("stage{test_stage}-{build}"))
} else {
let stage = compiler.stage;
(stage, format!("stage{}-{}", stage, target))
(stage, format!("stage{stage}-{target}"))
};
if suite.ends_with("fulldeps") {

View File

@ -1278,5 +1278,5 @@ impl Builder<'_> {
pub fn cargo_profile_var(name: &str, config: &Config) -> String {
let profile = if config.rust_optimize.is_release() { "RELEASE" } else { "DEV" };
format!("CARGO_PROFILE_{}_{}", profile, name)
format!("CARGO_PROFILE_{profile}_{name}")
}

View File

@ -504,8 +504,8 @@ impl StepDescription {
match std::path::absolute(p) {
Ok(p) => p.strip_prefix(&builder.src).unwrap_or(&p).to_path_buf(),
Err(e) => {
eprintln!("ERROR: {:?}", e);
panic!("Due to the above error, failed to resolve path: {:?}", p);
eprintln!("ERROR: {e:?}");
panic!("Due to the above error, failed to resolve path: {p:?}");
}
}
})
@ -694,8 +694,7 @@ impl<'a> ShouldRun<'a> {
if !submodules_paths.iter().any(|sm_p| p.contains(sm_p)) {
assert!(
self.builder.src.join(p).exists(),
"`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {}",
p
"`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {p}"
);
}

View File

@ -3042,7 +3042,7 @@ impl Config {
let actual_hash = recorded
.split_whitespace()
.nth(2)
.unwrap_or_else(|| panic!("unexpected output `{}`", recorded));
.unwrap_or_else(|| panic!("unexpected output `{recorded}`"));
if actual_hash == checked_out_hash {
// already checked out
@ -3297,7 +3297,7 @@ impl Config {
}
StringOrBool::String(s) if s == "if-unchanged" => if_unchanged(),
StringOrBool::String(other) => {
panic!("unrecognized option for download-ci-llvm: {:?}", other)
panic!("unrecognized option for download-ci-llvm: {other:?}")
}
}
}

View File

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

View File

@ -117,8 +117,8 @@ pub fn check(build: &mut Build) {
eprintln!(
"\nYour system's libstdc++ version is too old for the `llvm.download-ci-llvm` option."
);
eprintln!("Current version detected: '{}'", version);
eprintln!("Minimum required version: '{}'", LIBSTDCXX_MIN_VERSION_THRESHOLD);
eprintln!("Current version detected: '{version}'");
eprintln!("Minimum required version: '{LIBSTDCXX_MIN_VERSION_THRESHOLD}'");
eprintln!(
"Consider upgrading libstdc++ or disabling the `llvm.download-ci-llvm` option."
);

View File

@ -329,7 +329,7 @@ pub fn start_process(cmd: &mut Command) -> impl FnOnce() -> String + use<> {
Err(e) => fail(&format!("failed to execute command: {cmd:?}\nERROR: {e}")),
};
let command = format!("{:?}", cmd);
let command = format!("{cmd:?}");
move || {
let output = child.wait_with_output().unwrap();
@ -540,7 +540,7 @@ where
use std::fmt::Write;
input.as_ref().iter().fold(String::with_capacity(input.as_ref().len() * 2), |mut acc, &byte| {
write!(&mut acc, "{:02x}", byte).expect("Failed to write byte to the hex String.");
write!(&mut acc, "{byte:02x}").expect("Failed to write byte to the hex String.");
acc
})
}

View File

@ -90,7 +90,7 @@ pub fn maybe_dump(dump_name: String, cmd: &Command) {
let mut file = OpenOptions::new().create(true).append(true).open(dump_file).unwrap();
let cmd_dump = format!("{:?}\n", cmd);
let cmd_dump = format!("{cmd:?}\n");
let cmd_dump = cmd_dump.replace(&env::var("BUILD_OUT").unwrap(), "${BUILD_OUT}");
let cmd_dump = cmd_dump.replace(&env::var("CARGO_HOME").unwrap(), "${CARGO_HOME}");