Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 29932f3

Browse files
committedJun 5, 2024
Auto merge of rust-lang#126038 - matthiaskrgr:rollup-h4rm3x2, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#124840 (resolve: mark it undetermined if single import is not has any bindings) - rust-lang#125622 (Winnow private method candidates instead of assuming any candidate of the right name will apply) - rust-lang#125648 (Remove unused(?) `~/rustsrc` folder from docker script) - rust-lang#125672 (Add more ABI test cases to miri (RFC 3391)) - rust-lang#125800 (Fix `mut` static task queue in SGX target) - rust-lang#125871 (Orphanck[old solver]: Consider opaque types to never cover type parameters) - rust-lang#125893 (Handle all GVN binops in a single place.) - rust-lang#126008 (Port `tests/run-make-fulldeps/issue-19371` to ui-fulldeps) - rust-lang#126032 (Update description of the `IsTerminal` example) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ed91d55 + 4a81c12 commit 29932f3

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed
 

‎std/src/io/stdio.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1190,9 +1190,8 @@ pub trait IsTerminal: crate::sealed::Sealed {
11901190
///
11911191
/// - If you run this example by piping some text to it, e.g. `echo "foo" | path/to/executable`
11921192
/// it will print: `Hello foo`.
1193-
/// - If you instead run the example interactively by running the executable directly, it will
1194-
/// panic with the message "Expected input to be piped to the process".
1195-
///
1193+
/// - If you instead run the example interactively by running `path/to/executable` directly, it will
1194+
/// prompt for input.
11961195
///
11971196
/// [changes]: io#platform-specific-behavior
11981197
/// [`Stdin`]: crate::io::Stdin

‎std/src/sys/pal/sgx/thread.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub use self::task_queue::JoinNotifier;
1515

1616
mod task_queue {
1717
use super::wait_notify;
18-
use crate::sync::{Mutex, MutexGuard, Once};
18+
use crate::sync::{Mutex, MutexGuard};
1919

2020
pub type JoinHandle = wait_notify::Waiter;
2121

@@ -28,12 +28,12 @@ mod task_queue {
2828
}
2929

3030
pub(super) struct Task {
31-
p: Box<dyn FnOnce()>,
31+
p: Box<dyn FnOnce() + Send>,
3232
done: JoinNotifier,
3333
}
3434

3535
impl Task {
36-
pub(super) fn new(p: Box<dyn FnOnce()>) -> (Task, JoinHandle) {
36+
pub(super) fn new(p: Box<dyn FnOnce() + Send>) -> (Task, JoinHandle) {
3737
let (done, recv) = wait_notify::new();
3838
let done = JoinNotifier(Some(done));
3939
(Task { p, done }, recv)
@@ -45,18 +45,12 @@ mod task_queue {
4545
}
4646
}
4747

48-
#[cfg_attr(test, linkage = "available_externally")]
49-
#[export_name = "_ZN16__rust_internals3std3sys3sgx6thread15TASK_QUEUE_INITE"]
50-
static TASK_QUEUE_INIT: Once = Once::new();
5148
#[cfg_attr(test, linkage = "available_externally")]
5249
#[export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE"]
53-
static mut TASK_QUEUE: Option<Mutex<Vec<Task>>> = None;
50+
static TASK_QUEUE: Mutex<Vec<Task>> = Mutex::new(Vec::new());
5451

5552
pub(super) fn lock() -> MutexGuard<'static, Vec<Task>> {
56-
unsafe {
57-
TASK_QUEUE_INIT.call_once(|| TASK_QUEUE = Some(Default::default()));
58-
TASK_QUEUE.as_ref().unwrap().lock().unwrap()
59-
}
53+
TASK_QUEUE.lock().unwrap()
6054
}
6155
}
6256

@@ -101,7 +95,7 @@ pub mod wait_notify {
10195

10296
impl Thread {
10397
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
104-
pub unsafe fn new(_stack: usize, p: Box<dyn FnOnce()>) -> io::Result<Thread> {
98+
pub unsafe fn new(_stack: usize, p: Box<dyn FnOnce() + Send>) -> io::Result<Thread> {
10599
let mut queue_lock = task_queue::lock();
106100
unsafe { usercalls::launch_thread()? };
107101
let (task, handle) = task_queue::Task::new(p);

‎std/src/thread/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,8 @@ impl Builder {
561561
let main = Box::new(main);
562562
// SAFETY: dynamic size and alignment of the Box remain the same. See below for why the
563563
// lifetime change is justified.
564-
let main = unsafe { Box::from_raw(Box::into_raw(main) as *mut (dyn FnOnce() + 'static)) };
564+
let main =
565+
unsafe { Box::from_raw(Box::into_raw(main) as *mut (dyn FnOnce() + Send + 'static)) };
565566

566567
Ok(JoinInner {
567568
// SAFETY:
@@ -1544,7 +1545,7 @@ struct Packet<'scope, T> {
15441545
// The type `T` should already always be Send (otherwise the thread could not
15451546
// have been created) and the Packet is Sync because all access to the
15461547
// `UnsafeCell` synchronized (by the `join()` boundary), and `ScopeData` is Sync.
1547-
unsafe impl<'scope, T: Sync> Sync for Packet<'scope, T> {}
1548+
unsafe impl<'scope, T: Send> Sync for Packet<'scope, T> {}
15481549

15491550
impl<'scope, T> Drop for Packet<'scope, T> {
15501551
fn drop(&mut self) {

0 commit comments

Comments
 (0)
Failed to load comments.