Skip to content

Commit f52c6ee

Browse files
committed
Another round of tidy / warning fixes
1 parent 4aa62ea commit f52c6ee

File tree

24 files changed

+120
-105
lines changed

24 files changed

+120
-105
lines changed

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_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` | `rustc_thread_pool::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_thread_pool/src/broadcast/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::job::{ArcJob, StackJob};
66
use crate::latch::{CountLatch, LatchRef};
77
use crate::registry::{Registry, WorkerThread};
88

9-
mod test;
9+
mod tests;
1010

1111
/// Executes `op` within every thread in the current threadpool. If this is
1212
/// called from a non-Rayon thread, it will execute in the global threadpool.
@@ -103,18 +103,18 @@ where
103103
};
104104

105105
let n_threads = registry.num_threads();
106-
let current_thread = WorkerThread::current().as_ref();
106+
let current_thread = unsafe { WorkerThread::current().as_ref() };
107107
let tlv = crate::tlv::get();
108108
let latch = CountLatch::with_count(n_threads, current_thread);
109109
let jobs: Vec<_> =
110110
(0..n_threads).map(|_| StackJob::new(tlv, &f, LatchRef::new(&latch))).collect();
111-
let job_refs = jobs.iter().map(|job| job.as_job_ref());
111+
let job_refs = jobs.iter().map(|job| unsafe { job.as_job_ref() });
112112

113113
registry.inject_broadcast(job_refs);
114114

115115
// Wait for all jobs to complete, then collect the results, maybe propagating a panic.
116116
latch.wait(current_thread);
117-
jobs.into_iter().map(|job| job.into_result()).collect()
117+
jobs.into_iter().map(|job| unsafe { job.into_result() }).collect()
118118
}
119119

120120
/// Execute `op` on every thread in the pool. It will be executed on each

compiler/rustc_thread_pool/src/compile_fail/quicksort_race1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn quick_sort<T:PartialOrd+Send>(v: &mut [T]) {
77
88
let mid = partition(v);
99
let (lo, _hi) = v.split_at_mut(mid);
10-
rustc_thred_pool::join(|| quick_sort(lo), || quick_sort(lo)); //~ ERROR
10+
rustc_thread_pool::join(|| quick_sort(lo), || quick_sort(lo)); //~ ERROR
1111
}
1212
1313
fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {

compiler/rustc_thread_pool/src/compile_fail/quicksort_race2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn quick_sort<T:PartialOrd+Send>(v: &mut [T]) {
77
88
let mid = partition(v);
99
let (lo, _hi) = v.split_at_mut(mid);
10-
rustc_thred_pool::join(|| quick_sort(lo), || quick_sort(v)); //~ ERROR
10+
rustc_thread_pool::join(|| quick_sort(lo), || quick_sort(v)); //~ ERROR
1111
}
1212
1313
fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {

compiler/rustc_thread_pool/src/compile_fail/quicksort_race3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn quick_sort<T:PartialOrd+Send>(v: &mut [T]) {
77
88
let mid = partition(v);
99
let (_lo, hi) = v.split_at_mut(mid);
10-
rustc_thred_pool::join(|| quick_sort(hi), || quick_sort(hi)); //~ ERROR
10+
rustc_thread_pool::join(|| quick_sort(hi), || quick_sort(hi)); //~ ERROR
1111
}
1212
1313
fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {

compiler/rustc_thread_pool/src/compile_fail/rc_return.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::rc::Rc;
44
5-
rustc_thred_pool::join(|| Rc::new(22), || ()); //~ ERROR
5+
rustc_thread_pool::join(|| Rc::new(22), || ()); //~ ERROR
66
77
``` */
88
mod left {}
@@ -11,7 +11,7 @@ mod left {}
1111
1212
use std::rc::Rc;
1313
14-
rustc_thred_pool::join(|| (), || Rc::new(23)); //~ ERROR
14+
rustc_thread_pool::join(|| (), || Rc::new(23)); //~ ERROR
1515
1616
``` */
1717
mod right {}

compiler/rustc_thread_pool/src/compile_fail/rc_upvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::rc::Rc;
44
55
let r = Rc::new(22);
6-
rustc_thred_pool::join(|| r.clone(), || r.clone());
6+
rustc_thread_pool::join(|| r.clone(), || r.clone());
77
//~^ ERROR
88
99
``` */

compiler/rustc_thread_pool/src/compile_fail/scope_join_bad.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
fn bad_scope<F>(f: F)
44
where F: FnOnce(&i32) + Send,
55
{
6-
rustc_thred_pool::scope(|s| {
6+
rustc_thread_pool::scope(|s| {
77
let x = 22;
88
s.spawn(|_| f(&x)); //~ ERROR `x` does not live long enough
99
});
@@ -13,7 +13,7 @@ fn good_scope<F>(f: F)
1313
where F: FnOnce(&i32) + Send,
1414
{
1515
let x = 22;
16-
rustc_thred_pool::scope(|s| {
16+
rustc_thread_pool::scope(|s| {
1717
s.spawn(|_| f(&x));
1818
});
1919
}

compiler/rustc_thread_pool/src/job.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl JobRef {
6161

6262
#[inline]
6363
pub(super) unsafe fn execute(self) {
64-
(self.execute_fn)(self.pointer)
64+
unsafe { (self.execute_fn)(self.pointer) }
6565
}
6666
}
6767

@@ -97,7 +97,7 @@ where
9797
}
9898

9999
pub(super) unsafe fn as_job_ref(&self) -> JobRef {
100-
JobRef::new(self)
100+
unsafe { JobRef::new(self) }
101101
}
102102

103103
pub(super) unsafe fn run_inline(self, stolen: bool) -> R {
@@ -116,12 +116,16 @@ where
116116
R: Send,
117117
{
118118
unsafe fn execute(this: *const ()) {
119-
let this = &*(this as *const Self);
119+
let this = unsafe { &*(this as *const Self) };
120120
tlv::set(this.tlv);
121121
let abort = unwind::AbortIfPanic;
122-
let func = (*this.func.get()).take().unwrap();
123-
(*this.result.get()) = JobResult::call(func);
124-
Latch::set(&this.latch);
122+
let func = unsafe { (*this.func.get()).take().unwrap() };
123+
unsafe {
124+
(*this.result.get()) = JobResult::call(func);
125+
}
126+
unsafe {
127+
Latch::set(&this.latch);
128+
}
125129
mem::forget(abort);
126130
}
127131
}
@@ -152,7 +156,7 @@ where
152156
/// lifetimes, so it is up to you to ensure that this JobRef
153157
/// doesn't outlive any data that it closes over.
154158
pub(super) unsafe fn into_job_ref(self: Box<Self>) -> JobRef {
155-
JobRef::new(Box::into_raw(self))
159+
unsafe { JobRef::new(Box::into_raw(self)) }
156160
}
157161

158162
/// Creates a static `JobRef` from this job.
@@ -169,7 +173,7 @@ where
169173
BODY: FnOnce() + Send,
170174
{
171175
unsafe fn execute(this: *const ()) {
172-
let this = Box::from_raw(this as *mut Self);
176+
let this = unsafe { Box::from_raw(this as *mut Self) };
173177
tlv::set(this.tlv);
174178
(this.job)();
175179
}
@@ -196,7 +200,7 @@ where
196200
/// lifetimes, so it is up to you to ensure that this JobRef
197201
/// doesn't outlive any data that it closes over.
198202
pub(super) unsafe fn as_job_ref(this: &Arc<Self>) -> JobRef {
199-
JobRef::new(Arc::into_raw(Arc::clone(this)))
203+
unsafe { JobRef::new(Arc::into_raw(Arc::clone(this))) }
200204
}
201205

202206
/// Creates a static `JobRef` from this job.
@@ -213,7 +217,7 @@ where
213217
BODY: Fn() + Send + Sync,
214218
{
215219
unsafe fn execute(this: *const ()) {
216-
let this = Arc::from_raw(this as *mut Self);
220+
let this = unsafe { Arc::from_raw(this as *mut Self) };
217221
(this.job)();
218222
}
219223
}
@@ -254,17 +258,17 @@ impl JobFifo {
254258
// jobs in a thread's deque may be popped from the back (LIFO) or stolen from the front
255259
// (FIFO), but either way they will end up popping from the front of this queue.
256260
self.inner.push(job_ref);
257-
JobRef::new(self)
261+
unsafe { JobRef::new(self) }
258262
}
259263
}
260264

261265
impl Job for JobFifo {
262266
unsafe fn execute(this: *const ()) {
263267
// We "execute" a queue by executing its first job, FIFO.
264-
let this = &*(this as *const Self);
268+
let this = unsafe { &*(this as *const Self) };
265269
loop {
266270
match this.inner.steal() {
267-
Steal::Success(job_ref) => break job_ref.execute(),
271+
Steal::Success(job_ref) => break unsafe { job_ref.execute() },
268272
Steal::Empty => panic!("FIFO is empty"),
269273
Steal::Retry => {}
270274
}

0 commit comments

Comments
 (0)