Skip to content

Commit 1545f4e

Browse files
committed
std: remove a workaround for privacy limitations that isn't necessary anymore
1 parent fd182c4 commit 1545f4e

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

src/libstd/rt.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
3434
use panic;
3535
use sys;
3636
use sys_common;
37-
use sys_common::thread_info::{self, NewThread};
37+
use sys_common::thread_info;
3838
use thread::Thread;
3939

4040
sys::init();
@@ -47,7 +47,7 @@ fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
4747
// created. Note that this isn't necessary in general for new threads,
4848
// but we just do this to name the main thread and to give it correct
4949
// info about the stack bounds.
50-
let thread: Thread = NewThread::new(Some("main".to_owned()));
50+
let thread = Thread::new(Some("main".to_owned()));
5151
thread_info::set(main_guard, thread);
5252

5353
// Store our args if necessary in a squirreled away location

src/libstd/sys_common/thread_info.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl ThreadInfo {
3131
if c.borrow().is_none() {
3232
*c.borrow_mut() = Some(ThreadInfo {
3333
stack_guard: None,
34-
thread: NewThread::new(None),
34+
thread: Thread::new(None),
3535
})
3636
}
3737
Some(f(c.borrow_mut().as_mut().unwrap()))
@@ -54,8 +54,3 @@ pub fn set(stack_guard: Option<usize>, thread: Thread) {
5454
thread: thread,
5555
}));
5656
}
57-
58-
// a hack to get around privacy restrictions; implemented by `std::thread`
59-
pub trait NewThread {
60-
fn new(name: Option<String>) -> Self;
61-
}

src/libstd/thread/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ pub struct Thread {
745745

746746
impl Thread {
747747
// Used only internally to construct a thread object without spawning
748-
fn new(name: Option<String>) -> Thread {
748+
pub(crate) fn new(name: Option<String>) -> Thread {
749749
let cname = name.map(|n| {
750750
CString::new(n).expect("thread name may not contain interior null bytes")
751751
});
@@ -858,11 +858,6 @@ impl fmt::Debug for Thread {
858858
}
859859
}
860860

861-
// a hack to get around privacy restrictions
862-
impl thread_info::NewThread for Thread {
863-
fn new(name: Option<String>) -> Thread { Thread::new(name) }
864-
}
865-
866861
////////////////////////////////////////////////////////////////////////////////
867862
// JoinHandle
868863
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)