Skip to content

Commit 4a47e8e

Browse files
committed
Auto merge of rust-lang#130332 - Zalathar:rollup-eq0qvvy, r=Zalathar
Rollup of 5 pull requests Successful merges: - rust-lang#130138 (bootstrap: Print more debug info when `find_initial_libdir` fails) - rust-lang#130199 (Don't call closure_by_move_body_def_id on FnOnce async closures in MIR validation) - rust-lang#130302 (add llvm-bitcode-linker and llvm-tools bins to ci-rustc's sysroot) - rust-lang#130306 (avoid updating LLVM submodule during bootstrap unit tests) - rust-lang#130317 (`ProjectionElem` and `UnOp`/`BinOp` dont need to be `PartialOrd`/`Ord`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 23b04c0 + 89dd3f9 commit 4a47e8e

File tree

9 files changed

+84
-54
lines changed

9 files changed

+84
-54
lines changed

Diff for: compiler/rustc_interface/src/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
788788
rustc_hir_analysis::check_crate(tcx);
789789
sess.time("MIR_coroutine_by_move_body", || {
790790
tcx.hir().par_body_owners(|def_id| {
791-
if tcx.needs_coroutine_by_move_body_def_id(def_id) {
791+
if tcx.needs_coroutine_by_move_body_def_id(def_id.to_def_id()) {
792792
tcx.ensure_with_value().coroutine_by_move_body_def_id(def_id);
793793
}
794794
});

Diff for: compiler/rustc_middle/src/mir/syntax.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ pub struct Place<'tcx> {
10941094
pub projection: &'tcx List<PlaceElem<'tcx>>,
10951095
}
10961096

1097-
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1097+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
10981098
#[derive(TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
10991099
pub enum ProjectionElem<V, T> {
11001100
Deref,
@@ -1468,7 +1468,7 @@ pub enum NullOp<'tcx> {
14681468
UbChecks,
14691469
}
14701470

1471-
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1471+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
14721472
#[derive(HashStable, TyEncodable, TyDecodable, TypeFoldable, TypeVisitable)]
14731473
pub enum UnOp {
14741474
/// The `!` operator for logical inversion
@@ -1486,7 +1486,7 @@ pub enum UnOp {
14861486
PtrMetadata,
14871487
}
14881488

1489-
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Ord, Eq, Hash)]
1489+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
14901490
#[derive(TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
14911491
pub enum BinOp {
14921492
/// The `+` operator (addition)

Diff for: compiler/rustc_middle/src/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3171,7 +3171,7 @@ impl<'tcx> TyCtxt<'tcx> {
31713171
self.impl_trait_header(def_id).map_or(ty::ImplPolarity::Positive, |h| h.polarity)
31723172
}
31733173

3174-
pub fn needs_coroutine_by_move_body_def_id(self, def_id: LocalDefId) -> bool {
3174+
pub fn needs_coroutine_by_move_body_def_id(self, def_id: DefId) -> bool {
31753175
if let Some(hir::CoroutineKind::Desugared(_, hir::CoroutineSource::Closure)) =
31763176
self.coroutine_kind(def_id)
31773177
&& let ty::Coroutine(_, args) = self.type_of(def_id).instantiate_identity().kind()

Diff for: compiler/rustc_mir_transform/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fn mir_promoted(
330330
tcx.ensure_with_value().has_ffi_unwind_calls(def);
331331

332332
// the `by_move_body` query uses the raw mir, so make sure it is run.
333-
if tcx.needs_coroutine_by_move_body_def_id(def) {
333+
if tcx.needs_coroutine_by_move_body_def_id(def.to_def_id()) {
334334
tcx.ensure_with_value().coroutine_by_move_body_def_id(def);
335335
}
336336

Diff for: compiler/rustc_mir_transform/src/validate.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Validates the MIR to ensure that invariants are upheld.
22
33
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
4-
use rustc_hir as hir;
54
use rustc_hir::LangItem;
65
use rustc_index::bit_set::BitSet;
76
use rustc_index::IndexVec;
@@ -717,10 +716,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
717716
// first place.
718717
let layout = if def_id == self.caller_body.source.def_id() {
719718
self.caller_body.coroutine_layout_raw()
720-
} else if let Some(hir::CoroutineKind::Desugared(
721-
_,
722-
hir::CoroutineSource::Closure,
723-
)) = self.tcx.coroutine_kind(def_id)
719+
} else if self.tcx.needs_coroutine_by_move_body_def_id(def_id)
724720
&& let ty::ClosureKind::FnOnce =
725721
args.as_coroutine().kind_ty().to_opt_closure_kind().unwrap()
726722
&& self.caller_body.source.def_id()

Diff for: src/bootstrap/src/core/build_steps/compile.rs

+47-39
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,49 @@ impl Step for Assemble {
17601760
return target_compiler;
17611761
}
17621762

1763+
// We prepend this bin directory to the user PATH when linking Rust binaries. To
1764+
// avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`.
1765+
let libdir = builder.sysroot_libdir(target_compiler, target_compiler.host);
1766+
let libdir_bin = libdir.parent().unwrap().join("bin");
1767+
t!(fs::create_dir_all(&libdir_bin));
1768+
1769+
if builder.config.llvm_enabled(target_compiler.host) {
1770+
let llvm::LlvmResult { llvm_config, .. } =
1771+
builder.ensure(llvm::Llvm { target: target_compiler.host });
1772+
if !builder.config.dry_run() && builder.config.llvm_tools_enabled {
1773+
let llvm_bin_dir =
1774+
command(llvm_config).arg("--bindir").run_capture_stdout(builder).stdout();
1775+
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());
1776+
1777+
// Since we've already built the LLVM tools, install them to the sysroot.
1778+
// This is the equivalent of installing the `llvm-tools-preview` component via
1779+
// rustup, and lets developers use a locally built toolchain to
1780+
// build projects that expect llvm tools to be present in the sysroot
1781+
// (e.g. the `bootimage` crate).
1782+
for tool in LLVM_TOOLS {
1783+
let tool_exe = exe(tool, target_compiler.host);
1784+
let src_path = llvm_bin_dir.join(&tool_exe);
1785+
// When using `download-ci-llvm`, some of the tools
1786+
// may not exist, so skip trying to copy them.
1787+
if src_path.exists() {
1788+
builder.copy_link(&src_path, &libdir_bin.join(&tool_exe));
1789+
}
1790+
}
1791+
}
1792+
}
1793+
1794+
let maybe_install_llvm_bitcode_linker = |compiler| {
1795+
if builder.config.llvm_bitcode_linker_enabled {
1796+
let src_path = builder.ensure(crate::core::build_steps::tool::LlvmBitcodeLinker {
1797+
compiler,
1798+
target: target_compiler.host,
1799+
extra_features: vec![],
1800+
});
1801+
let tool_exe = exe("llvm-bitcode-linker", target_compiler.host);
1802+
builder.copy_link(&src_path, &libdir_bin.join(tool_exe));
1803+
}
1804+
};
1805+
17631806
// If we're downloading a compiler from CI, we can use the same compiler for all stages other than 0.
17641807
if builder.download_rustc() {
17651808
builder.ensure(Std::new(target_compiler, target_compiler.host));
@@ -1772,6 +1815,9 @@ impl Step for Assemble {
17721815
if target_compiler.stage == builder.top_stage {
17731816
builder.info(&format!("Creating a sysroot for stage{stage} compiler (use `rustup toolchain link 'name' build/host/stage{stage}`)", stage=target_compiler.stage));
17741817
}
1818+
1819+
maybe_install_llvm_bitcode_linker(target_compiler);
1820+
17751821
return target_compiler;
17761822
}
17771823

@@ -1880,11 +1926,6 @@ impl Step for Assemble {
18801926

18811927
copy_codegen_backends_to_sysroot(builder, build_compiler, target_compiler);
18821928

1883-
// We prepend this bin directory to the user PATH when linking Rust binaries. To
1884-
// avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`.
1885-
let libdir = builder.sysroot_libdir(target_compiler, target_compiler.host);
1886-
let libdir_bin = libdir.parent().unwrap().join("bin");
1887-
t!(fs::create_dir_all(&libdir_bin));
18881929
if let Some(lld_install) = lld_install {
18891930
let src_exe = exe("lld", target_compiler.host);
18901931
let dst_exe = exe("rust-lld", target_compiler.host);
@@ -1920,40 +1961,7 @@ impl Step for Assemble {
19201961
);
19211962
}
19221963

1923-
if builder.config.llvm_enabled(target_compiler.host) {
1924-
let llvm::LlvmResult { llvm_config, .. } =
1925-
builder.ensure(llvm::Llvm { target: target_compiler.host });
1926-
if !builder.config.dry_run() && builder.config.llvm_tools_enabled {
1927-
let llvm_bin_dir =
1928-
command(llvm_config).arg("--bindir").run_capture_stdout(builder).stdout();
1929-
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());
1930-
1931-
// Since we've already built the LLVM tools, install them to the sysroot.
1932-
// This is the equivalent of installing the `llvm-tools-preview` component via
1933-
// rustup, and lets developers use a locally built toolchain to
1934-
// build projects that expect llvm tools to be present in the sysroot
1935-
// (e.g. the `bootimage` crate).
1936-
for tool in LLVM_TOOLS {
1937-
let tool_exe = exe(tool, target_compiler.host);
1938-
let src_path = llvm_bin_dir.join(&tool_exe);
1939-
// When using `download-ci-llvm`, some of the tools
1940-
// may not exist, so skip trying to copy them.
1941-
if src_path.exists() {
1942-
builder.copy_link(&src_path, &libdir_bin.join(&tool_exe));
1943-
}
1944-
}
1945-
}
1946-
}
1947-
1948-
if builder.config.llvm_bitcode_linker_enabled {
1949-
let src_path = builder.ensure(crate::core::build_steps::tool::LlvmBitcodeLinker {
1950-
compiler: build_compiler,
1951-
target: target_compiler.host,
1952-
extra_features: vec![],
1953-
});
1954-
let tool_exe = exe("llvm-bitcode-linker", target_compiler.host);
1955-
builder.copy_link(&src_path, &libdir_bin.join(tool_exe));
1956-
}
1964+
maybe_install_llvm_bitcode_linker(build_compiler);
19571965

19581966
// Ensure that `libLLVM.so` ends up in the newly build compiler directory,
19591967
// so that it can be found when the newly built `rustc` is run.

Diff for: src/bootstrap/src/core/config/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2739,6 +2739,8 @@ impl Config {
27392739
return false;
27402740
}
27412741

2742+
// Fetching the LLVM submodule is unnecessary for self-tests.
2743+
#[cfg(not(feature = "bootstrap-self-test"))]
27422744
self.update_submodule("src/llvm-project");
27432745

27442746
// Check for untracked changes in `src/llvm-project`.

Diff for: src/bootstrap/src/lib.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,14 @@ impl Build {
349349
};
350350
let Some(initial_libdir) = find_initial_libdir() else {
351351
panic!(
352-
"couldn't determine `initial_libdir` \
353-
from target dir {initial_target_dir:?} \
354-
and sysroot {initial_sysroot:?}"
355-
)
352+
"couldn't determine `initial_libdir`:
353+
- config.initial_rustc: {rustc:?}
354+
- initial_target_libdir_str: {initial_target_libdir_str:?}
355+
- initial_target_dir: {initial_target_dir:?}
356+
- initial_sysroot: {initial_sysroot:?}
357+
",
358+
rustc = config.initial_rustc,
359+
);
356360
};
357361

358362
let version = std::fs::read_to_string(src.join("src").join("version"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ aux-build:block-on.rs
2+
//@ edition:2021
3+
//@ build-pass
4+
5+
#![feature(async_closure)]
6+
7+
extern crate block_on;
8+
9+
// Make sure that we don't call `coroutine_by_move_body_def_id` query
10+
// on async closures that are `FnOnce`. See issue: #130167.
11+
12+
async fn empty() {}
13+
14+
pub async fn call_once<F: async FnOnce()>(f: F) {
15+
f().await;
16+
}
17+
18+
fn main() {
19+
block_on::block_on(call_once(async || empty().await));
20+
}

0 commit comments

Comments
 (0)