diff options
| author | bors <bors@rust-lang.org> | 2015-03-21 05:25:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-21 05:25:21 +0000 |
| commit | ecf8c64e1b1b60f228f0c472c0b0dab4a5b5aa61 (patch) | |
| tree | 03752d10ba340b85b8720647c7919a97b21d694b /src/test | |
| parent | e2fa53e593a854a609ae9efe5a1bbe15265f0a6f (diff) | |
| parent | 212e03181e422f569b6426bc08b713a9efc0d0eb (diff) | |
| download | rust-ecf8c64e1b1b60f228f0c472c0b0dab4a5b5aa61.tar.gz rust-ecf8c64e1b1b60f228f0c472c0b0dab4a5b5aa61.zip | |
Auto merge of #23470 - alexcrichton:less-prelude, r=aturon
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
Diffstat (limited to 'src/test')
29 files changed, 174 insertions, 181 deletions
diff --git a/src/test/auxiliary/linkage-visibility.rs b/src/test/auxiliary/linkage-visibility.rs index 6cd94ee5602..03fe2fd94dd 100644 --- a/src/test/auxiliary/linkage-visibility.rs +++ b/src/test/auxiliary/linkage-visibility.rs @@ -27,8 +27,7 @@ fn bar() { } fn baz() { } pub fn test() { - let none: Option<&Path> = None; // appease the typechecker - let lib = DynamicLibrary::open(none).unwrap(); + let lib = DynamicLibrary::open(None).unwrap(); unsafe { assert!(lib.symbol::<int>("foo").is_ok()); assert!(lib.symbol::<int>("baz").is_err()); diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 4c3b3f42aca..c2ea097ed75 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -13,7 +13,8 @@ #![feature(unboxed_closures)] -use std::old_io::File; +use std::old_io::*; +use std::old_path::{Path, GenericPath}; use std::iter::repeat; use std::mem::swap; use std::env; diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 9cee75757aa..289f05a299b 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -39,7 +39,7 @@ // OF THE POSSIBILITY OF SUCH DAMAGE. use std::cmp::min; -use std::old_io::{stdout, IoResult}; +use std::old_io::*; use std::iter::repeat; use std::env; use std::slice::bytes::copy_memory; diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index e15f9d99ff6..df839fc27ee 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -39,8 +39,9 @@ // OF THE POSSIBILITY OF SUCH DAMAGE. use std::cmp::min; -use std::old_io::{BufferedWriter, File}; +use std::old_io::*; use std::old_io; +use std::old_path::Path; use std::num::Float; use std::env; diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 3ea4a10ea81..88c9f43f6ec 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -147,7 +147,7 @@ fn make_sequence_processor(sz: uint, // given a FASTA file on stdin, process sequence THREE fn main() { - use std::old_io::{stdio, MemReader, BufferedReader}; + use std::old_io::*; let rdr = if env::var_os("RUST_BENCH").is_some() { let foo = include_bytes!("shootout-k-nucleotide.data"); diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index bddf6153228..128c92921fa 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -43,6 +43,7 @@ // ignore-pretty very bad with line comments use std::old_io; +use std::old_io::*; use std::env; use std::simd::f64x2; use std::sync::Arc; diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index 33d959dfe93..93aa5f2571b 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -45,7 +45,7 @@ extern crate libc; use std::old_io::stdio::{stdin_raw, stdout_raw}; -use std::old_io::{IoResult, EndOfFile}; +use std::old_io::*; use std::ptr::{copy_memory, Unique}; use std::thread; diff --git a/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs b/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs index e59bd62d178..5ddde6460b0 100644 --- a/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs +++ b/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs @@ -10,6 +10,8 @@ #![feature(unboxed_closures)] +use std::io::Read; + fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f } fn main() { @@ -17,7 +19,7 @@ fn main() { to_fn_once(move|| { x = 2; }); //~^ ERROR: cannot assign to immutable captured outer variable - let s = std::old_io::stdin(); - to_fn_once(move|| { s.read_to_end(); }); + let s = std::io::stdin(); + to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); //~^ ERROR: cannot borrow immutable captured outer variable } diff --git a/src/test/compile-fail/issue-11374.rs b/src/test/compile-fail/issue-11374.rs index 09d7293a3d0..f78786a2889 100644 --- a/src/test/compile-fail/issue-11374.rs +++ b/src/test/compile-fail/issue-11374.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::old_io; +use std::io::{self, Read}; use std::vec; pub struct Container<'a> { - reader: &'a mut Reader + reader: &'a mut Read } impl<'a> Container<'a> { - pub fn wrap<'s>(reader: &'s mut Reader) -> Container<'s> { + pub fn wrap<'s>(reader: &'s mut io::Read) -> Container<'s> { Container { reader: reader } } @@ -26,8 +26,8 @@ impl<'a> Container<'a> { } pub fn for_stdin<'a>() -> Container<'a> { - let mut r = old_io::stdin(); - Container::wrap(&mut r as &mut Reader) + let mut r = io::stdin(); + Container::wrap(&mut r as &mut io::Read) } fn main() { diff --git a/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs b/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs index 89352a16d8b..fd69d2786b8 100644 --- a/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs +++ b/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs @@ -9,7 +9,10 @@ // except according to those terms. use std::env; -use std::old_io::{File, Command}; +use std::fs::File; +use std::process::Command; +use std::io::Write; +use std::path::Path; // creates broken.rs, which has the Ident \x00name_0,ctxt_0\x00 // embedded within it, and then attempts to compile broken.rs with the @@ -22,21 +25,18 @@ fn main() { let main_file = tmpdir.join("broken.rs"); let _ = File::create(&main_file).unwrap() - .write_str("pub fn main() { + .write_all(b"pub fn main() { let \x00name_0,ctxt_0\x00 = 3; println!(\"{}\", \x00name_0,ctxt_0\x00); - }"); + }").unwrap(); // rustc is passed to us with --out-dir and -L etc., so we // can't exec it directly let result = Command::new("sh") .arg("-c") - .arg(&format!("{} {}", - rustc, - main_file.as_str() - .unwrap())) + .arg(&format!("{} {}", rustc, main_file.display())) .output().unwrap(); - let err = String::from_utf8_lossy(&result.error); + let err = String::from_utf8_lossy(&result.stderr); // positive test so that this test will be updated when the // compiler changes. diff --git a/src/test/run-make/extern-fn-reachable/main.rs b/src/test/run-make/extern-fn-reachable/main.rs index 0f759efb025..86eed9dbe0a 100644 --- a/src/test/run-make/extern-fn-reachable/main.rs +++ b/src/test/run-make/extern-fn-reachable/main.rs @@ -10,6 +10,7 @@ use std::dynamic_lib::DynamicLibrary; use std::os; +use std::old_path::Path; pub fn main() { unsafe { diff --git a/src/test/run-make/unicode-input/multiple_files.rs b/src/test/run-make/unicode-input/multiple_files.rs index ce3e69918ff..1826e035e24 100644 --- a/src/test/run-make/unicode-input/multiple_files.rs +++ b/src/test/run-make/unicode-input/multiple_files.rs @@ -8,9 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{char, env}; -use std::old_io::{File, Command}; +use std::fs::File; +use std::io::prelude::*; +use std::path::Path; +use std::process::Command; use std::rand::{thread_rng, Rng}; +use std::{char, env}; // creates unicode_input_multiple_files_{main,chars}.rs, where the // former imports the latter. `_chars` just contains an identifier @@ -40,7 +43,7 @@ fn main() { let main_file = tmpdir.join("unicode_input_multiple_files_main.rs"); { let _ = File::create(&main_file).unwrap() - .write_str("mod unicode_input_multiple_files_chars;"); + .write_all(b"mod unicode_input_multiple_files_chars;").unwrap(); } for _ in 0..100 { @@ -48,7 +51,7 @@ fn main() { let randoms = tmpdir.join("unicode_input_multiple_files_chars.rs"); let mut w = File::create(&randoms).unwrap(); for _ in 0..30 { - let _ = w.write_char(random_char()); + write!(&mut w, "{}", random_char()).unwrap(); } } @@ -58,10 +61,9 @@ fn main() { .arg("-c") .arg(&format!("{} {}", rustc, - main_file.as_str() - .unwrap())) + main_file.display())) .output().unwrap(); - let err = String::from_utf8_lossy(&result.error); + let err = String::from_utf8_lossy(&result.stderr); // positive test so that this test will be updated when the // compiler changes. diff --git a/src/test/run-make/unicode-input/span_length.rs b/src/test/run-make/unicode-input/span_length.rs index a6cb9fe0324..9ed20ccaea5 100644 --- a/src/test/run-make/unicode-input/span_length.rs +++ b/src/test/run-make/unicode-input/span_length.rs @@ -8,8 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::old_io::{File, Command}; +use std::fs::File; +use std::io::prelude::*; use std::iter::repeat; +use std::path::Path; +use std::process::Command; use std::rand::{thread_rng, Rng}; use std::{char, env}; @@ -54,11 +57,11 @@ fn main() { .arg("-c") .arg(&format!("{} {}", rustc, - main_file.as_str() + main_file.to_str() .unwrap())) .output().unwrap(); - let err = String::from_utf8_lossy(&result.error); + let err = String::from_utf8_lossy(&result.stderr); // the span should end the line (e.g no extra ~'s) let expected_span = format!("^{}\n", repeat("~").take(n - 1) @@ -73,17 +76,16 @@ fn main() { } // Extra characters. Every line is preceded by `filename:lineno <actual code>` - let offset = main_file.as_str().unwrap().len() + 3; + let offset = main_file.to_str().unwrap().len() + 3; let result = Command::new("sh") .arg("-c") .arg(format!("{} {}", rustc, - main_file.as_str() - .unwrap())) + main_file.display())) .output().unwrap(); - let err = String::from_utf8_lossy(result.error.as_slice()); + let err = String::from_utf8_lossy(&result.stderr); // Test both the length of the snake and the leading spaces up to it diff --git a/src/test/run-pass/backtrace-debuginfo.rs b/src/test/run-pass/backtrace-debuginfo.rs index 088fa19356c..2a74e36aff3 100644 --- a/src/test/run-pass/backtrace-debuginfo.rs +++ b/src/test/run-pass/backtrace-debuginfo.rs @@ -11,7 +11,8 @@ // compile-flags:-g // ignore-pretty as this critically relies on line numbers -use std::old_io::stderr; +use std::io; +use std::io::prelude::*; use std::env; #[path = "backtrace-debuginfo-aux.rs"] mod aux; @@ -124,17 +125,18 @@ fn check_trace(output: &str, error: &str) { fn run_test(me: &str) { use std::str; - use std::old_io::process::Command; + use std::process::Command; let mut template = Command::new(me); template.env("RUST_BACKTRACE", "1"); let mut i = 0; loop { - let p = template.clone().arg(i.to_string()).spawn().unwrap(); - let out = p.wait_with_output().unwrap(); - let output = str::from_utf8(&out.output).unwrap(); - let error = str::from_utf8(&out.error).unwrap(); + let out = Command::new(me) + .env("RUST_BACKTRACE", "1") + .arg(i.to_string()).output().unwrap(); + let output = str::from_utf8(&out.stdout).unwrap(); + let error = str::from_utf8(&out.stderr).unwrap(); if out.status.success() { assert!(output.contains("done."), "bad output for successful run: {}", output); break; @@ -150,7 +152,7 @@ fn main() { let args: Vec<String> = env::args().collect(); if args.len() >= 2 { let case = args[1].parse().unwrap(); - writeln!(&mut stderr(), "test case {}", case).unwrap(); + writeln!(&mut io::stderr(), "test case {}", case).unwrap(); outer(case, pos!()); println!("done."); } else { diff --git a/src/test/run-pass/capturing-logging.rs b/src/test/run-pass/capturing-logging.rs index 70cc0463a6e..be5bb628b72 100644 --- a/src/test/run-pass/capturing-logging.rs +++ b/src/test/run-pass/capturing-logging.rs @@ -19,7 +19,7 @@ extern crate log; use log::{set_logger, Logger, LogRecord}; use std::sync::mpsc::channel; use std::fmt; -use std::old_io::{ChanReader, ChanWriter}; +use std::old_io::{ChanReader, ChanWriter, Reader, Writer}; use std::thread::Thread; struct MyWriter(ChanWriter); diff --git a/src/test/run-pass/colorful-write-macros.rs b/src/test/run-pass/colorful-write-macros.rs index 841aaa94e9b..35fe447c5e6 100644 --- a/src/test/run-pass/colorful-write-macros.rs +++ b/src/test/run-pass/colorful-write-macros.rs @@ -10,12 +10,11 @@ // no-pretty-expanded -#![allow(unused_must_use, dead_code, deprecated)] -use std::old_io::MemWriter; +use std::io::Write; use std::fmt; struct Foo<'a> { - writer: &'a mut (Writer+'a), + writer: &'a mut (Write+'a), other: &'a str, } @@ -32,8 +31,8 @@ fn borrowing_writer_from_struct_and_formatting_struct_field(foo: Foo) { } fn main() { - let mut w = MemWriter::new(); - write!(&mut w as &mut Writer, ""); + let mut w = Vec::new(); + write!(&mut w as &mut Write, ""); write!(&mut w, ""); // should coerce println!("ok"); diff --git a/src/test/run-pass/into-iterator-type-inference-shift.rs b/src/test/run-pass/into-iterator-type-inference-shift.rs index 26a0abc76ae..01e305581f1 100644 --- a/src/test/run-pass/into-iterator-type-inference-shift.rs +++ b/src/test/run-pass/into-iterator-type-inference-shift.rs @@ -31,7 +31,7 @@ impl<I> IntoIterator for I where I: Iterator { fn desugared_for_loop_bad(byte: u8) -> u8 { let mut result = 0; - let mut x = IntoIterator::into_iter(range(0, u8::BITS)); + let mut x = IntoIterator::into_iter(0..u8::BITS); let mut y = Iterator::next(&mut x); let mut z = y.unwrap(); byte >> z; diff --git a/src/test/run-pass/issue-14940.rs b/src/test/run-pass/issue-14940.rs index ed0e3bddbe5..098fa54207f 100644 --- a/src/test/run-pass/issue-14940.rs +++ b/src/test/run-pass/issue-14940.rs @@ -9,12 +9,13 @@ // except according to those terms. use std::env; -use std::old_io::{stdio, Command}; +use std::process::Command; +use std::io::{self, Write}; fn main() { let mut args = env::args(); if args.len() > 1 { - let mut out = stdio::stdout(); + let mut out = io::stdout(); out.write(&['a' as u8; 128 * 1024]).unwrap(); } else { let out = Command::new(&args.next().unwrap()).arg("child").output(); diff --git a/src/test/run-pass/issue-17121.rs b/src/test/run-pass/issue-17121.rs index 2f0b8c9f19b..6d32ffd6c43 100644 --- a/src/test/run-pass/issue-17121.rs +++ b/src/test/run-pass/issue-17121.rs @@ -8,31 +8,29 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::old_io::BufReader; -use std::old_io::BufferedReader; -use std::old_io::File; -use std::old_io::IoResult; +use std::fs::File; +use std::io::{self, BufReader, Read}; -struct Lexer<R: Reader> +struct Lexer<R: Read> { - reader: BufferedReader<R>, + reader: BufReader<R>, } -impl<R: Reader> Lexer<R> +impl<R: Read> Lexer<R> { pub fn new_from_reader(r: R) -> Lexer<R> { - Lexer{reader: BufferedReader::new(r)} + Lexer{reader: BufReader::new(r)} } - pub fn new_from_file(p: Path) -> IoResult<Lexer<File>> + pub fn new_from_file(p: &str) -> io::Result<Lexer<File>> { - Ok(Lexer::new_from_reader(try!(File::open(&p)))) + Ok(Lexer::new_from_reader(try!(File::open(p)))) } - pub fn new_from_str<'a>(s: &'a str) -> Lexer<BufReader<'a>> + pub fn new_from_str<'a>(s: &'a str) -> Lexer<&'a [u8]> { - Lexer::new_from_reader(BufReader::new(s.as_bytes())) + Lexer::new_from_reader(s.as_bytes()) } } diff --git a/src/test/run-pass/issue-20644.rs b/src/test/run-pass/issue-20644.rs index 0d482548cc0..83b91c93a86 100644 --- a/src/test/run-pass/issue-20644.rs +++ b/src/test/run-pass/issue-20644.rs @@ -11,24 +11,25 @@ // A reduced version of the rustbook ice. The problem this encountered // had to do with trans ignoring binders. -#![feature(associated_types)] -#![feature(macro_rules)] - use std::iter; use std::os; -use std::old_io::File; +use std::fs::File; +use std::io::prelude::*; +use std::env; +use std::path::Path; -#[allow(unused)] -pub fn parse_summary<R: Reader>(_: R, _: &Path) { +pub fn parse_summary<R: Read>(_: R, _: &Path) { let path_from_root = Path::new(""); - Path::new(iter::repeat("../") + Path::new(&iter::repeat("../") .take(path_from_root.components().count() - 1) .collect::<String>()); } -fn main() { - let cwd = os::getcwd().unwrap(); +fn foo() { + let cwd = env::current_dir().unwrap(); let src = cwd.clone(); - let summary = File::open(&src.join("SUMMARY.md")); + let summary = File::open(&src.join("SUMMARY.md")).unwrap(); let _ = parse_summary(summary, &src); } + +fn main() {} diff --git a/src/test/run-pass/issue-20797.rs b/src/test/run-pass/issue-20797.rs index 049e08d2b94..c5badb61494 100644 --- a/src/test/run-pass/issue-20797.rs +++ b/src/test/run-pass/issue-20797.rs @@ -8,24 +8,27 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-android -// ignore-windows - // Regression test for #20797. use std::default::Default; -use std::old_io::IoResult; -use std::old_io::fs; -use std::old_io::fs::PathExtensions; +use std::io; +use std::fs; +use std::path::{PathBuf, Path}; + +pub trait PathExtensions { + fn is_dir(&self) -> bool { false } +} + +impl PathExtensions for PathBuf {} /// A strategy for acquiring more subpaths to walk. pub trait Strategy { - type P: PathExtensions; - /// Get additional subpaths from a given path. - fn get_more(&self, item: &Self::P) -> IoResult<Vec<Self::P>>; - /// Determine whether a path should be walked further. - /// This is run against each item from `get_more()`. - fn prune(&self, p: &Self::P) -> bool; + type P: PathExtensions; + /// Get additional subpaths from a given path. + fn get_more(&self, item: &Self::P) -> io::Result<Vec<Self::P>>; + /// Determine whether a path should be walked further. + /// This is run against each item from `get_more()`. + fn prune(&self, p: &Self::P) -> bool; } /// The basic fully-recursive strategy. Nothing is pruned. @@ -33,10 +36,12 @@ pub trait Strategy { pub struct Recursive; impl Strategy for Recursive { - type P = Path; - fn get_more(&self, p: &Path) -> IoResult<Vec<Path>> { fs::readdir(p) } + type P = PathBuf; + fn get_more(&self, p: &PathBuf) -> io::Result<Vec<PathBuf>> { + Ok(fs::read_dir(p).unwrap().map(|s| s.unwrap().path()).collect()) + } - fn prune(&self, _: &Path) -> bool { false } + fn prune(&self, _: &PathBuf) -> bool { false } } /// A directory walker of `P` using strategy `S`. @@ -46,49 +51,51 @@ pub struct Subpaths<S: Strategy> { } impl<S: Strategy> Subpaths<S> { - /// Create a directory walker with a root path and strategy. - pub fn new(p: &S::P, strategy: S) -> IoResult<Subpaths<S>> { - let stack = try!(strategy.get_more(p)); - Ok(Subpaths { stack: stack, strategy: strategy }) - } + /// Create a directory walker with a root path and strategy. + pub fn new(p: &S::P, strategy: S) -> io::Result<Subpaths<S>> { + let stack = try!(strategy.get_more(p)); + Ok(Subpaths { stack: stack, strategy: strategy }) + } } impl<S: Default + Strategy> Subpaths<S> { - /// Create a directory walker with a root path and a default strategy. - pub fn walk(p: &S::P) -> IoResult<Subpaths<S>> { - Subpaths::new(p, Default::default()) - } + /// Create a directory walker with a root path and a default strategy. + pub fn walk(p: &S::P) -> io::Result<Subpaths<S>> { + Subpaths::new(p, Default::default()) + } } impl<S: Default + Strategy> Default for Subpaths<S> { - fn default() -> Subpaths<S> { - Subpaths { stack: Vec::new(), strategy: Default::default() } - } + fn default() -> Subpaths<S> { + Subpaths { stack: Vec::new(), strategy: Default::default() } + } } impl<S: Strategy> Iterator for Subpaths<S> { - type Item = S::P; - fn next (&mut self) -> Option<S::P> { - let mut opt_path = self.stack.pop(); - while opt_path.is_some() && self.strategy.prune(opt_path.as_ref().unwrap()) { - opt_path = self.stack.pop(); - } - match opt_path { - Some(path) => { - if PathExtensions::is_dir(&path) { - let result = self.strategy.get_more(&path); - match result { - Ok(dirs) => { self.stack.extend(dirs.into_iter()); }, - Err(..) => { } - } + type Item = S::P; + fn next (&mut self) -> Option<S::P> { + let mut opt_path = self.stack.pop(); + while opt_path.is_some() && self.strategy.prune(opt_path.as_ref().unwrap()) { + opt_path = self.stack.pop(); + } + match opt_path { + Some(path) => { + if path.is_dir() { + let result = self.strategy.get_more(&path); + match result { + Ok(dirs) => { self.stack.extend(dirs.into_iter()); }, + Err(..) => { } + } + } + Some(path) + } + None => None, } - Some(path) - } - None => None, } - } } -fn main() { - let mut walker: Subpaths<Recursive> = Subpaths::walk(&Path::new("/home")).unwrap(); +fn foo() { + let mut walker: Subpaths<Recursive> = Subpaths::walk(&PathBuf::new("/home")).unwrap(); } + +fn main() {} diff --git a/src/test/run-pass/issue22346.rs b/src/test/run-pass/issue22346.rs index 3193e5c5fc2..d30a0be5fee 100644 --- a/src/test/run-pass/issue22346.rs +++ b/src/test/run-pass/issue22346.rs @@ -10,7 +10,7 @@ // This used to cause an ICE because the retslot for the "return" had the wrong type fn testcase<'a>() -> Box<Iterator<Item=usize> + 'a> { - return Box::new(range(0, 3).map(|i| { return i; })); + return Box::new((0..3).map(|i| { return i; })); } fn main() { diff --git a/src/test/run-pass/process-spawn-with-unicode-params.rs b/src/test/run-pass/process-spawn-with-unicode-params.rs index 466b38e8742..72998133af1 100644 --- a/src/test/run-pass/process-spawn-with-unicode-params.rs +++ b/src/test/run-pass/process-spawn-with-unicode-params.rs @@ -28,9 +28,9 @@ use std::path::{Path, PathBuf}; fn main() { let my_args = env::args().collect::<Vec<_>>(); - let my_cwd = PathBuf::new(os::getcwd().unwrap().as_str().unwrap()); + let my_cwd = env::current_dir().unwrap(); let my_env = env::vars().collect::<Vec<_>>(); - let my_path = PathBuf::new(os::self_exe_name().unwrap().as_str().unwrap()); + let my_path = env::current_exe().unwrap(); let my_dir = my_path.parent().unwrap(); let my_ext = my_path.extension().and_then(|s| s.to_str()).unwrap_or(""); diff --git a/src/test/run-pass/rename-directory.rs b/src/test/run-pass/rename-directory.rs index e0810d39555..656fe898969 100644 --- a/src/test/run-pass/rename-directory.rs +++ b/src/test/run-pass/rename-directory.rs @@ -11,45 +11,23 @@ // This test can't be a unit test in std, // because it needs TempDir, which is in extra -extern crate libc; - use std::ffi::CString; -use std::old_io::TempDir; -use std::old_io::fs::PathExtensions; -use std::old_io::fs; -use std::old_io; -use std::os; +use std::fs::{self, TempDir, File, PathExt}; fn rename_directory() { - unsafe { - static U_RWX: i32 = (libc::S_IRUSR | libc::S_IWUSR | libc::S_IXUSR) as i32; - - let tmpdir = TempDir::new("rename_directory").ok().expect("rename_directory failed"); - let tmpdir = tmpdir.path(); - let old_path = tmpdir.join_many(&["foo", "bar", "baz"]); - fs::mkdir_recursive(&old_path, old_io::USER_RWX); - let test_file = &old_path.join("temp.txt"); - - /* Write the temp input file */ - let fromp = CString::new(test_file.as_vec()).unwrap(); - let modebuf = CString::new(&b"w+b"[..]).unwrap(); - let ostream = libc::fopen(fromp.as_ptr(), modebuf.as_ptr()); - assert!((ostream as uint != 0)); - let s = "hello".to_string(); - let buf = CString::new(&b"hello"[..]).unwrap(); - let write_len = libc::fwrite(buf.as_ptr() as *mut _, - 1_usize as libc::size_t, - (s.len() + 1_usize) as libc::size_t, - ostream); - assert_eq!(write_len, (s.len() + 1) as libc::size_t); - assert_eq!(libc::fclose(ostream), (0_usize as libc::c_int)); - - let new_path = tmpdir.join_many(&["quux", "blat"]); - fs::mkdir_recursive(&new_path, old_io::USER_RWX); - fs::rename(&old_path, &new_path.join("newdir")); - assert!(new_path.join("newdir").is_dir()); - assert!(new_path.join_many(&["newdir", "temp.txt"]).exists()); - } + let tmpdir = TempDir::new("rename_directory").ok().expect("rename_directory failed"); + let tmpdir = tmpdir.path(); + let old_path = tmpdir.join("foo/bar/baz"); + fs::create_dir_all(&old_path).unwrap(); + let test_file = &old_path.join("temp.txt"); + + File::create(test_file).unwrap(); + + let new_path = tmpdir.join("quux/blat"); + fs::create_dir_all(&new_path).unwrap(); + fs::rename(&old_path, &new_path.join("newdir")); + assert!(new_path.join("newdir").is_dir()); + assert!(new_path.join("newdir/temp.txt").exists()); } pub fn main() { rename_directory() } diff --git a/src/test/run-pass/sigpipe-should-be-ignored.rs b/src/test/run-pass/sigpipe-should-be-ignored.rs index d1428c6be19..665b582581c 100644 --- a/src/test/run-pass/sigpipe-should-be-ignored.rs +++ b/src/test/run-pass/sigpipe-should-be-ignored.rs @@ -11,18 +11,15 @@ // Be sure that when a SIGPIPE would have been received that the entire process // doesn't die in a ball of fire, but rather it's gracefully handled. -use std::os; use std::env; -use std::old_io::PipeStream; -use std::old_io::Command; +use std::io::prelude::*; +use std::io; +use std::process::{Command, Stdio}; fn test() { - let os::Pipe { reader, writer } = unsafe { os::pipe().unwrap() }; - let reader = PipeStream::open(reader); - let mut writer = PipeStream::open(writer); - drop(reader); - - let _ = writer.write(&[1]); + let _ = io::stdin().read_line(&mut String::new()); + io::stdout().write(&[1]); + assert!(io::stdout().flush().is_err()); } fn main() { @@ -32,6 +29,9 @@ fn main() { } let mut p = Command::new(&args[0]) + .stdout(Stdio::piped()) + .stdin(Stdio::piped()) .arg("test").spawn().unwrap(); + drop(p.stdout.take()); assert!(p.wait().unwrap().success()); } diff --git a/src/test/run-pass/stat.rs b/src/test/run-pass/stat.rs index 87d7376c243..1ccc189dc81 100644 --- a/src/test/run-pass/stat.rs +++ b/src/test/run-pass/stat.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::old_io::fs::PathExtensions; -use std::old_io::{File, TempDir}; +use std::fs::{File, TempDir}; +use std::io::prelude::*; pub fn main() { - let dir = TempDir::new_in(&Path::new("."), "").unwrap(); + let dir = TempDir::new_in(".", "").unwrap(); let path = dir.path().join("file"); { @@ -20,7 +20,7 @@ pub fn main() { Err(..) => unreachable!(), Ok(f) => { let mut f = f; - for _ in 0_usize..1000 { + for _ in 0..1000 { f.write(&[0]); } } @@ -28,5 +28,5 @@ pub fn main() { } assert!(path.exists()); - assert_eq!(path.stat().unwrap().size, 1000); + assert_eq!(path.metadata().unwrap().len(), 1000); } diff --git a/src/test/run-pass/tcp-stress.rs b/src/test/run-pass/tcp-stress.rs index 23ea998c026..e06e6883a75 100644 --- a/src/test/run-pass/tcp-stress.rs +++ b/src/test/run-pass/tcp-stress.rs @@ -19,7 +19,7 @@ extern crate libc; use std::sync::mpsc::channel; use std::old_io::net::tcp::{TcpListener, TcpStream}; -use std::old_io::{Acceptor, Listener}; +use std::old_io::{Acceptor, Listener, Reader, Writer}; use std::thread::{Builder, Thread}; use std::time::Duration; diff --git a/src/test/run-pass/tempfile.rs b/src/test/run-pass/tempfile.rs index 053df3a57f3..bc655837bab 100644 --- a/src/test/run-pass/tempfile.rs +++ b/src/test/run-pass/tempfile.rs @@ -18,6 +18,7 @@ // they're in a different location than before. Hence, these tests are all run // serially here. +use std::old_path::{Path, GenericPath}; use std::old_io::fs::PathExtensions; use std::old_io::{fs, TempDir}; use std::old_io; diff --git a/src/test/run-pass/trait-coercion.rs b/src/test/run-pass/trait-coercion.rs index b02f8eb0aa9..d1af6b746ac 100644 --- a/src/test/run-pass/trait-coercion.rs +++ b/src/test/run-pass/trait-coercion.rs @@ -8,10 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] #![feature(box_syntax)] -use std::old_io; +use std::io::{self, Write}; trait Trait { fn f(&self); @@ -29,9 +28,7 @@ impl Trait for Struct { } } -fn foo(mut a: Box<Writer>) { - a.write(b"Hello\n"); -} +fn foo(mut a: Box<Write>) {} // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. @@ -42,6 +39,6 @@ pub fn main() { let c: &Trait = &a; c.f(); - let out = old_io::stdout(); + let out = io::stdout(); foo(Box::new(out)); } |
