Skip to content

Commit 55967d7

Browse files
committed
Auto merge of #21543 - alexcrichton:old-io, r=alexcrichton
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]
2 parents 70b13a7 + c4f1d89 commit 55967d7

File tree

186 files changed

+1137
-1112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+1137
-1112
lines changed

Diff for: src/compiletest/compiletest.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ extern crate getopts;
2424
extern crate log;
2525

2626
use std::os;
27-
use std::io;
28-
use std::io::fs;
27+
use std::old_io;
28+
use std::old_io::fs;
2929
use std::str::FromStr;
3030
use std::thunk::Thunk;
3131
use getopts::{optopt, optflag, reqopt};
@@ -237,7 +237,7 @@ pub fn run_tests(config: &Config) {
237237
// sadly osx needs some file descriptor limits raised for running tests in
238238
// parallel (especially when we have lots and lots of child processes).
239239
// For context, see #8904
240-
io::test::raise_fd_limit();
240+
old_io::test::raise_fd_limit();
241241
// Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
242242
// If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
243243
os::setenv("__COMPAT_LAYER", "RunAsInvoker");

Diff for: src/compiletest/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010
use self::WhichLine::*;
1111

12-
use std::io::{BufferedReader, File};
12+
use std::old_io::{BufferedReader, File};
1313

1414
pub struct ExpectedError {
1515
pub line: uint,

Diff for: src/compiletest/header.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
223223
fn iter_header<F>(testfile: &Path, mut it: F) -> bool where
224224
F: FnMut(&str) -> bool,
225225
{
226-
use std::io::{BufferedReader, File};
226+
use std::old_io::{BufferedReader, File};
227227

228228
let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
229229
for ln in rdr.lines() {

Diff for: src/compiletest/procsrv.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::io::process::{ProcessExit, Command, Process, ProcessOutput};
11+
use std::old_io::process::{ProcessExit, Command, Process, ProcessOutput};
1212
use std::dynamic_lib::DynamicLibrary;
1313

1414
fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
@@ -47,7 +47,7 @@ pub fn run(lib_path: &str,
4747
match cmd.spawn() {
4848
Ok(mut process) => {
4949
for input in input.iter() {
50-
process.stdin.as_mut().unwrap().write(input.as_bytes()).unwrap();
50+
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
5151
}
5252
let ProcessOutput { status, output, error } =
5353
process.wait_with_output().unwrap();
@@ -79,7 +79,7 @@ pub fn run_background(lib_path: &str,
7979
match cmd.spawn() {
8080
Ok(mut process) => {
8181
for input in input.iter() {
82-
process.stdin.as_mut().unwrap().write(input.as_bytes()).unwrap();
82+
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
8383
}
8484

8585
Some(process)

Diff for: src/compiletest/runtest.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ use util;
2323

2424
#[cfg(target_os = "windows")]
2525
use std::ascii::AsciiExt;
26-
use std::io::File;
27-
use std::io::fs::PathExtensions;
28-
use std::io::fs;
29-
use std::io::net::tcp;
30-
use std::io::process::ProcessExit;
31-
use std::io::process;
32-
use std::io::timer;
33-
use std::io;
26+
use std::old_io::File;
27+
use std::old_io::fs::PathExtensions;
28+
use std::old_io::fs;
29+
use std::old_io::net::tcp;
30+
use std::old_io::process::ProcessExit;
31+
use std::old_io::process;
32+
use std::old_io::timer;
33+
use std::old_io;
3434
use std::os;
3535
use std::iter::repeat;
3636
use std::str;
@@ -619,7 +619,7 @@ fn find_rust_src_root(config: &Config) -> Option<Path> {
619619
}
620620

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

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

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

769769
let command_directive = format!("{}-command", debugger_prefix);
770770
let check_directive = format!("{}-check", debugger_prefix);
@@ -1224,7 +1224,7 @@ fn compose_and_run_compiler(
12241224

12251225
fn ensure_dir(path: &Path) {
12261226
if path.is_dir() { return; }
1227-
fs::mkdir(path, io::USER_RWX).unwrap();
1227+
fs::mkdir(path, old_io::USER_RWX).unwrap();
12281228
}
12291229

12301230
fn compose_and_run(config: &Config, testfile: &Path,
@@ -1401,7 +1401,7 @@ fn dump_output(config: &Config, testfile: &Path, out: &str, err: &str) {
14011401
fn dump_output_file(config: &Config, testfile: &Path,
14021402
out: &str, extension: &str) {
14031403
let outfile = make_out_name(config, testfile, extension);
1404-
File::create(&outfile).write(out.as_bytes()).unwrap();
1404+
File::create(&outfile).write_all(out.as_bytes()).unwrap();
14051405
}
14061406

14071407
fn make_out_name(config: &Config, testfile: &Path, extension: &str) -> Path {

Diff for: src/doc/trpl/guessing-game.md

+27-27
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ Let's get to it! The first thing we need to do for our guessing game is
7575
allow our player to input a guess. Put this in your `src/main.rs`:
7676

7777
```{rust,no_run}
78-
use std::io;
78+
use std::old_io;
7979
8080
fn main() {
8181
println!("Guess the number!");
8282
8383
println!("Please input your guess.");
8484
85-
let input = io::stdin().read_line()
85+
let input = old_io::stdin().read_line()
8686
.ok()
8787
.expect("Failed to read line");
8888
@@ -121,7 +121,7 @@ explanatory text, and then an example. Let's try to modify our code to add in th
121121
`random` function and see what happens:
122122

123123
```{rust,ignore}
124-
use std::io;
124+
use std::old_io;
125125
use std::rand;
126126
127127
fn main() {
@@ -133,7 +133,7 @@ fn main() {
133133
134134
println!("Please input your guess.");
135135
136-
let input = io::stdin().read_line()
136+
let input = old_io::stdin().read_line()
137137
.ok()
138138
.expect("Failed to read line");
139139
@@ -180,7 +180,7 @@ This says "please give me a random `i32` value." We can change our code to use
180180
this hint:
181181

182182
```{rust,no_run}
183-
use std::io;
183+
use std::old_io;
184184
use std::rand;
185185
186186
fn main() {
@@ -192,7 +192,7 @@ fn main() {
192192
193193
println!("Please input your guess.");
194194
195-
let input = io::stdin().read_line()
195+
let input = old_io::stdin().read_line()
196196
.ok()
197197
.expect("Failed to read line");
198198
@@ -233,7 +233,7 @@ unsigned integer approach. If we want a random positive number, we should ask fo
233233
a random positive number. Our code looks like this now:
234234

235235
```{rust,no_run}
236-
use std::io;
236+
use std::old_io;
237237
use std::rand;
238238
239239
fn main() {
@@ -245,7 +245,7 @@ fn main() {
245245
246246
println!("Please input your guess.");
247247
248-
let input = io::stdin().read_line()
248+
let input = old_io::stdin().read_line()
249249
.ok()
250250
.expect("Failed to read line");
251251
@@ -276,7 +276,7 @@ two numbers. Let's add that in, along with a `match` statement to compare our
276276
guess to the secret number:
277277

278278
```{rust,ignore}
279-
use std::io;
279+
use std::old_io;
280280
use std::rand;
281281
use std::cmp::Ordering;
282282
@@ -289,7 +289,7 @@ fn main() {
289289
290290
println!("Please input your guess.");
291291
292-
let input = io::stdin().read_line()
292+
let input = old_io::stdin().read_line()
293293
.ok()
294294
.expect("Failed to read line");
295295
@@ -331,7 +331,7 @@ but we've given it unsigned integers. In this case, the fix is easy, because
331331
we wrote the `cmp` function! Let's change it to take `u32`s:
332332
333333
```{rust,ignore}
334-
use std::io;
334+
use std::old_io;
335335
use std::rand;
336336
use std::cmp::Ordering;
337337

@@ -344,7 +344,7 @@ fn main() {
344344

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

347-
let input = io::stdin().read_line()
347+
let input = old_io::stdin().read_line()
348348
.ok()
349349
.expect("Failed to read line");
350350

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

@@ -442,7 +442,7 @@ fn main() {
442442

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

445-
let input = io::stdin().read_line()
445+
let input = old_io::stdin().read_line()
446446
.ok()
447447
.expect("Failed to read line");
448448
let input_num: Option<u32> = input.parse();
@@ -479,7 +479,7 @@ need to unwrap the Option. If you remember from before, `match` is a great way
479479
to do that. Try this code:
480480
481481
```{rust,no_run}
482-
use std::io;
482+
use std::old_io;
483483
use std::rand;
484484
use std::cmp::Ordering;
485485
@@ -492,7 +492,7 @@ fn main() {
492492
493493
println!("Please input your guess.");
494494
495-
let input = io::stdin().read_line()
495+
let input = old_io::stdin().read_line()
496496
.ok()
497497
.expect("Failed to read line");
498498
let input_num: Option<u32> = input.parse();
@@ -546,7 +546,7 @@ method we can use defined on them: `trim()`. One small modification, and our
546546
code looks like this:
547547
548548
```{rust,no_run}
549-
use std::io;
549+
use std::old_io;
550550
use std::rand;
551551
use std::cmp::Ordering;
552552
@@ -559,7 +559,7 @@ fn main() {
559559
560560
println!("Please input your guess.");
561561
562-
let input = io::stdin().read_line()
562+
let input = old_io::stdin().read_line()
563563
.ok()
564564
.expect("Failed to read line");
565565
let input_num: Option<u32> = input.trim().parse();
@@ -620,7 +620,7 @@ As we already discussed, the `loop` keyword gives us an infinite loop.
620620
Let's add that in:
621621
622622
```{rust,no_run}
623-
use std::io;
623+
use std::old_io;
624624
use std::rand;
625625
use std::cmp::Ordering;
626626

@@ -635,7 +635,7 @@ fn main() {
635635

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

638-
let input = io::stdin().read_line()
638+
let input = old_io::stdin().read_line()
639639
.ok()
640640
.expect("Failed to read line");
641641
let input_num: Option<u32> = input.trim().parse();
@@ -696,7 +696,7 @@ Ha! `quit` actually quits. As does any other non-number input. Well, this is
696696
suboptimal to say the least. First, let's actually quit when you win the game:
697697
698698
```{rust,no_run}
699-
use std::io;
699+
use std::old_io;
700700
use std::rand;
701701
use std::cmp::Ordering;
702702
@@ -711,7 +711,7 @@ fn main() {
711711
712712
println!("Please input your guess.");
713713
714-
let input = io::stdin().read_line()
714+
let input = old_io::stdin().read_line()
715715
.ok()
716716
.expect("Failed to read line");
717717
let input_num: Option<u32> = input.trim().parse();
@@ -752,7 +752,7 @@ we don't want to quit, we just want to ignore it. Change that `return` to
752752
753753
754754
```{rust,no_run}
755-
use std::io;
755+
use std::old_io;
756756
use std::rand;
757757
use std::cmp::Ordering;
758758
@@ -767,7 +767,7 @@ fn main() {
767767
768768
println!("Please input your guess.");
769769
770-
let input = io::stdin().read_line()
770+
let input = old_io::stdin().read_line()
771771
.ok()
772772
.expect("Failed to read line");
773773
let input_num: Option<u32> = input.trim().parse();
@@ -831,7 +831,7 @@ think of what it is? That's right, we don't want to print out the secret number.
831831
It was good for testing, but it kind of ruins the game. Here's our final source:
832832
833833
```{rust,no_run}
834-
use std::io;
834+
use std::old_io;
835835
use std::rand;
836836
use std::cmp::Ordering;
837837
@@ -844,7 +844,7 @@ fn main() {
844844
845845
println!("Please input your guess.");
846846
847-
let input = io::stdin().read_line()
847+
let input = old_io::stdin().read_line()
848848
.ok()
849849
.expect("Failed to read line");
850850
let input_num: Option<u32> = input.trim().parse();

0 commit comments

Comments
 (0)