Skip to content

Rollup of 8 pull requests #142814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jun 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
35c5144
Move rayon-core to rustc_thread_pool files as is
celinval Jun 11, 2025
0b9b1df
Fix format and tidy for code moved from rayon
celinval Jun 11, 2025
4aa62ea
Use `rustc_thread_pool` instead of `rustc-rayon-core`
celinval Jun 11, 2025
f52c6ee
Another round of tidy / warning fixes
celinval Jun 11, 2025
52167e0
Marks ADT live if it appears in pattern
mu001999 Jun 14, 2025
71afc6f
Add test.
cjgillot Jun 16, 2025
c4b67c6
Reason about borrowed classes in CopyProp.
cjgillot Jun 16, 2025
6da3bf8
Apply suggestions from code review
celinval Jun 16, 2025
41ca0cb
Adjust `with_generic_param_rib`.
nnethercote Jun 19, 2025
1ed0cbf
Preserve Paren expression's attributes during Unparenthesize
dtolnay Jun 13, 2025
9185143
Make `Clone` a `const_trait`
Daniel-Aaron-Bloom Jun 19, 2025
867d001
rustc_target: document public AbiMap-related fn and variants
workingjubilee Jun 17, 2025
2180503
Add CI check to ensure that rustdoc JSON `FORMAT_VERSION` is correctl…
GuillaumeGomez Jun 18, 2025
bbe8a2a
Generate base commit in rustdoc_json tidy checks
GuillaumeGomez Jun 19, 2025
6367694
Pass `src_path` to rustdoc_json tidy check
GuillaumeGomez Jun 20, 2025
0fc9507
Improve error message for rustdoc_json_types tidy check
GuillaumeGomez Jun 20, 2025
cbef8f6
Add AST pretty-printer tests involving attr on binary operation
dtolnay Jun 13, 2025
12a855d
Insert parentheses around binary operation with attribute
dtolnay Jun 13, 2025
535e11f
Add an attribute-related parenthesization edge case
dtolnay Jun 13, 2025
7b35511
Rollup merge of #142384 - celinval:chores-rayon-mv, r=oli-obk
tgross35 Jun 21, 2025
8751016
Rollup merge of #142476 - dtolnay:attrbinop, r=fmease
tgross35 Jun 21, 2025
c93fac7
Rollup merge of #142485 - mu001999-contrib:dead-code/adt-pattern, r=p…
tgross35 Jun 21, 2025
4455d1e
Rollup merge of #142571 - cjgillot:borrowed-classes, r=oli-obk
tgross35 Jun 21, 2025
cd85b9d
Rollup merge of #142677 - GuillaumeGomez:check-format-version-update,…
tgross35 Jun 21, 2025
44d50f9
Rollup merge of #142716 - nnethercote:adjust-with_generic_param_rib, …
tgross35 Jun 21, 2025
c386ffb
Rollup merge of #142756 - Daniel-Aaron-Bloom:const-clone, r=oli-obk
tgross35 Jun 21, 2025
432c7d0
Rollup merge of #142765 - workingjubilee:more-abimap-docs, r=compiler…
tgross35 Jun 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2983,6 +2983,15 @@ dependencies = [
"getrandom 0.3.3",
]

[[package]]
name = "rand_xorshift"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a"
dependencies = [
"rand_core 0.9.3",
]

[[package]]
name = "rand_xoshiro"
version = "0.7.0"
Expand Down Expand Up @@ -3182,16 +3191,6 @@ dependencies = [
"tikv-jemalloc-sys",
]

[[package]]
name = "rustc-rayon-core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f42932dcd3bcbe484b38a3ccf79b7906fac41c02d408b5b1bac26da3416efdb"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]

[[package]]
name = "rustc-semver"
version = "1.1.0"
Expand Down Expand Up @@ -3558,14 +3557,14 @@ dependencies = [
"parking_lot",
"portable-atomic",
"rustc-hash 2.1.1",
"rustc-rayon-core",
"rustc-stable-hash",
"rustc_arena",
"rustc_graphviz",
"rustc_hashes",
"rustc_index",
"rustc_macros",
"rustc_serialize",
"rustc_thread_pool",
"smallvec",
"stacker",
"tempfile",
Expand Down Expand Up @@ -3913,7 +3912,6 @@ dependencies = [
name = "rustc_interface"
version = "0.0.0"
dependencies = [
"rustc-rayon-core",
"rustc_abi",
"rustc_ast",
"rustc_ast_lowering",
Expand Down Expand Up @@ -3952,6 +3950,7 @@ dependencies = [
"rustc_span",
"rustc_symbol_mangling",
"rustc_target",
"rustc_thread_pool",
"rustc_trait_selection",
"rustc_traits",
"rustc_ty_utils",
Expand Down Expand Up @@ -4079,7 +4078,6 @@ dependencies = [
"either",
"gsgdt",
"polonius-engine",
"rustc-rayon-core",
"rustc_abi",
"rustc_apfloat",
"rustc_arena",
Expand All @@ -4103,6 +4101,7 @@ dependencies = [
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_thread_pool",
"rustc_type_ir",
"smallvec",
"thin-vec",
Expand Down Expand Up @@ -4349,7 +4348,6 @@ version = "0.0.0"
dependencies = [
"hashbrown",
"parking_lot",
"rustc-rayon-core",
"rustc_abi",
"rustc_ast",
"rustc_attr_data_structures",
Expand All @@ -4364,6 +4362,7 @@ dependencies = [
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_thread_pool",
"smallvec",
"tracing",
]
Expand Down Expand Up @@ -4525,6 +4524,18 @@ dependencies = [
"tracing",
]

[[package]]
name = "rustc_thread_pool"
version = "0.0.0"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
"libc",
"rand 0.9.1",
"rand_xorshift",
"scoped-tls",
]

[[package]]
name = "rustc_tools_util"
version = "0.4.2"
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ exclude = [
"obj",
]

[profile.release.package.rustc-rayon-core]
[profile.release.package.rustc_thread_pool]
# The rustc fork of Rayon has deadlock detection code which intermittently
# causes overflows in the CI (see https://github.com/rust-lang/rust/issues/90227)
# so we turn overflow checks off for now.
Expand Down
50 changes: 38 additions & 12 deletions compiler/rustc_ast_pretty/src/pprust/state/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,18 +386,44 @@ impl<'a> State<'a> {

let ib = self.ibox(INDENT_UNIT);

// The Match subexpression in `match x {} - 1` must be parenthesized if
// it is the leftmost subexpression in a statement:
//
// (match x {}) - 1;
//
// But not otherwise:
//
// let _ = match x {} - 1;
//
// Same applies to a small set of other expression kinds which eagerly
// terminate a statement which opens with them.
let needs_par = fixup.would_cause_statement_boundary(expr);
let needs_par = {
// The Match subexpression in `match x {} - 1` must be parenthesized
// if it is the leftmost subexpression in a statement:
//
// (match x {}) - 1;
//
// But not otherwise:
//
// let _ = match x {} - 1;
//
// Same applies to a small set of other expression kinds which
// eagerly terminate a statement which opens with them.
fixup.would_cause_statement_boundary(expr)
} || {
// If a binary operation ends up with an attribute, such as
// resulting from the following macro expansion, then parentheses
// are required so that the attribute encompasses the right
// subexpression and not just the left one.
//
// #![feature(stmt_expr_attributes)]
//
// macro_rules! add_attr {
// ($e:expr) => { #[attr] $e };
// }
//
// let _ = add_attr!(1 + 1);
//
// We must pretty-print `#[attr] (1 + 1)` not `#[attr] 1 + 1`.
!attrs.is_empty()
&& matches!(
expr.kind,
ast::ExprKind::Binary(..)
| ast::ExprKind::Cast(..)
| ast::ExprKind::Assign(..)
| ast::ExprKind::AssignOp(..)
| ast::ExprKind::Range(..)
)
};
if needs_par {
self.popen();
fixup = FixupContext::default();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ indexmap = "2.4.0"
jobserver_crate = { version = "0.1.28", package = "jobserver" }
measureme = "12.0.1"
rustc-hash = "2.0.0"
rustc-rayon-core = { version = "0.5.0" }
rustc-stable-hash = { version = "0.1.0", features = ["nightly"] }
rustc_arena = { path = "../rustc_arena" }
rustc_graphviz = { path = "../rustc_graphviz" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_index = { path = "../rustc_index", package = "rustc_index" }
rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_thread_pool = { path = "../rustc_thread_pool" }
smallvec = { version = "1.8.1", features = ["const_generics", "union", "may_dangle"] }
stacker = "0.1.17"
tempfile = "3.2"
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_data_structures/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
//! | | | `parking_lot::Mutex<T>` |
//! | `RwLock<T>` | `RefCell<T>` | `parking_lot::RwLock<T>` |
//! | `MTLock<T>` [^1] | `T` | `Lock<T>` |
//! | | | |
//! | `ParallelIterator` | `Iterator` | `rayon::iter::ParallelIterator` |
//!
//! [^1]: `MTLock` is similar to `Lock`, but the serial version avoids the cost
//! of a `RefCell`. This is appropriate when interior mutability is not
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_data_structures/src/sync/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ macro_rules! parallel {
pub fn spawn(func: impl FnOnce() + DynSend + 'static) {
if mode::is_dyn_thread_safe() {
let func = FromDyn::from(func);
rayon_core::spawn(|| {
rustc_thread_pool::spawn(|| {
(func.into_inner())();
});
} else {
Expand All @@ -107,11 +107,11 @@ pub fn spawn(func: impl FnOnce() + DynSend + 'static) {
// This function only works when `mode::is_dyn_thread_safe()`.
pub fn scope<'scope, OP, R>(op: OP) -> R
where
OP: FnOnce(&rayon_core::Scope<'scope>) -> R + DynSend,
OP: FnOnce(&rustc_thread_pool::Scope<'scope>) -> R + DynSend,
R: DynSend,
{
let op = FromDyn::from(op);
rayon_core::scope(|s| FromDyn::from(op.into_inner()(s))).into_inner()
rustc_thread_pool::scope(|s| FromDyn::from(op.into_inner()(s))).into_inner()
}

#[inline]
Expand All @@ -124,7 +124,7 @@ where
let oper_a = FromDyn::from(oper_a);
let oper_b = FromDyn::from(oper_b);
let (a, b) = parallel_guard(|guard| {
rayon_core::join(
rustc_thread_pool::join(
move || guard.run(move || FromDyn::from(oper_a.into_inner()())),
move || guard.run(move || FromDyn::from(oper_b.into_inner()())),
)
Expand Down Expand Up @@ -158,7 +158,7 @@ fn par_slice<I: DynSend>(
let (left, right) = items.split_at_mut(items.len() / 2);
let mut left = state.for_each.derive(left);
let mut right = state.for_each.derive(right);
rayon_core::join(move || par_rec(*left, state), move || par_rec(*right, state));
rustc_thread_pool::join(move || par_rec(*left, state), move || par_rec(*right, state));
}
}

Expand Down Expand Up @@ -241,7 +241,7 @@ pub fn par_map<I: DynSend, T: IntoIterator<Item = I>, R: DynSend, C: FromIterato
pub fn broadcast<R: DynSend>(op: impl Fn(usize) -> R + DynSync) -> Vec<R> {
if mode::is_dyn_thread_safe() {
let op = FromDyn::from(op);
let results = rayon_core::broadcast(|context| op.derive(op(context.index())));
let results = rustc_thread_pool::broadcast(|context| op.derive(op(context.index())));
results.into_iter().map(|r| r.into_inner()).collect()
} else {
vec![op(0)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ edition = "2024"

[dependencies]
# tidy-alphabetical-start
rustc-rayon-core = { version = "0.5.0" }
rustc_ast = { path = "../rustc_ast" }
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
rustc_ast_passes = { path = "../rustc_ast_passes" }
Expand Down Expand Up @@ -43,6 +42,7 @@ rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }
rustc_target = { path = "../rustc_target" }
rustc_thread_pool = { path = "../rustc_thread_pool" }
rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_traits = { path = "../rustc_traits" }
rustc_ty_utils = { path = "../rustc_ty_utils" }
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub(crate) fn run_in_thread_pool_with_globals<

let proxy_ = Arc::clone(&proxy);
let proxy__ = Arc::clone(&proxy);
let builder = rayon_core::ThreadPoolBuilder::new()
let builder = rustc_thread_pool::ThreadPoolBuilder::new()
.thread_name(|_| "rustc".to_string())
.acquire_thread_handler(move || proxy_.acquire_thread())
.release_thread_handler(move || proxy__.release_thread())
Expand All @@ -218,7 +218,7 @@ pub(crate) fn run_in_thread_pool_with_globals<
// locals to it. The new thread runs the deadlock handler.

let current_gcx2 = current_gcx2.clone();
let registry = rayon_core::Registry::current();
let registry = rustc_thread_pool::Registry::current();
let session_globals = rustc_span::with_session_globals(|session_globals| {
session_globals as *const SessionGlobals as usize
});
Expand Down Expand Up @@ -265,7 +265,7 @@ pub(crate) fn run_in_thread_pool_with_globals<
builder
.build_scoped(
// Initialize each new worker thread when created.
move |thread: rayon_core::ThreadBuilder| {
move |thread: rustc_thread_pool::ThreadBuilder| {
// Register the thread for use with the `WorkerLocal` type.
registry.register();

Expand All @@ -274,7 +274,7 @@ pub(crate) fn run_in_thread_pool_with_globals<
})
},
// Run `f` on the first thread in the thread pool.
move |pool: &rayon_core::ThreadPool| {
move |pool: &rustc_thread_pool::ThreadPool| {
pool.install(|| f(current_gcx.into_inner(), proxy))
},
)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ bitflags = "2.4.1"
either = "1.5.0"
gsgdt = "0.1.2"
polonius-engine = "0.13.0"
rustc-rayon-core = { version = "0.5.0" }
rustc_abi = { path = "../rustc_abi" }
rustc_apfloat = "0.2.0"
rustc_arena = { path = "../rustc_arena" }
Expand All @@ -33,6 +32,7 @@ rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
rustc_thread_pool = { path = "../rustc_thread_pool" }
rustc_type_ir = { path = "../rustc_type_ir" }
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
thin-vec = "0.2.12"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/context/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a, 'tcx> ImplicitCtxt<'a, 'tcx> {
}

// Import the thread-local variable from Rayon, which is preserved for Rayon jobs.
use rayon_core::tlv::TLV;
use rustc_thread_pool::tlv::TLV;

#[inline]
fn erase(context: &ImplicitCtxt<'_, '_>) -> *const () {
Expand Down
Loading
Loading