summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-02-01 11:24:42 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-02-03 10:39:23 -0800
commitc765a8e7ad314651b92ff860cda0159c79dbec6e (patch)
tree5cb922f942920dc7d6b0f3606e9cd914360b2707 /src/libstd
parentf9a32cdabc1680b89bd7b579dc1e3f8f18c28257 (diff)
downloadrust-c765a8e7ad314651b92ff860cda0159c79dbec6e.tar.gz
rust-c765a8e7ad314651b92ff860cda0159c79dbec6e.zip
Fixing remaining warnings and errors throughout
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/fmt/mod.rs27
-rw-r--r--src/libstd/io/mod.rs10
-rw-r--r--src/libstd/io/net/tcp.rs14
-rw-r--r--src/libstd/io/signal.rs1
-rw-r--r--src/libstd/os.rs1
-rw-r--r--src/libstd/path/mod.rs2
6 files changed, 26 insertions, 29 deletions
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs
index 0bc567b270a..06737e22007 100644
--- a/src/libstd/fmt/mod.rs
+++ b/src/libstd/fmt/mod.rs
@@ -477,16 +477,20 @@ will look like `"\\{"`.
 
 */
 
-#[cfg(not(stage0))]
-use prelude::*;
-
 use cast;
 use char::Char;
+use container::Container;
 use io::MemWriter;
 use io;
-use str;
+use iter::{Iterator, range};
+use num::Signed;
+use option::{Option,Some,None};
 use repr;
+use result::{Ok, Err};
+use str::StrSlice;
+use str;
 use util;
+use vec::ImmutableVector;
 use vec;
 
 // NOTE this is just because the `prelude::*` import above includes
@@ -494,19 +498,6 @@ use vec;
 #[cfg(stage0)]
 pub use Default = fmt::Show; // export required for `format!()` etc.
 
-#[cfg(stage0)]
-use container::Container;
-#[cfg(stage0)]
-use iter::{Iterator, range};
-#[cfg(stage0)]
-use option::{Option,Some,None};
-#[cfg(stage0)]
-use vec::ImmutableVector;
-#[cfg(stage0)]
-use str::StrSlice;
-#[cfg(stage0)]
-use num::Signed;
-
 pub mod parse;
 pub mod rt;
 
@@ -628,7 +619,7 @@ macro_rules! uniform_fn_call_workaround {
     ($( $name: ident, $trait_: ident; )*) => {
         $(
             #[doc(hidden)]
-            pub fn $name<T: $trait_>(x: &T, fmt: &mut Formatter) {
+            pub fn $name<T: $trait_>(x: &T, fmt: &mut Formatter) -> Result {
                 $trait_::fmt(x, fmt)
             }
             )*
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index 58a35e96393..7690c88478f 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -46,6 +46,7 @@ Some examples of obvious things you might want to do
 * Write a line to a file
 
     ```rust
+    # #[allow(unused_must_use)];
     use std::io::File;
 
     let mut file = File::create(&Path::new("message.txt"));
@@ -83,6 +84,7 @@ Some examples of obvious things you might want to do
   `write_str` and `write_line` methods.
 
     ```rust,should_fail
+    # #[allow(unused_must_use)];
     use std::io::net::ip::SocketAddr;
     use std::io::net::tcp::TcpStream;
 
@@ -188,6 +190,7 @@ be an error.
 If you wanted to handle the error though you might write:
 
 ```rust
+# #[allow(unused_must_use)];
 use std::io::File;
 
 match File::create(&Path::new("diary.txt")).write(bytes!("Met a girl.\n")) {
@@ -360,7 +363,7 @@ pub struct IoError {
     detail: Option<~str>
 }
 
-impl fmt::Default for IoError {
+impl fmt::Show for IoError {
     fn fmt(err: &IoError, fmt: &mut fmt::Formatter) -> fmt::Result {
         if_ok!(fmt.buf.write_str(err.desc));
         match err.detail {
@@ -515,14 +518,13 @@ pub trait Reader {
     /// Returns any non-EOF error immediately. Previously read bytes are
     /// discarded when an error is returned.
     ///
-    /// When EOF is encountered, all bytes read up to that point are returned,
-    /// but if 0 bytes have been read then the EOF error is returned.
+    /// When EOF is encountered, all bytes read up to that point are returned.
     fn read_to_end(&mut self) -> IoResult<~[u8]> {
         let mut buf = vec::with_capacity(DEFAULT_BUF_SIZE);
         loop {
             match self.push_bytes(&mut buf, DEFAULT_BUF_SIZE) {
                 Ok(()) => {}
-                Err(ref e) if buf.len() > 0 && e.kind == EndOfFile => break,
+                Err(ref e) if e.kind == EndOfFile => break,
                 Err(e) => return Err(e)
             }
         }
diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs
index f3db964b882..a0bdc193d98 100644
--- a/src/libstd/io/net/tcp.rs
+++ b/src/libstd/io/net/tcp.rs
@@ -192,9 +192,10 @@ mod test {
 
         match stream.read(buf) {
             Ok(..) => fail!(),
-            Err(ref e) if cfg!(windows) => assert_eq!(e.kind, NotConnected),
-            Err(ref e) if cfg!(unix) => assert_eq!(e.kind, EndOfFile),
-            Err(..) => fail!(),
+            Err(ref e) => {
+                assert!(e.kind == NotConnected || e.kind == EndOfFile,
+                        "unknown kind: {:?}", e.kind);
+            }
         }
     })
 
@@ -217,9 +218,10 @@ mod test {
 
         match stream.read(buf) {
             Ok(..) => fail!(),
-            Err(ref e) if cfg!(windows) => assert_eq!(e.kind, NotConnected),
-            Err(ref e) if cfg!(unix) => assert_eq!(e.kind, EndOfFile),
-            Err(..) => fail!(),
+            Err(ref e) => {
+                assert!(e.kind == NotConnected || e.kind == EndOfFile,
+                        "unknown kind: {:?}", e.kind);
+            }
         }
     })
 
diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs
index 92b86afe24d..75804c40c58 100644
--- a/src/libstd/io/signal.rs
+++ b/src/libstd/io/signal.rs
@@ -203,6 +203,7 @@ mod test {
     fn test_io_signal_invalid_signum() {
         use io;
         use super::User1;
+        use result::{Ok, Err};
         let mut s = Listener::new();
         let mut called = false;
         match s.register(User1) {
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 8815f88d694..541db01f148 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -1535,6 +1535,7 @@ mod tests {
             assert!(*chunk.data == 0xbe);
             close(fd);
         }
+        drop(chunk);
 
         fs::unlink(&path).unwrap();
     }
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index 190cf5745f4..4aa4a3feab1 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -533,7 +533,7 @@ pub struct Display<'a, P> {
 }
 
 impl<'a, P: GenericPath> fmt::Show for Display<'a, P> {
-    fn fmt(d: &Display<P>, f: &mut fmt::Formatter) -> fmt::Display {
+    fn fmt(d: &Display<P>, f: &mut fmt::Formatter) -> fmt::Result {
         d.with_str(|s| f.pad(s))
     }
 }