Skip to content

Commit df4ad9e

Browse files
committed
Auto merge of #142814 - tgross35:rollup-fioob6s, r=tgross35
Rollup of 8 pull requests Successful merges: - #142384 (Bringing `rustc_rayon_core` in tree as `rustc_thread_pool`) - #142476 (Insert parentheses around binary operation with attribute) - #142485 (Marks ADT live if it appears in pattern) - #142571 (Reason about borrowed classes in CopyProp.) - #142677 (Add CI check to ensure that rustdoc JSON `FORMAT_VERSION` is correctly updated) - #142716 (Adjust `with_generic_param_rib`.) - #142756 (Make `Clone` a `const_trait`) - #142765 (rustc_target: document public AbiMap-related fn and variants) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 15c701f + 432c7d0 commit df4ad9e

File tree

88 files changed

+8440
-267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+8440
-267
lines changed

Cargo.lock

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,6 +2983,15 @@ dependencies = [
29832983
"getrandom 0.3.3",
29842984
]
29852985

2986+
[[package]]
2987+
name = "rand_xorshift"
2988+
version = "0.4.0"
2989+
source = "registry+https://github.com/rust-lang/crates.io-index"
2990+
checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a"
2991+
dependencies = [
2992+
"rand_core 0.9.3",
2993+
]
2994+
29862995
[[package]]
29872996
name = "rand_xoshiro"
29882997
version = "0.7.0"
@@ -3182,16 +3191,6 @@ dependencies = [
31823191
"tikv-jemalloc-sys",
31833192
]
31843193

3185-
[[package]]
3186-
name = "rustc-rayon-core"
3187-
version = "0.5.1"
3188-
source = "registry+https://github.com/rust-lang/crates.io-index"
3189-
checksum = "2f42932dcd3bcbe484b38a3ccf79b7906fac41c02d408b5b1bac26da3416efdb"
3190-
dependencies = [
3191-
"crossbeam-deque",
3192-
"crossbeam-utils",
3193-
]
3194-
31953194
[[package]]
31963195
name = "rustc-semver"
31973196
version = "1.1.0"
@@ -3558,14 +3557,14 @@ dependencies = [
35583557
"parking_lot",
35593558
"portable-atomic",
35603559
"rustc-hash 2.1.1",
3561-
"rustc-rayon-core",
35623560
"rustc-stable-hash",
35633561
"rustc_arena",
35643562
"rustc_graphviz",
35653563
"rustc_hashes",
35663564
"rustc_index",
35673565
"rustc_macros",
35683566
"rustc_serialize",
3567+
"rustc_thread_pool",
35693568
"smallvec",
35703569
"stacker",
35713570
"tempfile",
@@ -3913,7 +3912,6 @@ dependencies = [
39133912
name = "rustc_interface"
39143913
version = "0.0.0"
39153914
dependencies = [
3916-
"rustc-rayon-core",
39173915
"rustc_abi",
39183916
"rustc_ast",
39193917
"rustc_ast_lowering",
@@ -3952,6 +3950,7 @@ dependencies = [
39523950
"rustc_span",
39533951
"rustc_symbol_mangling",
39543952
"rustc_target",
3953+
"rustc_thread_pool",
39553954
"rustc_trait_selection",
39563955
"rustc_traits",
39573956
"rustc_ty_utils",
@@ -4079,7 +4078,6 @@ dependencies = [
40794078
"either",
40804079
"gsgdt",
40814080
"polonius-engine",
4082-
"rustc-rayon-core",
40834081
"rustc_abi",
40844082
"rustc_apfloat",
40854083
"rustc_arena",
@@ -4103,6 +4101,7 @@ dependencies = [
41034101
"rustc_session",
41044102
"rustc_span",
41054103
"rustc_target",
4104+
"rustc_thread_pool",
41064105
"rustc_type_ir",
41074106
"smallvec",
41084107
"thin-vec",
@@ -4349,7 +4348,6 @@ version = "0.0.0"
43494348
dependencies = [
43504349
"hashbrown",
43514350
"parking_lot",
4352-
"rustc-rayon-core",
43534351
"rustc_abi",
43544352
"rustc_ast",
43554353
"rustc_attr_data_structures",
@@ -4364,6 +4362,7 @@ dependencies = [
43644362
"rustc_serialize",
43654363
"rustc_session",
43664364
"rustc_span",
4365+
"rustc_thread_pool",
43674366
"smallvec",
43684367
"tracing",
43694368
]
@@ -4525,6 +4524,18 @@ dependencies = [
45254524
"tracing",
45264525
]
45274526

4527+
[[package]]
4528+
name = "rustc_thread_pool"
4529+
version = "0.0.0"
4530+
dependencies = [
4531+
"crossbeam-deque",
4532+
"crossbeam-utils",
4533+
"libc",
4534+
"rand 0.9.1",
4535+
"rand_xorshift",
4536+
"scoped-tls",
4537+
]
4538+
45284539
[[package]]
45294540
name = "rustc_tools_util"
45304541
version = "0.4.2"

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ exclude = [
6060
"obj",
6161
]
6262

63-
[profile.release.package.rustc-rayon-core]
63+
[profile.release.package.rustc_thread_pool]
6464
# The rustc fork of Rayon has deadlock detection code which intermittently
6565
# causes overflows in the CI (see https://github.com/rust-lang/rust/issues/90227)
6666
# so we turn overflow checks off for now.

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -386,18 +386,44 @@ impl<'a> State<'a> {
386386

387387
let ib = self.ibox(INDENT_UNIT);
388388

389-
// The Match subexpression in `match x {} - 1` must be parenthesized if
390-
// it is the leftmost subexpression in a statement:
391-
//
392-
// (match x {}) - 1;
393-
//
394-
// But not otherwise:
395-
//
396-
// let _ = match x {} - 1;
397-
//
398-
// Same applies to a small set of other expression kinds which eagerly
399-
// terminate a statement which opens with them.
400-
let needs_par = fixup.would_cause_statement_boundary(expr);
389+
let needs_par = {
390+
// The Match subexpression in `match x {} - 1` must be parenthesized
391+
// if it is the leftmost subexpression in a statement:
392+
//
393+
// (match x {}) - 1;
394+
//
395+
// But not otherwise:
396+
//
397+
// let _ = match x {} - 1;
398+
//
399+
// Same applies to a small set of other expression kinds which
400+
// eagerly terminate a statement which opens with them.
401+
fixup.would_cause_statement_boundary(expr)
402+
} || {
403+
// If a binary operation ends up with an attribute, such as
404+
// resulting from the following macro expansion, then parentheses
405+
// are required so that the attribute encompasses the right
406+
// subexpression and not just the left one.
407+
//
408+
// #![feature(stmt_expr_attributes)]
409+
//
410+
// macro_rules! add_attr {
411+
// ($e:expr) => { #[attr] $e };
412+
// }
413+
//
414+
// let _ = add_attr!(1 + 1);
415+
//
416+
// We must pretty-print `#[attr] (1 + 1)` not `#[attr] 1 + 1`.
417+
!attrs.is_empty()
418+
&& matches!(
419+
expr.kind,
420+
ast::ExprKind::Binary(..)
421+
| ast::ExprKind::Cast(..)
422+
| ast::ExprKind::Assign(..)
423+
| ast::ExprKind::AssignOp(..)
424+
| ast::ExprKind::Range(..)
425+
)
426+
};
401427
if needs_par {
402428
self.popen();
403429
fixup = FixupContext::default();

compiler/rustc_data_structures/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ indexmap = "2.4.0"
1414
jobserver_crate = { version = "0.1.28", package = "jobserver" }
1515
measureme = "12.0.1"
1616
rustc-hash = "2.0.0"
17-
rustc-rayon-core = { version = "0.5.0" }
1817
rustc-stable-hash = { version = "0.1.0", features = ["nightly"] }
1918
rustc_arena = { path = "../rustc_arena" }
2019
rustc_graphviz = { path = "../rustc_graphviz" }
2120
rustc_hashes = { path = "../rustc_hashes" }
2221
rustc_index = { path = "../rustc_index", package = "rustc_index" }
2322
rustc_macros = { path = "../rustc_macros" }
2423
rustc_serialize = { path = "../rustc_serialize" }
24+
rustc_thread_pool = { path = "../rustc_thread_pool" }
2525
smallvec = { version = "1.8.1", features = ["const_generics", "union", "may_dangle"] }
2626
stacker = "0.1.17"
2727
tempfile = "3.2"

compiler/rustc_data_structures/src/sync.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
//! | | | `parking_lot::Mutex<T>` |
2323
//! | `RwLock<T>` | `RefCell<T>` | `parking_lot::RwLock<T>` |
2424
//! | `MTLock<T>` [^1] | `T` | `Lock<T>` |
25-
//! | | | |
26-
//! | `ParallelIterator` | `Iterator` | `rayon::iter::ParallelIterator` |
2725
//!
2826
//! [^1]: `MTLock` is similar to `Lock`, but the serial version avoids the cost
2927
//! of a `RefCell`. This is appropriate when interior mutability is not

compiler/rustc_data_structures/src/sync/parallel.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ macro_rules! parallel {
9696
pub fn spawn(func: impl FnOnce() + DynSend + 'static) {
9797
if mode::is_dyn_thread_safe() {
9898
let func = FromDyn::from(func);
99-
rayon_core::spawn(|| {
99+
rustc_thread_pool::spawn(|| {
100100
(func.into_inner())();
101101
});
102102
} else {
@@ -107,11 +107,11 @@ pub fn spawn(func: impl FnOnce() + DynSend + 'static) {
107107
// This function only works when `mode::is_dyn_thread_safe()`.
108108
pub fn scope<'scope, OP, R>(op: OP) -> R
109109
where
110-
OP: FnOnce(&rayon_core::Scope<'scope>) -> R + DynSend,
110+
OP: FnOnce(&rustc_thread_pool::Scope<'scope>) -> R + DynSend,
111111
R: DynSend,
112112
{
113113
let op = FromDyn::from(op);
114-
rayon_core::scope(|s| FromDyn::from(op.into_inner()(s))).into_inner()
114+
rustc_thread_pool::scope(|s| FromDyn::from(op.into_inner()(s))).into_inner()
115115
}
116116

117117
#[inline]
@@ -124,7 +124,7 @@ where
124124
let oper_a = FromDyn::from(oper_a);
125125
let oper_b = FromDyn::from(oper_b);
126126
let (a, b) = parallel_guard(|guard| {
127-
rayon_core::join(
127+
rustc_thread_pool::join(
128128
move || guard.run(move || FromDyn::from(oper_a.into_inner()())),
129129
move || guard.run(move || FromDyn::from(oper_b.into_inner()())),
130130
)
@@ -158,7 +158,7 @@ fn par_slice<I: DynSend>(
158158
let (left, right) = items.split_at_mut(items.len() / 2);
159159
let mut left = state.for_each.derive(left);
160160
let mut right = state.for_each.derive(right);
161-
rayon_core::join(move || par_rec(*left, state), move || par_rec(*right, state));
161+
rustc_thread_pool::join(move || par_rec(*left, state), move || par_rec(*right, state));
162162
}
163163
}
164164

@@ -241,7 +241,7 @@ pub fn par_map<I: DynSend, T: IntoIterator<Item = I>, R: DynSend, C: FromIterato
241241
pub fn broadcast<R: DynSend>(op: impl Fn(usize) -> R + DynSync) -> Vec<R> {
242242
if mode::is_dyn_thread_safe() {
243243
let op = FromDyn::from(op);
244-
let results = rayon_core::broadcast(|context| op.derive(op(context.index())));
244+
let results = rustc_thread_pool::broadcast(|context| op.derive(op(context.index())));
245245
results.into_iter().map(|r| r.into_inner()).collect()
246246
} else {
247247
vec![op(0)]

compiler/rustc_interface/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
rustc-rayon-core = { version = "0.5.0" }
98
rustc_ast = { path = "../rustc_ast" }
109
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
1110
rustc_ast_passes = { path = "../rustc_ast_passes" }
@@ -43,6 +42,7 @@ rustc_session = { path = "../rustc_session" }
4342
rustc_span = { path = "../rustc_span" }
4443
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }
4544
rustc_target = { path = "../rustc_target" }
45+
rustc_thread_pool = { path = "../rustc_thread_pool" }
4646
rustc_trait_selection = { path = "../rustc_trait_selection" }
4747
rustc_traits = { path = "../rustc_traits" }
4848
rustc_ty_utils = { path = "../rustc_ty_utils" }

compiler/rustc_interface/src/util.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub(crate) fn run_in_thread_pool_with_globals<
208208

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

220220
let current_gcx2 = current_gcx2.clone();
221-
let registry = rayon_core::Registry::current();
221+
let registry = rustc_thread_pool::Registry::current();
222222
let session_globals = rustc_span::with_session_globals(|session_globals| {
223223
session_globals as *const SessionGlobals as usize
224224
});
@@ -265,7 +265,7 @@ pub(crate) fn run_in_thread_pool_with_globals<
265265
builder
266266
.build_scoped(
267267
// Initialize each new worker thread when created.
268-
move |thread: rayon_core::ThreadBuilder| {
268+
move |thread: rustc_thread_pool::ThreadBuilder| {
269269
// Register the thread for use with the `WorkerLocal` type.
270270
registry.register();
271271

@@ -274,7 +274,7 @@ pub(crate) fn run_in_thread_pool_with_globals<
274274
})
275275
},
276276
// Run `f` on the first thread in the thread pool.
277-
move |pool: &rayon_core::ThreadPool| {
277+
move |pool: &rustc_thread_pool::ThreadPool| {
278278
pool.install(|| f(current_gcx.into_inner(), proxy))
279279
},
280280
)

compiler/rustc_middle/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ bitflags = "2.4.1"
99
either = "1.5.0"
1010
gsgdt = "0.1.2"
1111
polonius-engine = "0.13.0"
12-
rustc-rayon-core = { version = "0.5.0" }
1312
rustc_abi = { path = "../rustc_abi" }
1413
rustc_apfloat = "0.2.0"
1514
rustc_arena = { path = "../rustc_arena" }
@@ -33,6 +32,7 @@ rustc_serialize = { path = "../rustc_serialize" }
3332
rustc_session = { path = "../rustc_session" }
3433
rustc_span = { path = "../rustc_span" }
3534
rustc_target = { path = "../rustc_target" }
35+
rustc_thread_pool = { path = "../rustc_thread_pool" }
3636
rustc_type_ir = { path = "../rustc_type_ir" }
3737
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
3838
thin-vec = "0.2.12"

compiler/rustc_middle/src/ty/context/tls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a, 'tcx> ImplicitCtxt<'a, 'tcx> {
3636
}
3737

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

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

0 commit comments

Comments
 (0)