Skip to content

Commit

Permalink
Auto merge of #23470 - alexcrichton:less-prelude, r=aturon
Browse files Browse the repository at this point in the history
This commit removes the reexports of `old_io` traits as well as `old_path` types
and traits from the prelude. This functionality is now all deprecated and needs
to be removed to make way for other functionality like `Seek` in the `std::io`
module (currently reexported as `NewSeek` in the io prelude).

Closes #23377
Closes #23378
  • Loading branch information
bors committed Mar 21, 2015
2 parents e2fa53e + 212e031 commit ecf8c64
Show file tree
Hide file tree
Showing 74 changed files with 372 additions and 297 deletions.
5 changes: 3 additions & 2 deletions src/compiletest/procsrv.rs
Expand Up @@ -10,9 +10,10 @@

#![allow(deprecated)] // for old path, for dynamic_lib

use std::process::{ExitStatus, Command, Child, Output, Stdio};
use std::io::prelude::*;
use std::dynamic_lib::DynamicLibrary;
use std::io::prelude::*;
use std::old_path::Path;
use std::process::{ExitStatus, Command, Child, Output, Stdio};

fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
// Need to be sure to put both the lib_path and the aux path in the dylib
Expand Down
7 changes: 4 additions & 3 deletions src/libcollections/fmt.rs
Expand Up @@ -262,6 +262,7 @@
//!
//! ```
//! # #![allow(unused_must_use)]
//! use std::io::Write;
//! let mut w = Vec::new();
//! write!(&mut w, "Hello {}!", "world");
//! ```
Expand All @@ -288,15 +289,15 @@
//!
//! ```
//! use std::fmt;
//! use std::old_io;
//! use std::io::{self, Write};
//!
//! fmt::format(format_args!("this returns {}", "String"));
//!
//! let mut some_writer = old_io::stdout();
//! let mut some_writer = io::stdout();
//! write!(&mut some_writer, "{}", format_args!("print with a {}", "macro"));
//!
//! fn my_fmt_fn(args: fmt::Arguments) {
//! write!(&mut old_io::stdout(), "{}", args);
//! write!(&mut io::stdout(), "{}", args);
//! }
//! my_fmt_fn(format_args!("or a {} too", "function"));
//! ```
Expand Down
1 change: 1 addition & 0 deletions src/libcore/macros.rs
Expand Up @@ -176,6 +176,7 @@ macro_rules! try {
///
/// ```
/// # #![allow(unused_must_use)]
/// use std::io::Write;
///
/// let mut w = Vec::new();
/// write!(&mut w, "test");
Expand Down
2 changes: 0 additions & 2 deletions src/libcore/prelude.rs
Expand Up @@ -29,8 +29,6 @@ pub use marker::{Copy, Send, Sized, Sync};
pub use ops::{Drop, Fn, FnMut, FnOnce};

// Reexported functions
#[allow(deprecated)]
pub use iter::range;
pub use mem::drop;

// Reexported types and traits
Expand Down
20 changes: 13 additions & 7 deletions src/libcore/result.rs
Expand Up @@ -110,7 +110,8 @@
//! something like this:
//!
//! ```{.ignore}
//! use std::old_io::{File, Open, Write};
//! use std::old_io::*;
//! use std::old_path::Path;
//!
//! let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
//! // If `write_line` errors, then we'll never know, because the return
Expand All @@ -128,7 +129,8 @@
//! a marginally useful message indicating why:
//!
//! ```{.no_run}
//! use std::old_io::{File, Open, Write};
//! use std::old_io::*;
//! use std::old_path::Path;
//!
//! let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
//! file.write_line("important message").ok().expect("failed to write message");
Expand All @@ -138,7 +140,8 @@
//! You might also simply assert success:
//!
//! ```{.no_run}
//! # use std::old_io::{File, Open, Write};
//! # use std::old_io::*;
//! # use std::old_path::Path;
//!
//! # let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
//! assert!(file.write_line("important message").is_ok());
Expand All @@ -148,7 +151,8 @@
//! Or propagate the error up the call stack with `try!`:
//!
//! ```
//! # use std::old_io::{File, Open, Write, IoError};
//! # use std::old_io::*;
//! # use std::old_path::Path;
//! fn write_message() -> Result<(), IoError> {
//! let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
//! try!(file.write_line("important message"));
Expand All @@ -167,7 +171,8 @@
//! It replaces this:
//!
//! ```
//! use std::old_io::{File, Open, Write, IoError};
//! use std::old_io::*;
//! use std::old_path::Path;
//!
//! struct Info {
//! name: String,
Expand All @@ -191,7 +196,8 @@
//! With this:
//!
//! ```
//! use std::old_io::{File, Open, Write, IoError};
//! use std::old_io::*;
//! use std::old_path::Path;
//!
//! struct Info {
//! name: String,
Expand Down Expand Up @@ -446,7 +452,7 @@ impl<T, E> Result<T, E> {
/// ignoring I/O and parse errors:
///
/// ```
/// use std::old_io::IoResult;
/// use std::old_io::*;
///
/// let mut buffer: &[u8] = b"1\n2\n3\n4\n";
/// let mut buffer = &mut buffer;
Expand Down
2 changes: 1 addition & 1 deletion src/libcoretest/str.rs
Expand Up @@ -35,7 +35,7 @@ fn test_bool_from_str() {
fn check_contains_all_substrings(s: &str) {
assert!(s.contains(""));
for i in 0..s.len() {
for j in range(i+1, s.len() + 1) {
for j in i+1..s.len() + 1 {
assert!(s.contains(&s[i..j]));
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_back/fs.rs
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

use std::io;
#[allow(deprecated)] use std::old_path;
#[allow(deprecated)] use std::old_path::{self, GenericPath};
#[allow(deprecated)] use std::old_io;
use std::path::{Path, PathBuf};

Expand Down Expand Up @@ -72,6 +72,7 @@ mod test {
use std::old_io::fs::{File, symlink, mkdir, mkdir_recursive};
use super::old_realpath as realpath;
use std::old_io::TempDir;
use std::old_path::{Path, GenericPath};

#[test]
fn realpath_works() {
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/lib.rs
Expand Up @@ -64,6 +64,8 @@ use std::path::PathBuf;
use std::rc::Rc;
use std::sync::mpsc::channel;

#[allow(deprecated)] use std::old_path::Path;

use externalfiles::ExternalHtml;
use serialize::Decodable;
use serialize::json::{self, Json};
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/plugins.rs
Expand Up @@ -16,6 +16,7 @@ use std::dynamic_lib as dl;
use serialize::json;
use std::mem;
use std::string::String;
use std::old_path::{Path, GenericPath};

pub type PluginJson = Option<(String, json::Json)>;
pub type PluginResult = (clean::Crate, PluginJson);
Expand Down
1 change: 1 addition & 0 deletions src/libserialize/json.rs
Expand Up @@ -2622,6 +2622,7 @@ mod tests {
use std::{i64, u64, f32, f64};
use std::collections::BTreeMap;
use std::string;
use std::old_io::Writer;

#[derive(RustcDecodable, Eq, PartialEq, Debug)]
struct OptionData {
Expand Down
2 changes: 1 addition & 1 deletion src/libserialize/serialize.rs
Expand Up @@ -15,7 +15,7 @@ Core encoding and decoding interfaces.
*/

#[allow(deprecated)]
use std::old_path;
use std::old_path::{self, GenericPath};
use std::path;
use std::rc::Rc;
use std::cell::{Cell, RefCell};
Expand Down
9 changes: 5 additions & 4 deletions src/libstd/dynamic_lib.rs
Expand Up @@ -18,11 +18,12 @@

use prelude::v1::*;

use env;
use ffi::CString;
use mem;
use env;
use str;
use old_path::{Path, GenericPath};
use os;
use str;

pub struct DynamicLibrary {
handle: *mut u8
Expand Down Expand Up @@ -133,15 +134,15 @@ mod test {
use super::*;
use prelude::v1::*;
use libc;
use old_path::Path;
use mem;

#[test]
#[cfg_attr(any(windows, target_os = "android"), ignore)] // FIXME #8818, #10379
fn test_loading_cosine() {
// The math library does not need to be loaded since it is already
// statically linked in
let none: Option<&Path> = None; // appease the typechecker
let libm = match DynamicLibrary::open(none) {
let libm = match DynamicLibrary::open(None) {
Err(error) => panic!("Could not load self as module: {}", error),
Ok(libm) => libm
};
Expand Down
3 changes: 2 additions & 1 deletion src/libstd/env.rs
Expand Up @@ -729,10 +729,11 @@ mod arch {
mod tests {
use prelude::v1::*;
use super::*;

use iter::repeat;
use rand::{self, Rng};
use ffi::{OsString, OsStr};
use path::PathBuf;
use path::{Path, PathBuf};

fn make_rand_name() -> OsString {
let mut rng = rand::thread_rng();
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/fs/mod.rs
Expand Up @@ -801,6 +801,7 @@ mod tests {
use prelude::v1::*;
use io::prelude::*;

use env;
use fs::{self, File, OpenOptions};
use io::{ErrorKind, SeekFrom};
use path::PathBuf;
Expand Down Expand Up @@ -848,8 +849,7 @@ mod tests {
}

pub fn tmpdir() -> TempDir {
let s = os::tmpdir();
let p = Path2::new(s.as_str().unwrap());
let p = env::temp_dir();
let ret = p.join(&format!("rust-{}", rand::random::<u32>()));
check!(fs::create_dir(&ret));
TempDir(ret)
Expand Down Expand Up @@ -1082,7 +1082,7 @@ mod tests {
let dir = &tmpdir.join("di_readdir");
check!(fs::create_dir(dir));
let prefix = "foo";
for n in range(0, 3) {
for n in 0..3 {
let f = dir.join(&format!("{}.txt", n));
let mut w = check!(File::create(&f));
let msg_str = format!("{}{}", prefix, n.to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/libstd/io/prelude.rs
Expand Up @@ -23,8 +23,5 @@

#![stable(feature = "rust1", since = "1.0.0")]

pub use super::{Read, Write, BufRead};
pub use super::{Read, Write, BufRead, Seek};
pub use fs::PathExt;

// FIXME: pub use as `Seek` when the name isn't in the actual prelude any more
pub use super::Seek as NewSeek;
4 changes: 2 additions & 2 deletions src/libstd/num/mod.rs
Expand Up @@ -1650,7 +1650,7 @@ mod tests {
#![test]
assert_eq!((0 as $T).next_power_of_two(), 1);
let mut next_power = 1;
for i in range::<$T>(1, 40) {
for i in 1 as $T..40 {
assert_eq!(i.next_power_of_two(), next_power);
if i == next_power { next_power *= 2 }
}
Expand All @@ -1673,7 +1673,7 @@ mod tests {
assert_eq!(($T::MAX - 1).checked_next_power_of_two(), None);
assert_eq!($T::MAX.checked_next_power_of_two(), None);
let mut next_power = 1;
for i in range::<$T>(1, 40) {
for i in 1 as $T..40 {
assert_eq!(i.checked_next_power_of_two(), Some(next_power));
if i == next_power { next_power *= 2 }
}
Expand Down
11 changes: 7 additions & 4 deletions src/libstd/old_io/buffered.rs
Expand Up @@ -33,7 +33,8 @@ use vec::Vec;
/// # Examples
///
/// ```
/// use std::old_io::{BufferedReader, File};
/// use std::old_io::*;
/// use std::old_path::Path;
///
/// let file = File::open(&Path::new("message.txt"));
/// let mut reader = BufferedReader::new(file);
Expand Down Expand Up @@ -136,7 +137,8 @@ impl<R: Reader> Reader for BufferedReader<R> {
/// # Examples
///
/// ```
/// use std::old_io::{BufferedWriter, File};
/// use std::old_io::*;
/// use std::old_path::Path;
///
/// let file = File::create(&Path::new("message.txt")).unwrap();
/// let mut writer = BufferedWriter::new(file);
Expand Down Expand Up @@ -323,7 +325,8 @@ impl<W: Reader> Reader for InternalBufferedWriter<W> {
///
/// ```
/// # #![allow(unused_must_use)]
/// use std::old_io::{BufferedStream, File};
/// use std::old_io::*;
/// use std::old_path::Path;
///
/// let file = File::open(&Path::new("message.txt"));
/// let mut stream = BufferedStream::new(file);
Expand Down Expand Up @@ -422,7 +425,7 @@ impl<S: Stream> Writer for BufferedStream<S> {
#[cfg(test)]
mod test {
extern crate test;
use old_io;
use old_io::{self, Reader, Writer, Buffer, BufferPrelude};
use prelude::v1::*;
use super::*;
use super::super::{IoResult, EndOfFile};
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/old_io/comm_adapters.rs
Expand Up @@ -24,7 +24,7 @@ use vec::Vec;
///
/// ```
/// use std::sync::mpsc::channel;
/// use std::old_io::ChanReader;
/// use std::old_io::*;
///
/// let (tx, rx) = channel();
/// # drop(tx);
Expand Down Expand Up @@ -116,7 +116,7 @@ impl Reader for ChanReader {
/// ```
/// # #![allow(unused_must_use)]
/// use std::sync::mpsc::channel;
/// use std::old_io::ChanWriter;
/// use std::old_io::*;
///
/// let (tx, rx) = channel();
/// # drop(rx);
Expand Down Expand Up @@ -160,7 +160,7 @@ mod test {

use sync::mpsc::channel;
use super::*;
use old_io;
use old_io::{self, Reader, Writer, Buffer};
use thread;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/old_io/extensions.rs
Expand Up @@ -179,7 +179,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
#[cfg(test)]
mod test {
use prelude::v1::*;
use old_io;
use old_io::{self, Reader, Writer};
use old_io::{MemReader, BytesReader};

struct InitialZeroByteReader {
Expand Down

0 comments on commit ecf8c64

Please sign in to comment.