Skip to content

Commit

Permalink
Auto merge of #21543 - alexcrichton:old-io, r=aturon
Browse files Browse the repository at this point in the history
In preparation for the I/O rejuvination of the standard library, this commit
renames the current `io` module to `old_io` in order to make room for the new
I/O modules. It is expected that the I/O RFCs will land incrementally over time
instead of all at once, and this provides a fresh clean path for new modules to
enter into as well as guaranteeing that all old infrastructure will remain in
place for some time.

As each `old_io` module is replaced it will be deprecated in-place for new
structures in `std::{io, fs, net}` (as appropriate).

This commit does *not* leave a reexport of `old_io as io` as the deprecation
lint does not currently warn on this form of use. This is quite a large breaking
change for all imports in existing code, but all functionality is retained
precisely as-is and path statements simply need to be renamed from `io` to
`old_io`.

[breaking-change]
  • Loading branch information
bors committed Jan 24, 2015
2 parents 4be79d6 + a1bfa26 commit 618ec0e
Show file tree
Hide file tree
Showing 185 changed files with 1,137 additions and 1,112 deletions.
6 changes: 3 additions & 3 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ extern crate log;
extern crate regex;

use std::os;
use std::io;
use std::io::fs;
use std::old_io;
use std::old_io::fs;
use std::str::FromStr;
use std::thunk::Thunk;
use getopts::{optopt, optflag, reqopt};
Expand Down Expand Up @@ -247,7 +247,7 @@ pub fn run_tests(config: &Config) {
// sadly osx needs some file descriptor limits raised for running tests in
// parallel (especially when we have lots and lots of child processes).
// For context, see #8904
io::test::raise_fd_limit();
old_io::test::raise_fd_limit();
// Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
// If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
os::setenv("__COMPAT_LAYER", "RunAsInvoker");
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use self::WhichLine::*;

use std::ascii::AsciiExt;
use std::io::{BufferedReader, File};
use std::old_io::{BufferedReader, File};
use regex::Regex;

pub struct ExpectedError {
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
fn iter_header<F>(testfile: &Path, mut it: F) -> bool where
F: FnMut(&str) -> bool,
{
use std::io::{BufferedReader, File};
use std::old_io::{BufferedReader, File};

let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
for ln in rdr.lines() {
Expand Down
6 changes: 3 additions & 3 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::io::process::{ProcessExit, Command, Process, ProcessOutput};
use std::old_io::process::{ProcessExit, Command, Process, ProcessOutput};
use std::dynamic_lib::DynamicLibrary;

fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
Expand Down Expand Up @@ -47,7 +47,7 @@ pub fn run(lib_path: &str,
match cmd.spawn() {
Ok(mut process) => {
for input in input.iter() {
process.stdin.as_mut().unwrap().write(input.as_bytes()).unwrap();
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
}
let ProcessOutput { status, output, error } =
process.wait_with_output().unwrap();
Expand Down Expand Up @@ -79,7 +79,7 @@ pub fn run_background(lib_path: &str,
match cmd.spawn() {
Ok(mut process) => {
for input in input.iter() {
process.stdin.as_mut().unwrap().write(input.as_bytes()).unwrap();
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
}

Some(process)
Expand Down
24 changes: 12 additions & 12 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ use util;

#[cfg(target_os = "windows")]
use std::ascii::AsciiExt;
use std::io::File;
use std::io::fs::PathExtensions;
use std::io::fs;
use std::io::net::tcp;
use std::io::process::ProcessExit;
use std::io::process;
use std::io::timer;
use std::io;
use std::old_io::File;
use std::old_io::fs::PathExtensions;
use std::old_io::fs;
use std::old_io::net::tcp;
use std::old_io::process::ProcessExit;
use std::old_io::process;
use std::old_io::timer;
use std::old_io;
use std::os;
use std::iter::repeat;
use std::str;
Expand Down Expand Up @@ -619,7 +619,7 @@ fn find_rust_src_root(config: &Config) -> Option<Path> {
}

fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path) {
use std::io::process::{Command, ProcessOutput};
use std::old_io::process::{Command, ProcessOutput};

if config.lldb_python_dir.is_none() {
fatal("Can't run LLDB test because LLDB's python path is not set.");
Expand Down Expand Up @@ -764,7 +764,7 @@ struct DebuggerCommands {

fn parse_debugger_commands(file_path: &Path, debugger_prefix: &str)
-> DebuggerCommands {
use std::io::{BufferedReader, File};
use std::old_io::{BufferedReader, File};

let command_directive = format!("{}-command", debugger_prefix);
let check_directive = format!("{}-check", debugger_prefix);
Expand Down Expand Up @@ -1224,7 +1224,7 @@ fn compose_and_run_compiler(

fn ensure_dir(path: &Path) {
if path.is_dir() { return; }
fs::mkdir(path, io::USER_RWX).unwrap();
fs::mkdir(path, old_io::USER_RWX).unwrap();
}

fn compose_and_run(config: &Config, testfile: &Path,
Expand Down Expand Up @@ -1401,7 +1401,7 @@ fn dump_output(config: &Config, testfile: &Path, out: &str, err: &str) {
fn dump_output_file(config: &Config, testfile: &Path,
out: &str, extension: &str) {
let outfile = make_out_name(config, testfile, extension);
File::create(&outfile).write(out.as_bytes()).unwrap();
File::create(&outfile).write_all(out.as_bytes()).unwrap();
}

fn make_out_name(config: &Config, testfile: &Path, extension: &str) -> Path {
Expand Down
54 changes: 27 additions & 27 deletions src/doc/trpl/guessing-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ Let's get to it! The first thing we need to do for our guessing game is
allow our player to input a guess. Put this in your `src/main.rs`:

```{rust,no_run}
use std::io;
use std::old_io;
fn main() {
println!("Guess the number!");
println!("Please input your guess.");
let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
Expand Down Expand Up @@ -121,7 +121,7 @@ explanatory text, and then an example. Let's try to modify our code to add in th
`random` function and see what happens:

```{rust,ignore}
use std::io;
use std::old_io;
use std::rand;
fn main() {
Expand All @@ -133,7 +133,7 @@ fn main() {
println!("Please input your guess.");
let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
Expand Down Expand Up @@ -180,7 +180,7 @@ This says "please give me a random `i32` value." We can change our code to use
this hint:

```{rust,no_run}
use std::io;
use std::old_io;
use std::rand;
fn main() {
Expand All @@ -192,7 +192,7 @@ fn main() {
println!("Please input your guess.");
let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
Expand Down Expand Up @@ -233,7 +233,7 @@ unsigned integer approach. If we want a random positive number, we should ask fo
a random positive number. Our code looks like this now:

```{rust,no_run}
use std::io;
use std::old_io;
use std::rand;
fn main() {
Expand All @@ -245,7 +245,7 @@ fn main() {
println!("Please input your guess.");
let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
Expand Down Expand Up @@ -276,7 +276,7 @@ two numbers. Let's add that in, along with a `match` statement to compare our
guess to the secret number:

```{rust,ignore}
use std::io;
use std::old_io;
use std::rand;
use std::cmp::Ordering;
Expand All @@ -289,7 +289,7 @@ fn main() {
println!("Please input your guess.");
let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
Expand Down Expand Up @@ -331,7 +331,7 @@ but we've given it unsigned integers. In this case, the fix is easy, because
we wrote the `cmp` function! Let's change it to take `u32`s:
```{rust,ignore}
use std::io;
use std::old_io;
use std::rand;
use std::cmp::Ordering;

Expand All @@ -344,7 +344,7 @@ fn main() {

println!("Please input your guess.");

let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");

Expand Down Expand Up @@ -397,7 +397,7 @@ Anyway, we have a `String`, but we need a `u32`. What to do? Well, there's
a function for that:
```{rust,ignore}
let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
let input_num: Option<u32> = input.parse();
Expand Down Expand Up @@ -429,7 +429,7 @@ let input_num: Option<u32> = "5".parse(); // input_num: Option<u32>
Anyway, with us now converting our input to a number, our code looks like this:
```{rust,ignore}
use std::io;
use std::old_io;
use std::rand;
use std::cmp::Ordering;

Expand All @@ -442,7 +442,7 @@ fn main() {

println!("Please input your guess.");

let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
let input_num: Option<u32> = input.parse();
Expand Down Expand Up @@ -479,7 +479,7 @@ need to unwrap the Option. If you remember from before, `match` is a great way
to do that. Try this code:
```{rust,no_run}
use std::io;
use std::old_io;
use std::rand;
use std::cmp::Ordering;
Expand All @@ -492,7 +492,7 @@ fn main() {
println!("Please input your guess.");
let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
let input_num: Option<u32> = input.parse();
Expand Down Expand Up @@ -546,7 +546,7 @@ method we can use defined on them: `trim()`. One small modification, and our
code looks like this:
```{rust,no_run}
use std::io;
use std::old_io;
use std::rand;
use std::cmp::Ordering;
Expand All @@ -559,7 +559,7 @@ fn main() {
println!("Please input your guess.");
let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
let input_num: Option<u32> = input.trim().parse();
Expand Down Expand Up @@ -620,7 +620,7 @@ As we already discussed, the `loop` keyword gives us an infinite loop.
Let's add that in:
```{rust,no_run}
use std::io;
use std::old_io;
use std::rand;
use std::cmp::Ordering;

Expand All @@ -635,7 +635,7 @@ fn main() {

println!("Please input your guess.");

let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
let input_num: Option<u32> = input.trim().parse();
Expand Down Expand Up @@ -696,7 +696,7 @@ Ha! `quit` actually quits. As does any other non-number input. Well, this is
suboptimal to say the least. First, let's actually quit when you win the game:
```{rust,no_run}
use std::io;
use std::old_io;
use std::rand;
use std::cmp::Ordering;
Expand All @@ -711,7 +711,7 @@ fn main() {
println!("Please input your guess.");
let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
let input_num: Option<u32> = input.trim().parse();
Expand Down Expand Up @@ -752,7 +752,7 @@ we don't want to quit, we just want to ignore it. Change that `return` to
```{rust,no_run}
use std::io;
use std::old_io;
use std::rand;
use std::cmp::Ordering;
Expand All @@ -767,7 +767,7 @@ fn main() {
println!("Please input your guess.");
let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
let input_num: Option<u32> = input.trim().parse();
Expand Down Expand Up @@ -831,7 +831,7 @@ think of what it is? That's right, we don't want to print out the secret number.
It was good for testing, but it kind of ruins the game. Here's our final source:
```{rust,no_run}
use std::io;
use std::old_io;
use std::rand;
use std::cmp::Ordering;
Expand All @@ -844,7 +844,7 @@ fn main() {
println!("Please input your guess.");
let input = io::stdin().read_line()
let input = old_io::stdin().read_line()
.ok()
.expect("Failed to read line");
let input_num: Option<u32> = input.trim().parse();
Expand Down
Loading

0 comments on commit 618ec0e

Please sign in to comment.