Skip to content

Commit 20a4151

Browse files
committed
auto merge of #14430 : kballard/rust/squelch_os_warning, r=alexcrichton
Clean up the re-exports of various modules in `std::std`, and remove the `realstd` stuff from `std::rt::args`.
2 parents db2ddb1 + 009d898 commit 20a4151

File tree

5 files changed

+27
-70
lines changed

5 files changed

+27
-70
lines changed

src/libstd/io/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ mod test {
859859
})
860860

861861
iotest!(fn file_test_io_seek_shakedown() {
862-
use std::str; // 01234567890123
862+
use str; // 01234567890123
863863
let initial_msg = "qwer-asdf-zxcv";
864864
let chunk_one: &str = "qwer";
865865
let chunk_two: &str = "asdf";
@@ -947,7 +947,7 @@ mod test {
947947
})
948948

949949
iotest!(fn file_test_directoryinfo_readdir() {
950-
use std::str;
950+
use str;
951951
let tmpdir = tmpdir();
952952
let dir = &tmpdir.join("di_readdir");
953953
check!(mkdir(dir, io::UserRWX));

src/libstd/io/process.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use prelude::*;
1616

17-
use std::str;
17+
use str;
1818
use fmt;
1919
use io::IoResult;
2020
use io;

src/libstd/lib.rs

+11-14
Original file line numberDiff line numberDiff line change
@@ -266,24 +266,21 @@ pub mod rt;
266266
// can be resolved within libstd.
267267
#[doc(hidden)]
268268
mod std {
269+
// mods used for deriving
269270
pub use clone;
270271
pub use cmp;
271-
pub use comm;
272-
pub use fmt;
273272
pub use hash;
274-
pub use io;
275-
pub use kinds;
276-
pub use local_data;
277-
pub use option;
278-
pub use os;
279-
pub use rt;
280-
pub use str;
281-
pub use to_str;
282-
pub use ty;
283-
pub use unstable;
284-
pub use vec;
285273

274+
pub use comm; // used for select!()
275+
pub use fmt; // used for any formatting strings
276+
pub use io; // used for println!()
277+
pub use local_data; // used for local_data_key!()
278+
pub use option; // used for bitflags!()
279+
pub use rt; // used for fail!()
280+
pub use vec; // used for vec![]
281+
282+
// The test runner calls ::std::os::args() but really wants realstd
283+
#[cfg(test)] pub use os = realstd::os;
286284
// The test runner requires std::slice::Vector, so re-export std::slice just for it.
287285
#[cfg(test)] pub use slice;
288-
#[cfg(test)] pub use string;
289286
}

src/libstd/os.rs

+6-19
Original file line numberDiff line numberDiff line change
@@ -918,17 +918,10 @@ extern "system" {
918918
///
919919
/// The arguments are interpreted as utf-8, with invalid bytes replaced with \uFFFD.
920920
/// See `str::from_utf8_lossy` for details.
921-
#[cfg(not(test))]
922921
pub fn args() -> Vec<String> {
923922
real_args()
924923
}
925924

926-
#[cfg(test)]
927-
#[allow(missing_doc)]
928-
pub fn args() -> ::realstd::vec::Vec<::realstd::string::String> {
929-
::realstd::os::args()
930-
}
931-
932925
/// Returns the arguments which this program was started with (normally passed
933926
/// via the command line) as byte vectors.
934927
pub fn args_as_bytes() -> Vec<Vec<u8>> {
@@ -1328,7 +1321,7 @@ impl Drop for MemoryMap {
13281321

13291322
#[cfg(target_os = "linux")]
13301323
pub mod consts {
1331-
pub use std::os::arch_consts::ARCH;
1324+
pub use os::arch_consts::ARCH;
13321325

13331326
pub static FAMILY: &'static str = "unix";
13341327

@@ -1359,7 +1352,7 @@ pub mod consts {
13591352

13601353
#[cfg(target_os = "macos")]
13611354
pub mod consts {
1362-
pub use std::os::arch_consts::ARCH;
1355+
pub use os::arch_consts::ARCH;
13631356

13641357
pub static FAMILY: &'static str = "unix";
13651358

@@ -1390,7 +1383,7 @@ pub mod consts {
13901383

13911384
#[cfg(target_os = "freebsd")]
13921385
pub mod consts {
1393-
pub use std::os::arch_consts::ARCH;
1386+
pub use os::arch_consts::ARCH;
13941387

13951388
pub static FAMILY: &'static str = "unix";
13961389

@@ -1421,7 +1414,7 @@ pub mod consts {
14211414

14221415
#[cfg(target_os = "android")]
14231416
pub mod consts {
1424-
pub use std::os::arch_consts::ARCH;
1417+
pub use os::arch_consts::ARCH;
14251418

14261419
pub static FAMILY: &'static str = "unix";
14271420

@@ -1452,7 +1445,7 @@ pub mod consts {
14521445

14531446
#[cfg(target_os = "win32")]
14541447
pub mod consts {
1455-
pub use std::os::arch_consts::ARCH;
1448+
pub use os::arch_consts::ARCH;
14561449

14571450
pub static FAMILY: &'static str = "windows";
14581451

@@ -1507,7 +1500,7 @@ mod tests {
15071500
use prelude::*;
15081501
use c_str::ToCStr;
15091502
use option;
1510-
use os::{env, getcwd, getenv, make_absolute, args};
1503+
use os::{env, getcwd, getenv, make_absolute};
15111504
use os::{setenv, unsetenv};
15121505
use os;
15131506
use rand::Rng;
@@ -1518,12 +1511,6 @@ mod tests {
15181511
debug!("{}", os::last_os_error());
15191512
}
15201513

1521-
#[test]
1522-
pub fn test_args() {
1523-
let a = args();
1524-
assert!(a.len() >= 1);
1525-
}
1526-
15271514
fn make_rand_name() -> String {
15281515
let mut rng = rand::task_rng();
15291516
let n = format_strbuf!("TEST{}", rng.gen_ascii_str(10u).as_slice());

src/libstd/rt/args.rs

+7-34
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,23 @@
2222
2323
use option::Option;
2424
use vec::Vec;
25-
#[cfg(test)] use option::{Some, None};
26-
#[cfg(test)] use realstd;
27-
#[cfg(test)] use realargs = realstd::rt::args;
2825

2926
/// One-time global initialization.
30-
#[cfg(not(test))]
3127
pub unsafe fn init(argc: int, argv: **u8) { imp::init(argc, argv) }
32-
#[cfg(test)]
33-
pub unsafe fn init(argc: int, argv: **u8) { realargs::init(argc, argv) }
3428

3529
/// One-time global cleanup.
36-
#[cfg(not(test))] pub unsafe fn cleanup() { imp::cleanup() }
37-
#[cfg(test)] pub unsafe fn cleanup() { realargs::cleanup() }
30+
pub unsafe fn cleanup() { imp::cleanup() }
3831

3932
/// Take the global arguments from global storage.
40-
#[cfg(not(test))] pub fn take() -> Option<Vec<Vec<u8>>> { imp::take() }
41-
#[cfg(test)] pub fn take() -> Option<Vec<Vec<u8>>> {
42-
match realargs::take() {
43-
realstd::option::Some(v) => Some(unsafe{ ::mem::transmute(v) }),
44-
realstd::option::None => None,
45-
}
46-
}
33+
pub fn take() -> Option<Vec<Vec<u8>>> { imp::take() }
4734

4835
/// Give the global arguments to global storage.
4936
///
5037
/// It is an error if the arguments already exist.
51-
#[cfg(not(test))] pub fn put(args: Vec<Vec<u8>>) { imp::put(args) }
52-
#[cfg(test)] pub fn put(args: Vec<Vec<u8>>) {
53-
realargs::put(unsafe {
54-
::mem::transmute(args)
55-
})
56-
}
38+
pub fn put(args: Vec<Vec<u8>>) { imp::put(args) }
5739

5840
/// Make a clone of the global arguments.
59-
#[cfg(not(test))] pub fn clone() -> Option<Vec<Vec<u8>>> { imp::clone() }
60-
#[cfg(test)] pub fn clone() -> Option<Vec<Vec<u8>>> {
61-
match realargs::clone() {
62-
realstd::option::Some(v) => Some(unsafe { ::mem::transmute(v) }),
63-
realstd::option::None => None,
64-
}
65-
}
41+
pub fn clone() -> Option<Vec<Vec<u8>>> { imp::clone() }
6642

6743
#[cfg(target_os = "linux")]
6844
#[cfg(target_os = "android")]
@@ -75,18 +51,16 @@ mod imp {
7551
use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
7652
use mem;
7753
use vec::Vec;
78-
#[cfg(not(test))] use ptr::RawPtr;
54+
use ptr::RawPtr;
7955

8056
static mut global_args_ptr: uint = 0;
8157
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
8258

83-
#[cfg(not(test))]
8459
pub unsafe fn init(argc: int, argv: **u8) {
8560
let args = load_argc_and_argv(argc, argv);
8661
put(args);
8762
}
8863

89-
#[cfg(not(test))]
9064
pub unsafe fn cleanup() {
9165
rtassert!(take().is_some());
9266
lock.destroy();
@@ -127,7 +101,6 @@ mod imp {
127101
}
128102

129103
// Copied from `os`.
130-
#[cfg(not(test))]
131104
unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> Vec<Vec<u8>> {
132105
use c_str::CString;
133106
use ptr::RawPtr;
@@ -173,8 +146,8 @@ mod imp {
173146
}
174147
}
175148

176-
#[cfg(target_os = "macos", not(test))]
177-
#[cfg(target_os = "win32", not(test))]
149+
#[cfg(target_os = "macos")]
150+
#[cfg(target_os = "win32")]
178151
mod imp {
179152
use option::Option;
180153
use vec::Vec;

0 commit comments

Comments
 (0)