Skip to content
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

std: remove a workaround for privacy limitations #40503

Merged
merged 1 commit into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/libstd/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
use panic;
use sys;
use sys_common;
use sys_common::thread_info::{self, NewThread};
use sys_common::thread_info;
use thread::Thread;

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

// Store our args if necessary in a squirreled away location
Expand Down
7 changes: 1 addition & 6 deletions src/libstd/sys_common/thread_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl ThreadInfo {
if c.borrow().is_none() {
*c.borrow_mut() = Some(ThreadInfo {
stack_guard: None,
thread: NewThread::new(None),
thread: Thread::new(None),
})
}
Some(f(c.borrow_mut().as_mut().unwrap()))
Expand All @@ -54,8 +54,3 @@ pub fn set(stack_guard: Option<usize>, thread: Thread) {
thread: thread,
}));
}

// a hack to get around privacy restrictions; implemented by `std::thread`
pub trait NewThread {
fn new(name: Option<String>) -> Self;
}
7 changes: 1 addition & 6 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ pub struct Thread {

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

// a hack to get around privacy restrictions
impl thread_info::NewThread for Thread {
fn new(name: Option<String>) -> Thread { Thread::new(name) }
}

////////////////////////////////////////////////////////////////////////////////
// JoinHandle
////////////////////////////////////////////////////////////////////////////////
Expand Down