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,15 +120,13 @@ 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
if env::var("RUSTC_BACKTRACE_ON_ICE").is_ok() && env::var("RUST_BACKTRACE").is_err() { if env::var("RUSTC_BACKTRACE_ON_ICE").is_ok() && env::var("RUST_BACKTRACE").is_err() {
@@ -242,11 +240,11 @@ 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");
if verbose > 2 { if verbose > 2 {
@@ -282,10 +280,10 @@ 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.
@@ -301,7 +299,6 @@ fn main() {
rusage_data.unwrap_or_default(), rusage_data.unwrap_or_default(),
); );
} }
}
if status.success() { if status.success() {
std::process::exit(0); std::process::exit(0);

View File

@@ -626,20 +626,20 @@ 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()); let root = format!("native={}", p.to_str().unwrap());
cargo.rustflag("-L").rustflag(&root); 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()); let root = format!("native={}", dir.to_str().unwrap());
cargo.rustflag("-L").rustflag(&root); cargo.rustflag("-L").rustflag(&root);
} }
} }
}
// By default, rustc uses `-Cembed-bitcode=yes`, and Cargo overrides that // By default, rustc uses `-Cembed-bitcode=yes`, and Cargo overrides that
// with `-Cembed-bitcode=no` for non-LTO builds. However, libstd must be // with `-Cembed-bitcode=no` for non-LTO builds. However, libstd must be
@@ -1391,13 +1391,14 @@ 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()
&& let Some(ref clang_cl_path) = builder.config.llvm_clang_cl
{
// Add clang's runtime library directory to the search path // Add clang's runtime library directory to the search path
let clang_rt_dir = get_clang_cl_resource_dir(builder, clang_cl_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())); 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.
if let Some(ref s) = builder.config.llvm_ldflags { if let Some(ref s) = builder.config.llvm_ldflags {

View File

@@ -2276,12 +2276,13 @@ 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
&& config.llvm_config.is_some()
{
builder.info(&format!("Skipping LlvmTools ({target}): external LLVM")); builder.info(&format!("Skipping LlvmTools ({target}): external LLVM"));
return None; return None;
} }
}
if !builder.config.dry_run() { if !builder.config.dry_run() {
builder.require_submodule("src/llvm-project", None); builder.require_submodule("src/llvm-project", None);
@@ -2398,12 +2399,12 @@ 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")); builder.info(&format!("Skipping RustDev ({target}): external LLVM"));
return None; return None;
} }
}
if !builder.config.dry_run() { if !builder.config.dry_run() {
builder.require_submodule("src/llvm-project", None); builder.require_submodule("src/llvm-project", None);

View File

@@ -318,11 +318,11 @@ 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()
}); });
t!(tx.send(entry.into_path())); t!(tx.send(entry.into_path()));

View File

@@ -107,8 +107,9 @@ 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); check_llvm_version(builder, s);
let llvm_config = s.to_path_buf(); let llvm_config = s.to_path_buf();
let mut llvm_cmake_dir = llvm_config.clone(); let mut llvm_cmake_dir = llvm_config.clone();
@@ -119,7 +120,6 @@ pub fn prebuilt_llvm_config(
llvm_cmake_dir.push("llvm"); llvm_cmake_dir.push("llvm");
return LlvmBuildStatus::AlreadyBuilt(LlvmResult { llvm_config, llvm_cmake_dir }); return LlvmBuildStatus::AlreadyBuilt(LlvmResult { llvm_config, llvm_cmake_dir });
} }
}
if handle_submodule_when_needed { if handle_submodule_when_needed {
// If submodules are disabled, this does nothing. // If submodules are disabled, this does nothing.
@@ -467,11 +467,11 @@ 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
if !builder.config.is_host_target(target) { if !builder.config.is_host_target(target) {
@@ -596,11 +596,11 @@ 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,12 +729,10 @@ 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))
.define("CMAKE_ASM_COMPILER", sanitize_cc(&cc)); .define("CMAKE_ASM_COMPILER", sanitize_cc(&cc));
@@ -791,21 +789,21 @@ 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 // LLVM build breaks if `CMAKE_AR` is a relative path, for some reason it
// tries to resolve this path in the LLVM build directory. // tries to resolve this path in the LLVM build directory.
cfg.define("CMAKE_AR", sanitize_cc(&ar)); 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 // LLVM build breaks if `CMAKE_RANLIB` is a relative path, for some reason it
// tries to resolve this path in the LLVM build directory. // tries to resolve this path in the LLVM build directory.
cfg.define("CMAKE_RANLIB", sanitize_cc(&ranlib)); 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 {
ldflags.push_all(flags); ldflags.push_all(flags);
@@ -1037,14 +1035,15 @@ 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()
&& let Some(clang_cl_path) = builder.config.llvm_clang_cl.as_ref()
{
// Find clang's runtime library directory and push that as a search path to the // Find clang's runtime library directory and push that as a search path to the
// cmake linker flags. // cmake linker flags.
let clang_rt_dir = get_clang_cl_resource_dir(builder, clang_cl_path); let clang_rt_dir = get_clang_cl_resource_dir(builder, clang_cl_path);
ldflags.push_all(format!("/libpath:{}", clang_rt_dir.display())); 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,
// which impacts where it expects to find LLVM's shared library. This causes #80703. // which impacts where it expects to find LLVM's shared library. This causes #80703.

View File

@@ -154,11 +154,11 @@ 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));
let mut rustc = sysroot.clone(); let mut rustc = sysroot.clone();

View File

@@ -241,12 +241,12 @@ 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 {
let config = &builder.config; let config = &builder.config;
@@ -457,12 +457,12 @@ 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);
} }
} }
}
fn run(self, builder: &Builder<'_>) -> Self::Output { fn run(self, builder: &Builder<'_>) -> Self::Output {
let config = &builder.config; let config = &builder.config;
@@ -672,12 +672,12 @@ 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);
} }
} }
}
fn run(self, builder: &Builder<'_>) -> Self::Output { fn run(self, builder: &Builder<'_>) -> Self::Output {
let config = &builder.config; let config = &builder.config;

View File

@@ -2417,11 +2417,11 @@ 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()));
let mut cmd = builder.rustdoc_cmd(compiler); let mut cmd = builder.rustdoc_cmd(compiler);

View File

@@ -988,8 +988,9 @@ 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 = let llvm_libdir =
command(llvm_config).arg("--libdir").run_capture_stdout(self).stdout(); command(llvm_config).arg("--libdir").run_capture_stdout(self).stdout();
if target.is_msvc() { if target.is_msvc() {
@@ -998,7 +999,6 @@ impl Builder<'_> {
rustflags.arg(&format!("-Clink-arg=-L{llvm_libdir}")); rustflags.arg(&format!("-Clink-arg=-L{llvm_libdir}"));
} }
} }
}
// Compile everything except libraries and proc macros with the more // Compile everything except libraries and proc macros with the more
// efficient initial-exec TLS model. This doesn't work with `dlopen`, // efficient initial-exec TLS model. This doesn't work with `dlopen`,
@@ -1226,14 +1226,13 @@ 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}"));
} }
} }
}
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 {

View File

@@ -1700,8 +1700,9 @@ 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}""#)) { match get_table(&format!(r#"{key}="{value}""#)) {
Ok(v) => { Ok(v) => {
override_toml.merge( override_toml.merge(
@@ -1715,7 +1716,6 @@ impl Config {
Err(e) => err = e, Err(e) => err = e,
} }
} }
}
eprintln!("failed to parse override `{option}`: `{err}"); eprintln!("failed to parse override `{option}`: `{err}");
exit!(2) exit!(2)
} }
@@ -2057,17 +2057,16 @@ 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!( eprintln!(
"WARN: currently no CI rustc builds have rustc debug assertions \ "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(
download_rustc, download_rustc,
@@ -2177,20 +2176,18 @@ 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!( println!(
"WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel." "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 {
let Llvm { let Llvm {
@@ -2699,12 +2696,12 @@ 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,8 +3477,9 @@ 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_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_cfg = ci_target_toml.ok_or(format!(
"Target specific config for '{host_str}' is not present for CI-rustc" "Target specific config for '{host_str}' is not present for CI-rustc"
@@ -3493,7 +3491,6 @@ fn check_incompatible_options_for_ci_rustc(
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)) =
(current_config_toml.rust, ci_config_toml.rust) (current_config_toml.rust, ci_config_toml.rust)

View File

@@ -709,11 +709,11 @@ 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,8 +1451,9 @@ 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 ."); path.push_str(" run -C cache=n --dir .");
// Make sure that tests have access to RUSTC_BOOTSTRAP. This (for example) is // Make sure that tests have access to RUSTC_BOOTSTRAP. This (for example) is
// required for libtest to work on beta/stable channels. // required for libtest to work on beta/stable channels.
@@ -1468,7 +1469,6 @@ Executed at: {executed_at}"#,
return Some(path); return Some(path);
} }
}
None None
} }
@@ -1637,13 +1637,13 @@ 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(" (");
version.push_str(s); version.push_str(s);
version.push(')'); version.push(')');
} }
}
version version
} }
@@ -1760,8 +1760,9 @@ 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( self.copy_link_internal(
&dbg_file, &dbg_file,
&dst.with_extension(dbg_file.extension().unwrap()), &dst.with_extension(dbg_file.extension().unwrap()),
@@ -1769,7 +1770,6 @@ Executed at: {executed_at}"#,
); );
} }
} }
}
fn copy_link_internal(&self, src: &Path, dst: &Path, dereference_symlinks: bool) { fn copy_link_internal(&self, src: &Path, dst: &Path, dereference_symlinks: bool) {
if self.config.dry_run() { if self.config.dry_run() {
@@ -1779,14 +1779,15 @@ 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)
&& e.kind() != io::ErrorKind::NotFound
{
// workaround for https://github.com/rust-lang/rust/issues/127126 // workaround for https://github.com/rust-lang/rust/issues/127126
// if removing the file fails, attempt to rename it instead. // if removing the file fails, attempt to rename it instead.
let now = t!(SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)); let now = t!(SystemTime::now().duration_since(SystemTime::UNIX_EPOCH));
let _ = fs::rename(dst, format!("{}-{}", dst.display(), now.as_nanos())); 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();
if metadata.file_type().is_symlink() { if metadata.file_type().is_symlink() {
@@ -1894,12 +1895,12 @@ 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);
} }
} }
}
fn read(&self, path: &Path) -> String { fn read(&self, path: &Path) -> String {
if self.config.dry_run() { if self.config.dry_run() {

View File

@@ -46,11 +46,11 @@ 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
} }