diff options
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/buffered.rs | 11 | ||||
| -rw-r--r-- | src/libstd/io/comm_adapters.rs | 12 | ||||
| -rw-r--r-- | src/libstd/io/extensions.rs | 8 | ||||
| -rw-r--r-- | src/libstd/io/fs.rs | 30 | ||||
| -rw-r--r-- | src/libstd/io/mem.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/net/pipe.rs | 28 | ||||
| -rw-r--r-- | src/libstd/io/net/tcp.rs | 26 | ||||
| -rw-r--r-- | src/libstd/io/net/udp.rs | 32 | ||||
| -rw-r--r-- | src/libstd/io/process.rs | 18 | ||||
| -rw-r--r-- | src/libstd/io/result.rs | 6 | ||||
| -rw-r--r-- | src/libstd/io/stdio.rs | 8 | ||||
| -rw-r--r-- | src/libstd/io/test.rs | 6 | ||||
| -rw-r--r-- | src/libstd/io/timer.rs | 6 |
14 files changed, 98 insertions, 99 deletions
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 95c44e6a3fc..9cd8dbcc509 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -183,7 +183,7 @@ impl<W: Writer> BufferedWriter<W> { /// /// The buffer is flushed before returning the writer. pub fn unwrap(mut self) -> W { - // FIXME(#12628): is failing the right thing to do if flushing fails? + // FIXME(#12628): is panicking the right thing to do if flushing panicks? self.flush_buf().unwrap(); self.inner.take().unwrap() } @@ -214,7 +214,7 @@ impl<W: Writer> Writer for BufferedWriter<W> { impl<W: Writer> Drop for BufferedWriter<W> { fn drop(&mut self) { if self.inner.is_some() { - // dtors should not fail, so we ignore a failed flush + // dtors should not panic, so we ignore a panicked flush let _ = self.flush_buf(); } } @@ -612,7 +612,7 @@ mod test { #[test] #[should_fail] - fn dont_fail_in_drop_on_failed_flush() { + fn dont_panic_in_drop_on_panicked_flush() { struct FailFlushWriter; impl Writer for FailFlushWriter { @@ -623,9 +623,8 @@ mod test { let writer = FailFlushWriter; let _writer = BufferedWriter::new(writer); - // Trigger failure. If writer fails *again* due to the flush - // error then the process will abort. - fail!(); + // If writer panics *again* due to the flush error then the process will abort. + panic!(); } #[bench] diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs index bd9577c8cfc..07f4ebda2d4 100644 --- a/src/libstd/io/comm_adapters.rs +++ b/src/libstd/io/comm_adapters.rs @@ -188,14 +188,14 @@ mod test { assert_eq!(a, buf.as_slice()); match reader.read(buf.as_mut_slice()) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } assert_eq!(a, buf.as_slice()); - // Ensure it continues to fail in the same way. + // Ensure it continues to panic in the same way. match reader.read(buf.as_mut_slice()) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } assert_eq!(a, buf.as_slice()); @@ -218,7 +218,7 @@ mod test { assert_eq!(Ok("hello world\n".to_string()), reader.read_line()); assert_eq!(Ok("how are you?".to_string()), reader.read_line()); match reader.read_line() { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } } @@ -232,12 +232,12 @@ mod test { let wanted = vec![0u8, 0u8, 0u8, 42u8]; let got = match task::try(proc() { rx.recv() }) { Ok(got) => got, - Err(_) => fail!(), + Err(_) => panic!(), }; assert_eq!(wanted, got); match writer.write_u8(1) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::BrokenPipe), } } diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 57741db5ae2..a595921fcf7 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -70,7 +70,7 @@ impl<'r, R: Reader> Iterator<IoResult<u8>> for Bytes<'r, R> { /// /// * `n`: The value to convert. /// * `size`: The size of the value, in bytes. This must be 8 or less, or task -/// failure occurs. If this is less than 8, then a value of that +/// panic occurs. If this is less than 8, then a value of that /// many bytes is produced. For example, if `size` is 4, then a /// 32-bit byte representation is produced. /// * `f`: A callback that receives the value. @@ -109,7 +109,7 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { /// /// * `n`: The value to convert. /// * `size`: The size of the value, in bytes. This must be 8 or less, or task -/// failure occurs. If this is less than 8, then a value of that +/// panic occurs. If this is less than 8, then a value of that /// many bytes is produced. For example, if `size` is 4, then a /// 32-bit byte representation is produced. /// * `f`: A callback that receives the value. @@ -146,7 +146,7 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { /// * `data`: The buffer in which to extract the value. /// * `start`: The offset at which to extract the value. /// * `size`: The size of the value in bytes to extract. This must be 8 or -/// less, or task failure occurs. If this is less than 8, then only +/// less, or task panic occurs. If this is less than 8, then only /// that many bytes are parsed. For example, if `size` is 4, then a /// 32-bit value is parsed. pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { @@ -156,7 +156,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { assert!(size <= 8u); if data.len() - start < size { - fail!("index out of bounds"); + panic!("index out of bounds"); } let mut buf = [0u8, ..8]; diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 8632fc63e52..f749d6c823e 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -105,7 +105,7 @@ impl File { /// /// let file = match File::open_mode(&p, Open, ReadWrite) { /// Ok(f) => f, - /// Err(e) => fail!("file error: {}", e), + /// Err(e) => panic!("file error: {}", e), /// }; /// // do some stuff with that file /// @@ -957,13 +957,13 @@ mod test { macro_rules! check( ($e:expr) => ( match $e { Ok(t) => t, - Err(e) => fail!("{} failed with: {}", stringify!($e), e), + Err(e) => panic!("{} failed with: {}", stringify!($e), e), } ) ) macro_rules! error( ($e:expr, $s:expr) => ( match $e { - Ok(val) => fail!("Unexpected success. Should've been: {}", $s), + Ok(val) => panic!("Unexpected success. Should've been: {}", $s), Err(ref err) => assert!(err.to_string().as_slice().contains($s.as_slice()), format!("`{}` did not contain `{}`", err, $s)) } @@ -1013,7 +1013,7 @@ mod test { let mut read_stream = File::open_mode(filename, Open, Read); let mut read_buf = [0, .. 1028]; let read_str = match check!(read_stream.read(read_buf)) { - -1|0 => fail!("shouldn't happen"), + -1|0 => panic!("shouldn't happen"), n => str::from_utf8(read_buf[..n]).unwrap().to_string() }; assert_eq!(read_str.as_slice(), message); @@ -1241,7 +1241,7 @@ mod test { check!(File::open(f).read(mem)); let read_str = str::from_utf8(mem).unwrap(); let expected = match n { - None|Some("") => fail!("really shouldn't happen.."), + None|Some("") => panic!("really shouldn't happen.."), Some(n) => format!("{}{}", prefix, n), }; assert_eq!(expected.as_slice(), read_str); @@ -1371,7 +1371,7 @@ mod test { from.display(), to.display())); match copy(&from, &to) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(..) => { assert!(!from.exists()); assert!(!to.exists()); @@ -1400,7 +1400,7 @@ mod test { check!(File::create(&out)); match copy(&out, tmpdir.path()) { - Ok(..) => fail!(), Err(..) => {} + Ok(..) => panic!(), Err(..) => {} } } @@ -1424,7 +1424,7 @@ mod test { let out = tmpdir.join("out"); match copy(tmpdir.path(), &out) { - Ok(..) => fail!(), Err(..) => {} + Ok(..) => panic!(), Err(..) => {} } assert!(!out.exists()); } @@ -1475,7 +1475,7 @@ mod test { fn readlink_not_symlink() { let tmpdir = tmpdir(); match readlink(tmpdir.path()) { - Ok(..) => fail!("wanted a failure"), + Ok(..) => panic!("wanted a failure"), Err(..) => {} } } @@ -1501,12 +1501,12 @@ mod test { // can't link to yourself match link(&input, &input) { - Ok(..) => fail!("wanted a failure"), + Ok(..) => panic!("wanted a failure"), Err(..) => {} } // can't link to something that doesn't exist match link(&tmpdir.join("foo"), &tmpdir.join("bar")) { - Ok(..) => fail!("wanted a failure"), + Ok(..) => panic!("wanted a failure"), Err(..) => {} } } @@ -1522,7 +1522,7 @@ mod test { assert!(!check!(stat(&file)).perm.contains(io::USER_WRITE)); match chmod(&tmpdir.join("foo"), io::USER_RWX) { - Ok(..) => fail!("wanted a failure"), + Ok(..) => panic!("wanted a panic"), Err(..) => {} } @@ -1580,7 +1580,7 @@ mod test { let tmpdir = tmpdir(); match File::open_mode(&tmpdir.join("a"), io::Open, io::Read) { - Ok(..) => fail!(), Err(..) => {} + Ok(..) => panic!(), Err(..) => {} } // Perform each one twice to make sure that it succeeds the second time @@ -1615,7 +1615,7 @@ mod test { let mut f = check!(File::open_mode(&tmpdir.join("h"), io::Open, io::Read)); match f.write("wut".as_bytes()) { - Ok(..) => fail!(), Err(..) => {} + Ok(..) => panic!(), Err(..) => {} } } assert!(check!(stat(&tmpdir.join("h"))).size == 3, @@ -1653,7 +1653,7 @@ mod test { let tmpdir = tmpdir(); match change_file_times(&tmpdir.join("a"), 100, 200) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(..) => {} } } diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index dd4a3e05935..2f6dd7e4795 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -409,7 +409,7 @@ mod test { writer.write([0]).unwrap(); match writer.write([0, 0]) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::OtherIoError), } } @@ -510,7 +510,7 @@ mod test { let buf = [0xff]; let mut r = BufReader::new(buf); match r.read_to_string() { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(..) => {} } } diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 8592d48974a..7826a6dd9c6 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1730,7 +1730,7 @@ pub enum FileType { /// # fn foo() { /// let info = match Path::new("foo.txt").stat() { /// Ok(stat) => stat, -/// Err(e) => fail!("couldn't read foo.txt: {}", e), +/// Err(e) => panic!("couldn't read foo.txt: {}", e), /// }; /// /// println!("byte size: {}", info.size); diff --git a/src/libstd/io/net/pipe.rs b/src/libstd/io/net/pipe.rs index e0cf761fdbd..112094d1d39 100644 --- a/src/libstd/io/net/pipe.rs +++ b/src/libstd/io/net/pipe.rs @@ -269,13 +269,13 @@ mod tests { spawn(proc() { match UnixStream::connect(&path2) { Ok(c) => client(c), - Err(e) => fail!("failed connect: {}", e), + Err(e) => panic!("failed connect: {}", e), } }); match acceptor.accept() { Ok(c) => server(c), - Err(e) => fail!("failed accept: {}", e), + Err(e) => panic!("failed accept: {}", e), } } @@ -283,7 +283,7 @@ mod tests { fn bind_error() { let path = "path/to/nowhere"; match UnixListener::bind(&path) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => { assert!(e.kind == PermissionDenied || e.kind == FileNotFound || e.kind == InvalidInput); @@ -299,7 +299,7 @@ mod tests { "path/to/nowhere" }; match UnixStream::connect(&path) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => { assert!(e.kind == FileNotFound || e.kind == OtherIoError); } @@ -358,7 +358,7 @@ mod tests { let mut acceptor = match UnixListener::bind(&path1).listen() { Ok(a) => a, - Err(e) => fail!("failed listen: {}", e), + Err(e) => panic!("failed listen: {}", e), }; spawn(proc() { @@ -366,7 +366,7 @@ mod tests { let mut stream = UnixStream::connect(&path2); match stream.write([100]) { Ok(..) => {} - Err(e) => fail!("failed write: {}", e) + Err(e) => panic!("failed write: {}", e) } } }); @@ -376,7 +376,7 @@ mod tests { let mut buf = [0]; match client.read(buf) { Ok(..) => {} - Err(e) => fail!("failed read/accept: {}", e), + Err(e) => panic!("failed read/accept: {}", e), } assert_eq!(buf[0], 100); } @@ -531,10 +531,10 @@ mod tests { match a.accept() { Ok(..) => break, Err(ref e) if e.kind == TimedOut => {} - Err(e) => fail!("error: {}", e), + Err(e) => panic!("error: {}", e), } ::task::deschedule(); - if i == 1000 { fail!("should have a pending connection") } + if i == 1000 { panic!("should have a pending connection") } } drop(l); @@ -659,9 +659,9 @@ mod tests { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } - if i == 1000 { fail!("should have filled up?!"); } + if i == 1000 { panic!("should have filled up?!"); } } // I'm not sure as to why, but apparently the write on windows always @@ -687,7 +687,7 @@ mod tests { while amt < 100 * 128 * 1024 { match s.read([0, ..128 * 1024]) { Ok(n) => { amt += n; } - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } } let _ = rx.recv_opt(); @@ -722,9 +722,9 @@ mod tests { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } - if i == 1000 { fail!("should have filled up?!"); } + if i == 1000 { panic!("should have filled up?!"); } } tx.send(()); diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index d6528ce977e..09804ef5703 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -471,7 +471,7 @@ impl TcpAcceptor { /// match socket { /// Ok(s) => { /* handle s */ } /// Err(ref e) if e.kind == EndOfFile => break, // closed - /// Err(e) => fail!("unexpected error: {}", e), + /// Err(e) => panic!("unexpected error: {}", e), /// } /// } /// }); @@ -532,7 +532,7 @@ mod test { #[test] fn bind_error() { match TcpListener::bind("0.0.0.0", 1) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, PermissionDenied), } } @@ -540,7 +540,7 @@ mod test { #[test] fn connect_error() { match TcpStream::connect("0.0.0.0", 1) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, ConnectionRefused), } } @@ -708,7 +708,7 @@ mod test { assert!(nread.is_err()); match stream.read(buf) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(ref e) => { assert!(e.kind == NotConnected || e.kind == EndOfFile, "unknown kind: {}", e.kind); @@ -734,7 +734,7 @@ mod test { assert!(nread.is_err()); match stream.read(buf) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(ref e) => { assert!(e.kind == NotConnected || e.kind == EndOfFile, "unknown kind: {}", e.kind); @@ -1082,7 +1082,7 @@ mod test { let listener = TcpListener::bind(ip_str.as_slice(), port).unwrap().listen(); assert!(listener.is_ok()); match TcpListener::bind(ip_str.as_slice(), port).listen() { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => { assert!(e.kind == ConnectionRefused || e.kind == OtherIoError, "unknown error: {} {}", e, e.kind); @@ -1266,10 +1266,10 @@ mod test { match a.accept() { Ok(..) => break, Err(ref e) if e.kind == TimedOut => {} - Err(e) => fail!("error: {}", e), + Err(e) => panic!("error: {}", e), } ::task::deschedule(); - if i == 1000 { fail!("should have a pending connection") } + if i == 1000 { panic!("should have a pending connection") } } } @@ -1373,9 +1373,9 @@ mod test { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } - if i == 1000 { fail!("should have filled up?!"); } + if i == 1000 { panic!("should have filled up?!"); } } assert_eq!(s.write([0]).err().unwrap().kind, TimedOut); @@ -1398,7 +1398,7 @@ mod test { while amt < 100 * 128 * 1024 { match s.read([0, ..128 * 1024]) { Ok(n) => { amt += n; } - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } } let _ = rx.recv_opt(); @@ -1435,9 +1435,9 @@ mod test { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } - if i == 1000 { fail!("should have filled up?!"); } + if i == 1000 { panic!("should have filled up?!"); } } assert_eq!(s.write([0]).err().unwrap().kind, TimedOut); diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 7d9eea3a732..ad9ed090a5b 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -43,7 +43,7 @@ use rt::rtio; /// let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 34254 }; /// let mut socket = match UdpSocket::bind(addr) { /// Ok(s) => s, -/// Err(e) => fail!("couldn't bind socket: {}", e), +/// Err(e) => panic!("couldn't bind socket: {}", e), /// }; /// /// let mut buf = [0, ..10]; @@ -271,7 +271,7 @@ mod test { fn bind_error() { let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 }; match UdpSocket::bind(addr) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, PermissionDenied), } } @@ -289,7 +289,7 @@ mod test { rx1.recv(); client.send_to([99], server_ip).unwrap() } - Err(..) => fail!() + Err(..) => panic!() } tx2.send(()); }); @@ -304,10 +304,10 @@ mod test { assert_eq!(buf[0], 99); assert_eq!(src, client_ip); } - Err(..) => fail!() + Err(..) => panic!() } } - Err(..) => fail!() + Err(..) => panic!() } rx2.recv(); } @@ -324,7 +324,7 @@ mod test { rx.recv(); client.send_to([99], server_ip).unwrap() } - Err(..) => fail!() + Err(..) => panic!() } }); @@ -338,10 +338,10 @@ mod test { assert_eq!(buf[0], 99); assert_eq!(src, client_ip); } - Err(..) => fail!() + Err(..) => panic!() } } - Err(..) => fail!() + Err(..) => panic!() } } @@ -362,7 +362,7 @@ mod test { let mut stream = client.connect(server_ip); stream.write(val).unwrap(); } - Err(..) => fail!() + Err(..) => panic!() } }; rx1.recv(); @@ -382,10 +382,10 @@ mod test { assert_eq!(nread, 1); assert_eq!(buf[0], 99); } - Err(..) => fail!(), + Err(..) => panic!(), } } - Err(..) => fail!() + Err(..) => panic!() } rx2.recv(); } @@ -406,7 +406,7 @@ mod test { rx1.recv(); stream.write([99]).unwrap(); } - Err(..) => fail!() + Err(..) => panic!() } tx2.send(()); }); @@ -422,10 +422,10 @@ mod test { assert_eq!(nread, 1); assert_eq!(buf[0], 99); } - Err(..) => fail!() + Err(..) => panic!() } } - Err(..) => fail!() + Err(..) => panic!() } rx2.recv(); } @@ -535,7 +535,7 @@ mod test { rx.recv(); match sock2.recv_from(buf) { Ok(..) => {} - Err(e) => fail!("failed receive: {}", e), + Err(e) => panic!("failed receive: {}", e), } serv_tx.send(()); }); @@ -612,7 +612,7 @@ mod test { match a.send_to([0, ..4*1024], addr2) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, - Err(e) => fail!("other error: {}", e), + Err(e) => panic!("other error: {}", e), } } } diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 88f8434b957..36d23590704 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -56,7 +56,7 @@ use std::hash::sip::SipState; /// /// let mut child = match Command::new("/bin/cat").arg("file.txt").spawn() { /// Ok(child) => child, -/// Err(e) => fail!("failed to execute child: {}", e), +/// Err(e) => panic!("failed to execute child: {}", e), /// }; /// /// let contents = child.stdout.as_mut().unwrap().read_to_end(); @@ -145,7 +145,7 @@ pub type EnvMap = HashMap<EnvKey, CString>; /// /// let mut process = match Command::new("sh").arg("-c").arg("echo hello").spawn() { /// Ok(p) => p, -/// Err(e) => fail!("failed to execute process: {}", e), +/// Err(e) => panic!("failed to execute process: {}", e), /// }; /// /// let output = process.stdout.as_mut().unwrap().read_to_end(); @@ -372,7 +372,7 @@ impl Command { /// /// let output = match Command::new("cat").arg("foot.txt").output() { /// Ok(output) => output, - /// Err(e) => fail!("failed to execute process: {}", e), + /// Err(e) => panic!("failed to execute process: {}", e), /// }; /// /// println!("status: {}", output.status); @@ -393,7 +393,7 @@ impl Command { /// /// let status = match Command::new("ls").status() { /// Ok(status) => status, - /// Err(e) => fail!("failed to execute process: {}", e), + /// Err(e) => panic!("failed to execute process: {}", e), /// }; /// /// println!("process exited with: {}", status); @@ -691,7 +691,7 @@ mod tests { #[test] fn smoke_failure() { match Command::new("if-this-is-a-binary-then-the-world-has-ended").spawn() { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(..) => {} } } @@ -714,7 +714,7 @@ mod tests { let mut p = p.unwrap(); match p.wait().unwrap() { process::ExitSignal(1) => {}, - result => fail!("not terminated by signal 1 (instead, {})", result), + result => panic!("not terminated by signal 1 (instead, {})", result), } } @@ -815,7 +815,7 @@ mod tests { fn test_process_output_fail_to_start() { match Command::new("/no-binary-by-this-name-should-exist").output() { Err(e) => assert_eq!(e.kind, FileNotFound), - Ok(..) => fail!() + Ok(..) => panic!() } } @@ -1063,7 +1063,7 @@ mod tests { } timer::sleep(Duration::milliseconds(100)); } - fail!("never saw the child go away"); + panic!("never saw the child go away"); } #[test] @@ -1121,7 +1121,7 @@ mod tests { let mut fdes = match file::open(&path.to_c_str(), Truncate, Write) { Ok(f) => f, - Err(_) => fail!("failed to open file descriptor"), + Err(_) => panic!("failed to open file descriptor"), }; let mut cmd = pwd_cmd(); diff --git a/src/libstd/io/result.rs b/src/libstd/io/result.rs index 03637079241..40793d98ee3 100644 --- a/src/libstd/io/result.rs +++ b/src/libstd/io/result.rs @@ -96,11 +96,11 @@ mod test { Err(io::standard_error(io::EndOfFile)); match writer.write([0, 0, 0]) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } match writer.flush() { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } } @@ -122,7 +122,7 @@ mod test { let mut buf = []; match reader.read(buf) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } } diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 93037f765d6..5fd4faff6d2 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -176,8 +176,8 @@ pub fn set_stdout(stdout: Box<Writer + Send>) -> Option<Box<Writer + Send>> { /// Resets the task-local stderr handle to the specified writer /// /// This will replace the current task's stderr handle, returning the old -/// handle. Currently, the stderr handle is used for printing failure messages -/// during task failure. +/// handle. Currently, the stderr handle is used for printing panic messages +/// during task panic. /// /// Note that this does not need to be called for all new tasks; the default /// output handle is to the process's stderr stream. @@ -212,7 +212,7 @@ fn with_task_stdout(f: |&mut Writer| -> IoResult<()>) { }; match result { Ok(()) => {} - Err(e) => fail!("failed printing to stdout: {}", e), + Err(e) => panic!("failed printing to stdout: {}", e), } } @@ -415,7 +415,7 @@ mod tests { let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); spawn(proc() { ::realstd::io::stdio::set_stderr(box w); - fail!("my special message"); + panic!("my special message"); }); let s = r.read_to_string().unwrap(); assert!(s.as_slice().contains("my special message")); diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index 9b4333a6d82..6571dc41585 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -139,14 +139,14 @@ mod darwin_fd_limit { if sysctl(&mut mib[0], 2, &mut maxfiles as *mut libc::c_int as *mut libc::c_void, &mut size, null_mut(), 0) != 0 { let err = last_os_error(); - fail!("raise_fd_limit: error calling sysctl: {}", err); + panic!("raise_fd_limit: error calling sysctl: {}", err); } // Fetch the current resource limits let mut rlim = rlimit{rlim_cur: 0, rlim_max: 0}; if getrlimit(RLIMIT_NOFILE, &mut rlim) != 0 { let err = last_os_error(); - fail!("raise_fd_limit: error calling getrlimit: {}", err); + panic!("raise_fd_limit: error calling getrlimit: {}", err); } // Bump the soft limit to the smaller of kern.maxfilesperproc and the hard limit @@ -155,7 +155,7 @@ mod darwin_fd_limit { // Set our newly-increased resource limit if setrlimit(RLIMIT_NOFILE, &rlim) != 0 { let err = last_os_error(); - fail!("raise_fd_limit: error calling setrlimit: {}", err); + panic!("raise_fd_limit: error calling setrlimit: {}", err); } } } diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index a657989fe12..d16199da77f 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -340,7 +340,7 @@ mod test { fn oneshot_fail() { let mut timer = Timer::new().unwrap(); let _rx = timer.oneshot(Duration::milliseconds(1)); - fail!(); + panic!(); } #[test] @@ -348,14 +348,14 @@ mod test { fn period_fail() { let mut timer = Timer::new().unwrap(); let _rx = timer.periodic(Duration::milliseconds(1)); - fail!(); + panic!(); } #[test] #[should_fail] fn normal_fail() { let _timer = Timer::new().unwrap(); - fail!(); + panic!(); } #[test] |
