]> git.lizzy.rs Git - rust.git/commitdiff
std: remove a workaround for privacy limitations that isn't necessary anymore
authorSean Gillespie <sean@swgillespie.me>
Tue, 14 Mar 2017 01:42:23 +0000 (18:42 -0700)
committerSean Gillespie <sean@swgillespie.me>
Tue, 14 Mar 2017 01:42:23 +0000 (18:42 -0700)
src/libstd/rt.rs
src/libstd/sys_common/thread_info.rs
src/libstd/thread/mod.rs

index 78d5aa597ba0df01f33a1ae000f70bc9414b7b2a..6c791cd336ded6b20ff19a5fb2715cb958f48206 100644 (file)
@@ -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();
@@ -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
index 95d8b6cc9516d2e3e5573863d9287ed65d70e105..5ed48ee45587190e42a047427d4b3015ac012908 100644 (file)
@@ -31,7 +31,7 @@ fn with<R, F>(f: F) -> Option<R> where F: FnOnce(&mut ThreadInfo) -> R {
             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()))
@@ -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;
-}
index 2bc066d3fea55c3c203525a08317a3e1cd609aa5..fa4cc276ee5df8e0063c0d23c6f337d55e83c527 100644 (file)
@@ -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")
         });
@@ -858,11 +858,6 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-// a hack to get around privacy restrictions
-impl thread_info::NewThread for Thread {
-    fn new(name: Option<String>) -> Thread { Thread::new(name) }
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // JoinHandle
 ////////////////////////////////////////////////////////////////////////////////