Skip to content

Commit 6987ad2

Browse files
committed
Make most of std::rt private
Previously, the entire runtime API surface was publicly exposed, but that is neither necessary nor desirable. This commit hides most of the module, using librustrt directly as needed. The arrangement will need to be revisited when rustrt is pulled into std. [breaking-change]
1 parent 40c78ab commit 6987ad2

File tree

24 files changed

+64
-81
lines changed

24 files changed

+64
-81
lines changed

src/libcollections/slice.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,8 @@ pub mod raw {
666666

667667
#[cfg(test)]
668668
mod tests {
669+
extern crate rustrt;
670+
669671
use std::cell::Cell;
670672
use std::default::Default;
671673
use std::mem;
@@ -949,9 +951,9 @@ mod tests {
949951
#[test]
950952
fn test_swap_remove_noncopyable() {
951953
// Tests that we don't accidentally run destructors twice.
952-
let mut v = vec![rt::exclusive::Exclusive::new(()),
953-
rt::exclusive::Exclusive::new(()),
954-
rt::exclusive::Exclusive::new(())];
954+
let mut v = vec![rustrt::exclusive::Exclusive::new(()),
955+
rustrt::exclusive::Exclusive::new(()),
956+
rustrt::exclusive::Exclusive::new(())];
955957
let mut _e = v.swap_remove(0);
956958
assert_eq!(v.len(), 2);
957959
_e = v.swap_remove(1);

src/librustrt/local.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ impl Local<local_ptr::Borrowed<Task>> for Task {
5252

5353
#[cfg(test)]
5454
mod test {
55+
extern crate rustrt;
56+
5557
use std::prelude::*;
56-
use std::rt::thread::Thread;
58+
use rustrt::thread::Thread;
5759
use super::*;
5860
use task::Task;
5961

src/librustrt/mutex.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//! # Example
3434
//!
3535
//! ```rust
36-
//! use std::rt::mutex::{NativeMutex, StaticNativeMutex, NATIVE_MUTEX_INIT};
36+
//! use rustrt::mutex::{NativeMutex, StaticNativeMutex, NATIVE_MUTEX_INIT};
3737
//!
3838
//! // Use a statically initialized mutex
3939
//! static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
@@ -108,7 +108,7 @@ impl StaticNativeMutex {
108108
/// # Example
109109
///
110110
/// ```rust
111-
/// use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
111+
/// use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
112112
/// static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
113113
/// unsafe {
114114
/// let _guard = LOCK.lock();
@@ -225,7 +225,7 @@ impl NativeMutex {
225225
/// # Example
226226
///
227227
/// ```rust
228-
/// use std::rt::mutex::NativeMutex;
228+
/// use rustrt::mutex::NativeMutex;
229229
/// unsafe {
230230
/// let mut lock = NativeMutex::new();
231231
///
@@ -649,11 +649,13 @@ mod imp {
649649

650650
#[cfg(test)]
651651
mod test {
652+
extern crate rustrt;
653+
652654
use std::prelude::*;
653655

654656
use std::mem::drop;
655657
use super::{StaticNativeMutex, NATIVE_MUTEX_INIT};
656-
use std::rt::thread::Thread;
658+
use rustrt::thread::Thread;
657659

658660
#[test]
659661
fn smoke_lock() {

src/librustrt/task.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,8 @@ impl Death {
544544

545545
#[cfg(test)]
546546
mod test {
547+
extern crate rustrt;
548+
547549
use super::*;
548550
use std::prelude::*;
549551
use std::task;
@@ -592,7 +594,7 @@ mod test {
592594
#[test]
593595
#[should_fail]
594596
fn test_begin_unwind() {
595-
use std::rt::unwind::begin_unwind;
597+
use rustrt::unwind::begin_unwind;
596598
begin_unwind("cause", &(file!(), line!()))
597599
}
598600

src/libstd/dynamic_lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ pub mod dl {
229229
}
230230

231231
pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, String> {
232-
use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
232+
use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
233233
static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
234234
unsafe {
235235
// dlerror isn't thread safe, so we need to lock around this entire

src/libstd/failure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use kinds::Send;
1818
use option::{Some, None};
1919
use result::Ok;
2020
use rt::backtrace;
21-
use rt::{Stderr, Stdio};
21+
use rustrt::{Stderr, Stdio};
2222
use rustrt::local::Local;
2323
use rustrt::task::Task;
2424
use str::Str;

src/libstd/io/stdio.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ use option::{Option, Some, None};
4040
use boxed::Box;
4141
use sys::{fs, tty};
4242
use result::{Ok, Err};
43-
use rt;
44-
use rt::local::Local;
45-
use rt::task::Task;
43+
use rustrt;
44+
use rustrt::local::Local;
45+
use rustrt::task::Task;
4646
use slice::SlicePrelude;
4747
use str::StrPrelude;
4848
use uint;
@@ -207,7 +207,7 @@ fn with_task_stdout(f: |&mut Writer| -> IoResult<()>) {
207207
local_stdout.replace(Some(my_stdout));
208208
result
209209
} else {
210-
let mut io = rt::Stdout;
210+
let mut io = rustrt::Stdout;
211211
f(&mut io as &mut Writer)
212212
};
213213
match result {

src/libstd/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ pub use core::result;
162162
pub use core::option;
163163

164164
pub use alloc::boxed;
165-
166165
pub use alloc::rc;
167166

168167
pub use core_collections::slice;
@@ -247,7 +246,7 @@ pub mod fmt;
247246

248247
#[path = "sys/common/mod.rs"] mod sys_common;
249248

250-
mod rt;
249+
pub mod rt;
251250
mod failure;
252251

253252
// A curious inner-module that's not exported that contains the binding

src/libstd/os.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Accessing environment variables is not generally threadsafe.
208208
Serialize access through a global lock.
209209
*/
210210
fn with_env_lock<T>(f: || -> T) -> T {
211-
use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
211+
use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
212212

213213
static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
214214

@@ -1039,9 +1039,9 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> {
10391039
target_os = "freebsd",
10401040
target_os = "dragonfly"))]
10411041
fn real_args_as_bytes() -> Vec<Vec<u8>> {
1042-
use rt;
1042+
use rustrt;
10431043

1044-
match rt::args::clone() {
1044+
match rustrt::args::clone() {
10451045
Some(args) => args,
10461046
None => panic!("process arguments not initialized")
10471047
}

src/libstd/rt/backtrace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ mod imp {
238238
use mem;
239239
use option::{Some, None, Option};
240240
use result::{Ok, Err};
241-
use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
241+
use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
242242

243243
/// As always - iOS on arm uses SjLj exceptions and
244244
/// _Unwind_Backtrace is even not available there. Still,
@@ -667,7 +667,7 @@ mod imp {
667667
use option::{Some, None};
668668
use path::Path;
669669
use result::{Ok, Err};
670-
use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
670+
use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
671671
use slice::SlicePrelude;
672672
use str::StrPrelude;
673673
use dynamic_lib::DynamicLibrary;

0 commit comments

Comments
 (0)