fix clippy warnings

Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
onur-ozkan
2025-05-27 18:53:20 +03:00
parent d2a6990122
commit a577bcc077
13 changed files with 229 additions and 234 deletions

View File

@@ -120,14 +120,12 @@ fn main() {
}; };
cmd.args(&args).env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); cmd.args(&args).env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
if let Some(crate_name) = crate_name { if let Some(crate_name) = crate_name
if let Some(target) = env::var_os("RUSTC_TIME") { && let Some(target) = env::var_os("RUSTC_TIME")
if target == "all" && (target == "all"
|| target.into_string().unwrap().split(',').any(|c| c.trim() == crate_name) || target.into_string().unwrap().split(',').any(|c| c.trim() == crate_name))
{ {
cmd.arg("-Ztime-passes"); cmd.arg("-Ztime-passes");
}
}
} }
// Print backtrace in case of ICE // Print backtrace in case of ICE
@@ -242,10 +240,10 @@ fn main() {
} }
} }
if env::var_os("RUSTC_BOLT_LINK_FLAGS").is_some() { if env::var_os("RUSTC_BOLT_LINK_FLAGS").is_some()
if let Some("rustc_driver") = crate_name { && let Some("rustc_driver") = crate_name
cmd.arg("-Clink-args=-Wl,-q"); {
} cmd.arg("-Clink-args=-Wl,-q");
} }
let is_test = args.iter().any(|a| a == "--test"); let is_test = args.iter().any(|a| a == "--test");
@@ -282,25 +280,24 @@ fn main() {
(child, status) (child, status)
}; };
if env::var_os("RUSTC_PRINT_STEP_TIMINGS").is_some() if (env::var_os("RUSTC_PRINT_STEP_TIMINGS").is_some()
|| env::var_os("RUSTC_PRINT_STEP_RUSAGE").is_some() || env::var_os("RUSTC_PRINT_STEP_RUSAGE").is_some())
&& let Some(crate_name) = crate_name
{ {
if let Some(crate_name) = crate_name { let dur = start.elapsed();
let dur = start.elapsed(); // If the user requested resource usage data, then
// If the user requested resource usage data, then // include that in addition to the timing output.
// include that in addition to the timing output. let rusage_data =
let rusage_data = env::var_os("RUSTC_PRINT_STEP_RUSAGE").and_then(|_| format_rusage_data(child));
env::var_os("RUSTC_PRINT_STEP_RUSAGE").and_then(|_| format_rusage_data(child)); eprintln!(
eprintln!( "[RUSTC-TIMING] {} test:{} {}.{:03}{}{}",
"[RUSTC-TIMING] {} test:{} {}.{:03}{}{}", crate_name,
crate_name, is_test,
is_test, dur.as_secs(),
dur.as_secs(), dur.subsec_millis(),
dur.subsec_millis(), if rusage_data.is_some() { " " } else { "" },
if rusage_data.is_some() { " " } else { "" }, rusage_data.unwrap_or_default(),
rusage_data.unwrap_or_default(), );
);
}
} }
if status.success() { if status.success() {

View File

@@ -626,18 +626,18 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
// Help the libc crate compile by assisting it in finding various // Help the libc crate compile by assisting it in finding various
// sysroot native libraries. // sysroot native libraries.
if target.contains("musl") { if target.contains("musl")
if let Some(p) = builder.musl_libdir(target) { && let Some(p) = builder.musl_libdir(target)
let root = format!("native={}", p.to_str().unwrap()); {
cargo.rustflag("-L").rustflag(&root); let root = format!("native={}", p.to_str().unwrap());
} cargo.rustflag("-L").rustflag(&root);
} }
if target.contains("-wasi") { if target.contains("-wasi")
if let Some(dir) = builder.wasi_libdir(target) { && let Some(dir) = builder.wasi_libdir(target)
let root = format!("native={}", dir.to_str().unwrap()); {
cargo.rustflag("-L").rustflag(&root); let root = format!("native={}", dir.to_str().unwrap());
} cargo.rustflag("-L").rustflag(&root);
} }
} }
@@ -1391,12 +1391,13 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
// found. This is to avoid the linker errors about undefined references to // found. This is to avoid the linker errors about undefined references to
// `__llvm_profile_instrument_memop` when linking `rustc_driver`. // `__llvm_profile_instrument_memop` when linking `rustc_driver`.
let mut llvm_linker_flags = String::new(); let mut llvm_linker_flags = String::new();
if builder.config.llvm_profile_generate && target.is_msvc() { if builder.config.llvm_profile_generate
if let Some(ref clang_cl_path) = builder.config.llvm_clang_cl { && target.is_msvc()
// Add clang's runtime library directory to the search path && let Some(ref clang_cl_path) = builder.config.llvm_clang_cl
let clang_rt_dir = get_clang_cl_resource_dir(builder, clang_cl_path); {
llvm_linker_flags.push_str(&format!("-L{}", clang_rt_dir.display())); // Add clang's runtime library directory to the search path
} let clang_rt_dir = get_clang_cl_resource_dir(builder, clang_cl_path);
llvm_linker_flags.push_str(&format!("-L{}", clang_rt_dir.display()));
} }
// The config can also specify its own llvm linker flags. // The config can also specify its own llvm linker flags.

View File

@@ -2276,11 +2276,12 @@ impl Step for LlvmTools {
let target = self.target; let target = self.target;
// Run only if a custom llvm-config is not used // Run only if a custom llvm-config is not used
if let Some(config) = builder.config.target_config.get(&target) { if let Some(config) = builder.config.target_config.get(&target)
if !builder.config.llvm_from_ci && config.llvm_config.is_some() { && !builder.config.llvm_from_ci
builder.info(&format!("Skipping LlvmTools ({target}): external LLVM")); && config.llvm_config.is_some()
return None; {
} builder.info(&format!("Skipping LlvmTools ({target}): external LLVM"));
return None;
} }
if !builder.config.dry_run() { if !builder.config.dry_run() {
@@ -2398,11 +2399,11 @@ impl Step for RustDev {
let target = self.target; let target = self.target;
/* 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 { && let Some(ref _s) = config.llvm_config
builder.info(&format!("Skipping RustDev ({target}): external LLVM")); {
return None; builder.info(&format!("Skipping RustDev ({target}): external LLVM"));
} return None;
} }
if !builder.config.dry_run() { if !builder.config.dry_run() {

View File

@@ -318,10 +318,10 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) {
// `into_path` produces an absolute path. Try to strip `cwd` to get a shorter // `into_path` produces an absolute path. Try to strip `cwd` to get a shorter
// relative path. // relative path.
let mut path = entry.clone().into_path(); let mut path = entry.clone().into_path();
if let Ok(cwd) = cwd { if let Ok(cwd) = cwd
if let Ok(path2) = path.strip_prefix(cwd) { && let Ok(path2) = path.strip_prefix(cwd)
path = path2.to_path_buf(); {
} path = path2.to_path_buf();
} }
path.display().to_string() path.display().to_string()
}); });

View File

@@ -107,18 +107,18 @@ pub fn prebuilt_llvm_config(
// If we're using a custom LLVM bail out here, but we can only use a // If we're using a custom LLVM bail out here, but we can only use a
// custom LLVM for the build triple. // custom LLVM for the build triple.
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 { && let Some(ref s) = config.llvm_config
check_llvm_version(builder, s); {
let llvm_config = s.to_path_buf(); check_llvm_version(builder, s);
let mut llvm_cmake_dir = llvm_config.clone(); let llvm_config = s.to_path_buf();
llvm_cmake_dir.pop(); let mut llvm_cmake_dir = llvm_config.clone();
llvm_cmake_dir.pop(); llvm_cmake_dir.pop();
llvm_cmake_dir.push("lib"); llvm_cmake_dir.pop();
llvm_cmake_dir.push("cmake"); llvm_cmake_dir.push("lib");
llvm_cmake_dir.push("llvm"); llvm_cmake_dir.push("cmake");
return LlvmBuildStatus::AlreadyBuilt(LlvmResult { llvm_config, llvm_cmake_dir }); llvm_cmake_dir.push("llvm");
} return LlvmBuildStatus::AlreadyBuilt(LlvmResult { llvm_config, llvm_cmake_dir });
} }
if handle_submodule_when_needed { if handle_submodule_when_needed {
@@ -467,10 +467,10 @@ impl Step for Llvm {
cfg.define("LLVM_ENABLE_RUNTIMES", enabled_llvm_runtimes.join(";")); cfg.define("LLVM_ENABLE_RUNTIMES", enabled_llvm_runtimes.join(";"));
} }
if let Some(num_linkers) = builder.config.llvm_link_jobs { if let Some(num_linkers) = builder.config.llvm_link_jobs
if num_linkers > 0 { && num_linkers > 0
cfg.define("LLVM_PARALLEL_LINK_JOBS", num_linkers.to_string()); {
} cfg.define("LLVM_PARALLEL_LINK_JOBS", num_linkers.to_string());
} }
// https://llvm.org/docs/HowToCrossCompileLLVM.html // https://llvm.org/docs/HowToCrossCompileLLVM.html
@@ -596,10 +596,10 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
let version = get_llvm_version(builder, llvm_config); let version = get_llvm_version(builder, llvm_config);
let mut parts = version.split('.').take(2).filter_map(|s| s.parse::<u32>().ok()); let mut parts = version.split('.').take(2).filter_map(|s| s.parse::<u32>().ok());
if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) { if let (Some(major), Some(_minor)) = (parts.next(), parts.next())
if major >= 19 { && major >= 19
return; {
} return;
} }
panic!("\n\nbad LLVM version: {version}, need >=19\n\n") panic!("\n\nbad LLVM version: {version}, need >=19\n\n")
} }
@@ -729,11 +729,9 @@ fn configure_cmake(
// If ccache is configured we inform the build a little differently how // If ccache is configured we inform the build a little differently how
// to invoke ccache while also invoking our compilers. // to invoke ccache while also invoking our compilers.
if use_compiler_launcher { if use_compiler_launcher && let Some(ref ccache) = builder.config.ccache {
if let Some(ref ccache) = builder.config.ccache { cfg.define("CMAKE_C_COMPILER_LAUNCHER", ccache)
cfg.define("CMAKE_C_COMPILER_LAUNCHER", ccache) .define("CMAKE_CXX_COMPILER_LAUNCHER", ccache);
.define("CMAKE_CXX_COMPILER_LAUNCHER", ccache);
}
} }
cfg.define("CMAKE_C_COMPILER", sanitize_cc(&cc)) cfg.define("CMAKE_C_COMPILER", sanitize_cc(&cc))
.define("CMAKE_CXX_COMPILER", sanitize_cc(&cxx)) .define("CMAKE_CXX_COMPILER", sanitize_cc(&cxx))
@@ -791,20 +789,20 @@ fn configure_cmake(
cxxflags.push(format!(" --target={target}")); cxxflags.push(format!(" --target={target}"));
} }
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)
if ar.is_absolute() { && ar.is_absolute()
// LLVM build breaks if `CMAKE_AR` is a relative path, for some reason it {
// tries to resolve this path in the LLVM build directory. // LLVM build breaks if `CMAKE_AR` is a relative path, for some reason it
cfg.define("CMAKE_AR", sanitize_cc(&ar)); // tries to resolve this path in the LLVM build directory.
} cfg.define("CMAKE_AR", sanitize_cc(&ar));
} }
if let Some(ranlib) = builder.ranlib(target) { if let Some(ranlib) = builder.ranlib(target)
if ranlib.is_absolute() { && ranlib.is_absolute()
// LLVM build breaks if `CMAKE_RANLIB` is a relative path, for some reason it {
// tries to resolve this path in the LLVM build directory. // LLVM build breaks if `CMAKE_RANLIB` is a relative path, for some reason it
cfg.define("CMAKE_RANLIB", sanitize_cc(&ranlib)); // tries to resolve this path in the LLVM build directory.
} cfg.define("CMAKE_RANLIB", sanitize_cc(&ranlib));
} }
if let Some(ref flags) = builder.config.llvm_ldflags { if let Some(ref flags) = builder.config.llvm_ldflags {
@@ -1037,13 +1035,14 @@ impl Step for Lld {
// when doing PGO on CI, cmake or clang-cl don't automatically link clang's // when doing PGO on CI, cmake or clang-cl don't automatically link clang's
// profiler runtime in. In that case, we need to manually ask cmake to do it, to avoid // profiler runtime in. In that case, we need to manually ask cmake to do it, to avoid
// linking errors, much like LLVM's cmake setup does in that situation. // linking errors, much like LLVM's cmake setup does in that situation.
if builder.config.llvm_profile_generate && target.is_msvc() { if builder.config.llvm_profile_generate
if let Some(clang_cl_path) = builder.config.llvm_clang_cl.as_ref() { && target.is_msvc()
// Find clang's runtime library directory and push that as a search path to the && let Some(clang_cl_path) = builder.config.llvm_clang_cl.as_ref()
// cmake linker flags. {
let clang_rt_dir = get_clang_cl_resource_dir(builder, clang_cl_path); // Find clang's runtime library directory and push that as a search path to the
ldflags.push_all(format!("/libpath:{}", clang_rt_dir.display())); // cmake linker flags.
} let clang_rt_dir = get_clang_cl_resource_dir(builder, clang_cl_path);
ldflags.push_all(format!("/libpath:{}", clang_rt_dir.display()));
} }
// LLD is built as an LLVM tool, but is distributed outside of the `llvm-tools` component, // LLD is built as an LLVM tool, but is distributed outside of the `llvm-tools` component,

View File

@@ -154,10 +154,10 @@ Consider setting `rust.debuginfo-level = 1` in `bootstrap.toml`."#);
let compiler = builder.compiler(builder.top_stage, builder.config.build); let compiler = builder.compiler(builder.top_stage, builder.config.build);
builder.ensure(Std::new(compiler, builder.config.build)); builder.ensure(Std::new(compiler, builder.config.build));
if let Some(opts) = args.cmd.shared_opts() { if let Some(opts) = args.cmd.shared_opts()
if opts.profiles.contains(&Profile::Doc) { && opts.profiles.contains(&Profile::Doc)
builder.ensure(Rustdoc { compiler }); {
} builder.ensure(Rustdoc { compiler });
} }
let sysroot = builder.ensure(Sysroot::new(compiler)); let sysroot = builder.ensure(Sysroot::new(compiler));

View File

@@ -241,10 +241,10 @@ impl Step for Link {
if run.builder.config.dry_run() { if run.builder.config.dry_run() {
return; return;
} }
if let [cmd] = &run.paths[..] { if let [cmd] = &run.paths[..]
if cmd.assert_single_path().path.as_path().as_os_str() == "link" { && cmd.assert_single_path().path.as_path().as_os_str() == "link"
run.builder.ensure(Link); {
} run.builder.ensure(Link);
} }
} }
fn run(self, builder: &Builder<'_>) -> Self::Output { fn run(self, builder: &Builder<'_>) -> Self::Output {
@@ -457,10 +457,10 @@ impl Step for Hook {
} }
fn make_run(run: RunConfig<'_>) { fn make_run(run: RunConfig<'_>) {
if let [cmd] = &run.paths[..] { if let [cmd] = &run.paths[..]
if cmd.assert_single_path().path.as_path().as_os_str() == "hook" { && cmd.assert_single_path().path.as_path().as_os_str() == "hook"
run.builder.ensure(Hook); {
} run.builder.ensure(Hook);
} }
} }
@@ -672,10 +672,10 @@ impl Step for Editor {
if run.builder.config.dry_run() { if run.builder.config.dry_run() {
return; return;
} }
if let [cmd] = &run.paths[..] { if let [cmd] = &run.paths[..]
if cmd.assert_single_path().path.as_path().as_os_str() == "editor" { && cmd.assert_single_path().path.as_path().as_os_str() == "editor"
run.builder.ensure(Editor); {
} run.builder.ensure(Editor);
} }
} }

View File

@@ -2417,10 +2417,10 @@ impl Step for ErrorIndex {
} }
fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> bool { fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> bool {
if let Ok(contents) = fs::read_to_string(markdown) { if let Ok(contents) = fs::read_to_string(markdown)
if !contents.contains("```") { && !contents.contains("```")
return true; {
} return true;
} }
builder.verbose(|| println!("doc tests for: {}", markdown.display())); builder.verbose(|| println!("doc tests for: {}", markdown.display()));

View File

@@ -988,15 +988,15 @@ impl Builder<'_> {
// requirement, but the `-L` library path is not propagated across // requirement, but the `-L` library path is not propagated across
// separate Cargo projects. We can add LLVM's library path to the // separate Cargo projects. We can add LLVM's library path to the
// rustc args as a workaround. // rustc args as a workaround.
if mode == Mode::ToolRustc || mode == Mode::Codegen { if (mode == Mode::ToolRustc || mode == Mode::Codegen)
if let Some(llvm_config) = self.llvm_config(target) { && let Some(llvm_config) = self.llvm_config(target)
let llvm_libdir = {
command(llvm_config).arg("--libdir").run_capture_stdout(self).stdout(); let llvm_libdir =
if target.is_msvc() { command(llvm_config).arg("--libdir").run_capture_stdout(self).stdout();
rustflags.arg(&format!("-Clink-arg=-LIBPATH:{llvm_libdir}")); if target.is_msvc() {
} else { rustflags.arg(&format!("-Clink-arg=-LIBPATH:{llvm_libdir}"));
rustflags.arg(&format!("-Clink-arg=-L{llvm_libdir}")); } else {
} rustflags.arg(&format!("-Clink-arg=-L{llvm_libdir}"));
} }
} }
@@ -1226,12 +1226,11 @@ impl Builder<'_> {
_ => None, _ => None,
}; };
if let Some(limit) = limit { if let Some(limit) = limit
if stage == 0 && (stage == 0
|| self.config.default_codegen_backend(target).unwrap_or_default() == "llvm" || self.config.default_codegen_backend(target).unwrap_or_default() == "llvm")
{ {
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={limit}")); rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={limit}"));
}
} }
} }

View File

@@ -1700,20 +1700,20 @@ impl Config {
}; };
// We want to be able to set string values without quotes, // We want to be able to set string values without quotes,
// like in `configure.py`. Try adding quotes around the right hand side // like in `configure.py`. Try adding quotes around the right hand side
if let Some((key, value)) = option.split_once('=') { if let Some((key, value)) = option.split_once('=')
if !value.contains('"') { && !value.contains('"')
match get_table(&format!(r#"{key}="{value}""#)) { {
Ok(v) => { match get_table(&format!(r#"{key}="{value}""#)) {
override_toml.merge( Ok(v) => {
None, override_toml.merge(
&mut Default::default(), None,
v, &mut Default::default(),
ReplaceOpt::ErrorOnDuplicate, v,
); ReplaceOpt::ErrorOnDuplicate,
continue; );
} continue;
Err(e) => err = e,
} }
Err(e) => err = e,
} }
} }
eprintln!("failed to parse override `{option}`: `{err}"); eprintln!("failed to parse override `{option}`: `{err}");
@@ -2057,16 +2057,15 @@ impl Config {
|| (matches!(debug_toml, Some(true)) || (matches!(debug_toml, Some(true))
&& !matches!(rustc_debug_assertions_toml, Some(false))); && !matches!(rustc_debug_assertions_toml, Some(false)));
if debug_assertions_requested { if debug_assertions_requested
if let Some(ref opt) = download_rustc { && let Some(ref opt) = download_rustc
if opt.is_string_or_true() { && opt.is_string_or_true()
eprintln!( {
"WARN: currently no CI rustc builds have rustc debug assertions \ eprintln!(
"WARN: currently no CI rustc builds have rustc debug assertions \
enabled. Please either set `rust.debug-assertions` to `false` if you \ enabled. Please either set `rust.debug-assertions` to `false` if you \
want to use download CI rustc or set `rust.download-rustc` to `false`." want to use download CI rustc or set `rust.download-rustc` to `false`."
); );
}
}
} }
config.download_rustc_commit = config.download_ci_rustc_commit( config.download_rustc_commit = config.download_ci_rustc_commit(
@@ -2177,19 +2176,17 @@ impl Config {
// We need to override `rust.channel` if it's manually specified when using the CI rustc. // We need to override `rust.channel` if it's manually specified when using the CI rustc.
// This is because if the compiler uses a different channel than the one specified in bootstrap.toml, // This is because if the compiler uses a different channel than the one specified in bootstrap.toml,
// tests may fail due to using a different channel than the one used by the compiler during tests. // tests may fail due to using a different channel than the one used by the compiler during tests.
if let Some(commit) = &config.download_rustc_commit { if let Some(commit) = &config.download_rustc_commit
if is_user_configured_rust_channel { && is_user_configured_rust_channel
println!( {
"WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel." println!(
); "WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel."
);
let channel = config let channel =
.read_file_by_commit(Path::new("src/ci/channel"), commit) config.read_file_by_commit(Path::new("src/ci/channel"), commit).trim().to_owned();
.trim()
.to_owned();
config.channel = channel; config.channel = channel;
}
} }
if let Some(llvm) = toml.llvm { if let Some(llvm) = toml.llvm {
@@ -2699,10 +2696,10 @@ impl Config {
let bindir = &self.bindir; let bindir = &self.bindir;
if bindir.is_absolute() { if bindir.is_absolute() {
// Try to make it relative to the prefix. // Try to make it relative to the prefix.
if let Some(prefix) = &self.prefix { if let Some(prefix) = &self.prefix
if let Ok(stripped) = bindir.strip_prefix(prefix) { && let Ok(stripped) = bindir.strip_prefix(prefix)
return stripped; {
} return stripped;
} }
} }
bindir bindir
@@ -3480,19 +3477,19 @@ fn check_incompatible_options_for_ci_rustc(
// We always build the in-tree compiler on cross targets, so we only care // We always build the in-tree compiler on cross targets, so we only care
// about the host target here. // about the host target here.
let host_str = host.to_string(); let host_str = host.to_string();
if let Some(current_cfg) = current_config_toml.target.as_ref().and_then(|c| c.get(&host_str)) { if let Some(current_cfg) = current_config_toml.target.as_ref().and_then(|c| c.get(&host_str))
if current_cfg.profiler.is_some() { && current_cfg.profiler.is_some()
let ci_target_toml = ci_config_toml.target.as_ref().and_then(|c| c.get(&host_str)); {
let ci_cfg = ci_target_toml.ok_or(format!( let ci_target_toml = ci_config_toml.target.as_ref().and_then(|c| c.get(&host_str));
"Target specific config for '{host_str}' is not present for CI-rustc" let ci_cfg = ci_target_toml.ok_or(format!(
))?; "Target specific config for '{host_str}' is not present for CI-rustc"
))?;
let profiler = &ci_cfg.profiler; let profiler = &ci_cfg.profiler;
err!(current_cfg.profiler, profiler, "build"); err!(current_cfg.profiler, profiler, "build");
let optimized_compiler_builtins = &ci_cfg.optimized_compiler_builtins; let optimized_compiler_builtins = &ci_cfg.optimized_compiler_builtins;
err!(current_cfg.optimized_compiler_builtins, optimized_compiler_builtins, "build"); err!(current_cfg.optimized_compiler_builtins, optimized_compiler_builtins, "build");
}
} }
let (Some(current_rust_config), Some(ci_rust_config)) = let (Some(current_rust_config), Some(ci_rust_config)) =

View File

@@ -709,10 +709,10 @@ download-rustc = false
"; ";
} }
self.download_file(&format!("{base_url}/{url}"), &tarball, help_on_error); self.download_file(&format!("{base_url}/{url}"), &tarball, help_on_error);
if let Some(sha256) = checksum { if let Some(sha256) = checksum
if !self.verify(&tarball, sha256) { && !self.verify(&tarball, sha256)
panic!("failed to verify {}", tarball.display()); {
} panic!("failed to verify {}", tarball.display());
} }
self.unpack(&tarball, &bin_root, prefix); self.unpack(&tarball, &bin_root, prefix);

View File

@@ -1451,23 +1451,23 @@ Executed at: {executed_at}"#,
// Look for Wasmtime, and for its default options be sure to disable // Look for Wasmtime, and for its default options be sure to disable
// its caching system since we're executing quite a lot of tests and // its caching system since we're executing quite a lot of tests and
// ideally shouldn't pollute the cache too much. // ideally shouldn't pollute the cache too much.
if let Some(path) = finder.maybe_have("wasmtime") { if let Some(path) = finder.maybe_have("wasmtime")
if let Ok(mut path) = path.into_os_string().into_string() { && let Ok(mut path) = path.into_os_string().into_string()
path.push_str(" run -C cache=n --dir ."); {
// Make sure that tests have access to RUSTC_BOOTSTRAP. This (for example) is path.push_str(" run -C cache=n --dir .");
// required for libtest to work on beta/stable channels. // Make sure that tests have access to RUSTC_BOOTSTRAP. This (for example) is
// // required for libtest to work on beta/stable channels.
// NB: with Wasmtime 20 this can change to `-S inherit-env` to //
// inherit the entire environment rather than just this single // NB: with Wasmtime 20 this can change to `-S inherit-env` to
// environment variable. // inherit the entire environment rather than just this single
path.push_str(" --env RUSTC_BOOTSTRAP"); // environment variable.
path.push_str(" --env RUSTC_BOOTSTRAP");
if target.contains("wasip2") { if target.contains("wasip2") {
path.push_str(" --wasi inherit-network --wasi allow-ip-name-lookup"); path.push_str(" --wasi inherit-network --wasi allow-ip-name-lookup");
}
return Some(path);
} }
return Some(path);
} }
None None
@@ -1637,12 +1637,12 @@ Executed at: {executed_at}"#,
/// sha, version, etc. /// sha, version, etc.
fn rust_version(&self) -> String { fn rust_version(&self) -> String {
let mut version = self.rust_info().version(self, &self.version); let mut version = self.rust_info().version(self, &self.version);
if let Some(ref s) = self.config.description { if let Some(ref s) = self.config.description
if !s.is_empty() { && !s.is_empty()
version.push_str(" ("); {
version.push_str(s); version.push_str(" (");
version.push(')'); version.push_str(s);
} version.push(')');
} }
version version
} }
@@ -1760,14 +1760,14 @@ Executed at: {executed_at}"#,
pub fn copy_link(&self, src: &Path, dst: &Path, file_type: FileType) { pub fn copy_link(&self, src: &Path, dst: &Path, file_type: FileType) {
self.copy_link_internal(src, dst, false); self.copy_link_internal(src, dst, false);
if file_type.could_have_split_debuginfo() { if file_type.could_have_split_debuginfo()
if let Some(dbg_file) = split_debuginfo(src) { && let Some(dbg_file) = split_debuginfo(src)
self.copy_link_internal( {
&dbg_file, self.copy_link_internal(
&dst.with_extension(dbg_file.extension().unwrap()), &dbg_file,
false, &dst.with_extension(dbg_file.extension().unwrap()),
); false,
} );
} }
} }
@@ -1779,13 +1779,14 @@ Executed at: {executed_at}"#,
if src == dst { if src == dst {
return; return;
} }
if let Err(e) = fs::remove_file(dst) { if let Err(e) = fs::remove_file(dst)
if cfg!(windows) && e.kind() != io::ErrorKind::NotFound { && cfg!(windows)
// workaround for https://github.com/rust-lang/rust/issues/127126 && e.kind() != io::ErrorKind::NotFound
// if removing the file fails, attempt to rename it instead. {
let now = t!(SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)); // workaround for https://github.com/rust-lang/rust/issues/127126
let _ = fs::rename(dst, format!("{}-{}", dst.display(), now.as_nanos())); // if removing the file fails, attempt to rename it instead.
} let now = t!(SystemTime::now().duration_since(SystemTime::UNIX_EPOCH));
let _ = fs::rename(dst, format!("{}-{}", dst.display(), now.as_nanos()));
} }
let metadata = t!(src.symlink_metadata(), format!("src = {}", src.display())); let metadata = t!(src.symlink_metadata(), format!("src = {}", src.display()));
let mut src = src.to_path_buf(); let mut src = src.to_path_buf();
@@ -1894,10 +1895,10 @@ Executed at: {executed_at}"#,
chmod(&dst, file_type.perms()); chmod(&dst, file_type.perms());
// If this file can have debuginfo, look for split debuginfo and install it too. // If this file can have debuginfo, look for split debuginfo and install it too.
if file_type.could_have_split_debuginfo() { if file_type.could_have_split_debuginfo()
if let Some(dbg_file) = split_debuginfo(src) { && let Some(dbg_file) = split_debuginfo(src)
self.install(&dbg_file, dstdir, FileType::Regular); {
} self.install(&dbg_file, dstdir, FileType::Regular);
} }
} }

View File

@@ -46,10 +46,10 @@ pub fn find_recent_config_change_ids(current_id: usize) -> &'static [ChangeInfo]
// an empty list (it may be due to switching from a recent branch to an // an empty list (it may be due to switching from a recent branch to an
// older one); otherwise, return the full list (assuming the user provided // older one); otherwise, return the full list (assuming the user provided
// the incorrect change-id by accident). // the incorrect change-id by accident).
if let Some(config) = CONFIG_CHANGE_HISTORY.iter().max_by_key(|config| config.change_id) { if let Some(config) = CONFIG_CHANGE_HISTORY.iter().max_by_key(|config| config.change_id)
if current_id > config.change_id { && current_id > config.change_id
return &[]; {
} return &[];
} }
CONFIG_CHANGE_HISTORY CONFIG_CHANGE_HISTORY