about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAndre Bogus <bogusandre@gmail.com>2015-09-08 00:36:29 +0200
committerAndre Bogus <bogusandre@gmail.com>2015-09-08 00:36:29 +0200
commit9cca96545faf2cfc972cc67b83deae2a78935c43 (patch)
treeef675da82a1ce1b23173921957f6a6a167ad8db8 /src/libstd
parent7bf626a68045be1d1a4fac9a635113bb7775b6bb (diff)
downloadrust-9cca96545faf2cfc972cc67b83deae2a78935c43.tar.gz
rust-9cca96545faf2cfc972cc67b83deae2a78935c43.zip
some more clippy-based improvements
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/dynamic_lib.rs2
-rw-r--r--src/libstd/io/error.rs6
-rw-r--r--src/libstd/io/lazy.rs2
-rw-r--r--src/libstd/net/parser.rs4
-rw-r--r--src/libstd/rt/at_exit_imp.rs4
-rw-r--r--src/libstd/rt/dwarf/eh.rs2
-rw-r--r--src/libstd/rt/mod.rs2
-rw-r--r--src/libstd/rt/util.rs2
-rw-r--r--src/libstd/sync/mpsc/mod.rs8
-rw-r--r--src/libstd/sync/mpsc/spsc_queue.rs7
-rw-r--r--src/libstd/sync/mpsc/stream.rs9
-rw-r--r--src/libstd/sync/mpsc/sync.rs12
-rw-r--r--src/libstd/sync/mutex.rs5
-rw-r--r--src/libstd/sys/common/gnu/libbacktrace.rs2
-rw-r--r--src/libstd/sys/common/net.rs2
-rw-r--r--src/libstd/sys/common/remutex.rs4
-rw-r--r--src/libstd/sys/common/wtf8.rs18
-rw-r--r--src/libstd/sys/unix/backtrace/tracing/gcc_s.rs2
-rw-r--r--src/libstd/sys/unix/net.rs2
-rw-r--r--src/libstd/sys/unix/os.rs6
-rw-r--r--src/libstd/sys/unix/stdio.rs6
-rw-r--r--src/libstd/sys/unix/thread.rs2
-rw-r--r--src/libstd/sys/unix/thread_local.rs2
23 files changed, 47 insertions, 64 deletions
diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs
index 43bfce9b9e9..7801662ff25 100644
--- a/src/libstd/dynamic_lib.rs
+++ b/src/libstd/dynamic_lib.rs
@@ -231,7 +231,7 @@ mod dl {
                 Ok(result)
             } else {
                 let s = CStr::from_ptr(last_error).to_bytes();
-                Err(str::from_utf8(s).unwrap().to_string())
+                Err(str::from_utf8(s).unwrap().to_owned())
             };
 
             ret
diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs
index d161b625068..576d9b92156 100644
--- a/src/libstd/io/error.rs
+++ b/src/libstd/io/error.rs
@@ -277,11 +277,11 @@ impl Error {
 
 impl fmt::Debug for Repr {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-        match self {
-            &Repr::Os(ref code) =>
+        match *self {
+            Repr::Os(ref code) =>
                 fmt.debug_struct("Os").field("code", code)
                    .field("message", &sys::os::error_string(*code)).finish(),
-            &Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(),
+            Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(),
         }
     }
 }
diff --git a/src/libstd/io/lazy.rs b/src/libstd/io/lazy.rs
index ad17a650336..5424fec8110 100644
--- a/src/libstd/io/lazy.rs
+++ b/src/libstd/io/lazy.rs
@@ -62,6 +62,6 @@ impl<T: Send + Sync + 'static> Lazy<T> {
         if registered.is_ok() {
             self.ptr.set(Box::into_raw(Box::new(ret.clone())));
         }
-        return ret
+        ret
     }
 }
diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs
index 480fd63c36a..f0b35bbc388 100644
--- a/src/libstd/net/parser.rs
+++ b/src/libstd/net/parser.rs
@@ -262,8 +262,8 @@ impl<'a> Parser<'a> {
     }
 
     fn read_ip_addr(&mut self) -> Option<IpAddr> {
-        let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr().map(|v4| IpAddr::V4(v4));
-        let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr().map(|v6| IpAddr::V6(v6));
+        let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr().map(IpAddr::V4);
+        let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr().map(IpAddr::V6);
         self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)])
     }
 
diff --git a/src/libstd/rt/at_exit_imp.rs b/src/libstd/rt/at_exit_imp.rs
index 379c86eb2a0..7a1215bf382 100644
--- a/src/libstd/rt/at_exit_imp.rs
+++ b/src/libstd/rt/at_exit_imp.rs
@@ -42,7 +42,7 @@ unsafe fn init() -> bool {
         return false
     }
 
-    return true
+    true
 }
 
 pub fn cleanup() {
@@ -78,5 +78,5 @@ pub fn push(f: Box<FnBox()>) -> bool {
         }
         LOCK.unlock();
     }
-    return ret
+    ret
 }
diff --git a/src/libstd/rt/dwarf/eh.rs b/src/libstd/rt/dwarf/eh.rs
index 990501b28db..f4799703d99 100644
--- a/src/libstd/rt/dwarf/eh.rs
+++ b/src/libstd/rt/dwarf/eh.rs
@@ -104,7 +104,7 @@ pub unsafe fn find_landing_pad(lsda: *const u8, context: &EHContext)
     // IP range not found: gcc's C++ personality calls terminate() here,
     // however the rest of the languages treat this the same as cs_lpad == 0.
     // We follow this suit.
-    return None;
+    None
 }
 
 #[inline]
diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs
index f2bf8757a51..95cba132201 100644
--- a/src/libstd/rt/mod.rs
+++ b/src/libstd/rt/mod.rs
@@ -73,7 +73,7 @@ fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
         // created. Note that this isn't necessary in general for new threads,
         // but we just do this to name the main thread and to give it correct
         // info about the stack bounds.
-        let thread: Thread = NewThread::new(Some("<main>".to_string()));
+        let thread: Thread = NewThread::new(Some("<main>".to_owned()));
         thread_info::set(main_guard, thread);
 
         // By default, some platforms will send a *signal* when a EPIPE error
diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs
index 0fe8d873a75..23a3c3e38c4 100644
--- a/src/libstd/rt/util.rs
+++ b/src/libstd/rt/util.rs
@@ -27,7 +27,7 @@ pub fn min_stack() -> usize {
     // 0 is our sentinel value, so ensure that we'll never see 0 after
     // initialization has run
     MIN.store(amt + 1, Ordering::SeqCst);
-    return amt;
+    amt
 }
 
 // Indicates whether we should perform expensive sanity checks, including rtassert!
diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs
index c37c0405bbb..8c5cec969a6 100644
--- a/src/libstd/sync/mpsc/mod.rs
+++ b/src/libstd/sync/mpsc/mod.rs
@@ -397,7 +397,7 @@ enum Flavor<T> {
 
 #[doc(hidden)]
 trait UnsafeFlavor<T> {
-    fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>>;
+    fn inner_unsafe(&self) -> &UnsafeCell<Flavor<T>>;
     unsafe fn inner_mut<'a>(&'a self) -> &'a mut Flavor<T> {
         &mut *self.inner_unsafe().get()
     }
@@ -406,12 +406,12 @@ trait UnsafeFlavor<T> {
     }
 }
 impl<T> UnsafeFlavor<T> for Sender<T> {
-    fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
+    fn inner_unsafe(&self) -> &UnsafeCell<Flavor<T>> {
         &self.inner
     }
 }
 impl<T> UnsafeFlavor<T> for Receiver<T> {
-    fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
+    fn inner_unsafe(&self) -> &UnsafeCell<Flavor<T>> {
         &self.inner
     }
 }
@@ -677,7 +677,7 @@ impl<T> SyncSender<T> {
 impl<T> Clone for SyncSender<T> {
     fn clone(&self) -> SyncSender<T> {
         unsafe { (*self.inner.get()).clone_chan(); }
-        return SyncSender::new(self.inner.clone());
+        SyncSender::new(self.inner.clone())
     }
 }
 
diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs
index 819f75c006b..ffd33f8518f 100644
--- a/src/libstd/sync/mpsc/spsc_queue.rs
+++ b/src/libstd/sync/mpsc/spsc_queue.rs
@@ -196,7 +196,7 @@ impl<T> Queue<T> {
                     let _: Box<Node<T>> = Box::from_raw(tail);
                 }
             }
-            return ret;
+            ret
         }
     }
 
@@ -207,14 +207,13 @@ impl<T> Queue<T> {
     /// The reference returned is invalid if it is not used before the consumer
     /// pops the value off the queue. If the producer then pushes another value
     /// onto the queue, it will overwrite the value pointed to by the reference.
-    pub fn peek<'a>(&'a self) -> Option<&'a mut T> {
+    pub fn peek(&self) -> Option<&mut T> {
         // This is essentially the same as above with all the popping bits
         // stripped out.
         unsafe {
             let tail = *self.tail.get();
             let next = (*tail).next.load(Ordering::Acquire);
-            if next.is_null() { return None }
-            return (*next).value.as_mut();
+            if next.is_null() { None } else { (*next).value.as_mut() }
         }
     }
 }
diff --git a/src/libstd/sync/mpsc/stream.rs b/src/libstd/sync/mpsc/stream.rs
index a9da1b12f7d..e8012ca470b 100644
--- a/src/libstd/sync/mpsc/stream.rs
+++ b/src/libstd/sync/mpsc/stream.rs
@@ -307,12 +307,7 @@ impl<T> Packet<T> {
                             steals, DISCONNECTED, Ordering::SeqCst);
             cnt != DISCONNECTED && cnt != steals
         } {
-            loop {
-                match self.queue.pop() {
-                    Some(..) => { steals += 1; }
-                    None => break
-                }
-            }
+            while let Some(_) = self.queue.pop() { steals += 1; }
         }
 
         // At this point in time, we have gated all future senders from sending,
@@ -378,7 +373,7 @@ impl<T> Packet<T> {
                 // previous value is positive because we're not going to sleep
                 let prev = self.bump(1);
                 assert!(prev == DISCONNECTED || prev >= 0);
-                return ret;
+                ret
             }
         }
     }
diff --git a/src/libstd/sync/mpsc/sync.rs b/src/libstd/sync/mpsc/sync.rs
index 84d758cf9b3..b98fc2859af 100644
--- a/src/libstd/sync/mpsc/sync.rs
+++ b/src/libstd/sync/mpsc/sync.rs
@@ -254,7 +254,7 @@ impl<T> Packet<T> {
         assert!(guard.buf.size() > 0);
         let ret = guard.buf.dequeue();
         self.wakeup_senders(waited, guard);
-        return Ok(ret);
+        Ok(ret)
     }
 
     pub fn try_recv(&self) -> Result<T, Failure> {
@@ -267,8 +267,7 @@ impl<T> Packet<T> {
         // Be sure to wake up neighbors
         let ret = Ok(guard.buf.dequeue());
         self.wakeup_senders(false, guard);
-
-        return ret;
+        ret
     }
 
     // Wake up pending senders after some data has been received
@@ -356,12 +355,7 @@ impl<T> Packet<T> {
         };
         mem::drop(guard);
 
-        loop {
-            match queue.dequeue() {
-                Some(token) => { token.signal(); }
-                None => break,
-            }
-        }
+        while let Some(token) = queue.dequeue() { token.signal(); }
         waiter.map(|t| t.signal());
     }
 
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs
index e56e5a72c13..846a97b547d 100644
--- a/src/libstd/sync/mutex.rs
+++ b/src/libstd/sync/mutex.rs
@@ -334,13 +334,14 @@ impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> {
 impl<'mutex, T: ?Sized> Deref for MutexGuard<'mutex, T> {
     type Target = T;
 
-    fn deref<'a>(&'a self) -> &'a T {
+    fn deref(&self) -> &T {
         unsafe { &*self.__data.get() }
     }
 }
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'mutex, T: ?Sized> DerefMut for MutexGuard<'mutex, T> {
-    fn deref_mut<'a>(&'a mut self) -> &'a mut T {
+    fn deref_mut(&mut self) -> &mut T {
         unsafe { &mut *self.__data.get() }
     }
 }
diff --git a/src/libstd/sys/common/gnu/libbacktrace.rs b/src/libstd/sys/common/gnu/libbacktrace.rs
index 7a2ca0a9f09..3b846fd462e 100644
--- a/src/libstd/sys/common/gnu/libbacktrace.rs
+++ b/src/libstd/sys/common/gnu/libbacktrace.rs
@@ -151,7 +151,7 @@ pub fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void,
         };
         STATE = backtrace_create_state(filename, 0, error_cb,
                                        ptr::null_mut());
-        return STATE
+        STATE
     }
 
     ////////////////////////////////////////////////////////////////////////
diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs
index 4fb3134eac9..37379596251 100644
--- a/src/libstd/sys/common/net.rs
+++ b/src/libstd/sys/common/net.rs
@@ -161,7 +161,7 @@ pub fn lookup_addr(addr: &IpAddr) -> io::Result<String> {
     };
 
     match from_utf8(data.to_bytes()) {
-        Ok(name) => Ok(name.to_string()),
+        Ok(name) => Ok(name.to_owned()),
         Err(_) => Err(io::Error::new(io::ErrorKind::Other,
                                      "failed to lookup address information"))
     }
diff --git a/src/libstd/sys/common/remutex.rs b/src/libstd/sys/common/remutex.rs
index 4df3441f87b..f3f21e47a14 100644
--- a/src/libstd/sys/common/remutex.rs
+++ b/src/libstd/sys/common/remutex.rs
@@ -67,7 +67,7 @@ impl<T> ReentrantMutex<T> {
                 data: t,
             };
             mutex.inner.init();
-            return mutex
+            mutex
         }
     }
 
@@ -145,7 +145,7 @@ impl<'mutex, T> ReentrantMutexGuard<'mutex, T> {
 impl<'mutex, T> Deref for ReentrantMutexGuard<'mutex, T> {
     type Target = T;
 
-    fn deref<'a>(&'a self) -> &'a T {
+    fn deref(&self) -> &T {
         &self.__lock.data
     }
 }
diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs
index eb313d275a1..633e7d78a9a 100644
--- a/src/libstd/sys/common/wtf8.rs
+++ b/src/libstd/sys/common/wtf8.rs
@@ -282,19 +282,13 @@ impl Wtf8Buf {
     /// like concatenating ill-formed UTF-16 strings effectively would.
     #[inline]
     pub fn push(&mut self, code_point: CodePoint) {
-        match code_point.to_u32() {
-            trail @ 0xDC00...0xDFFF => {
-                match (&*self).final_lead_surrogate() {
-                    Some(lead) => {
-                        let len_without_lead_surrogate = self.len() - 3;
-                        self.bytes.truncate(len_without_lead_surrogate);
-                        self.push_char(decode_surrogate_pair(lead, trail as u16));
-                        return
-                    }
-                    _ => {}
-                }
+        if let trail @ 0xDC00...0xDFFF = code_point.to_u32() {
+            if let Some(lead) = (&*self).final_lead_surrogate() {
+                let len_without_lead_surrogate = self.len() - 3;
+                self.bytes.truncate(len_without_lead_surrogate);
+                self.push_char(decode_surrogate_pair(lead, trail as u16));
+                return
             }
-            _ => {}
         }
 
         // No newly paired surrogates at the boundary.
diff --git a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs
index cdaf69c4882..8b32b5ec040 100644
--- a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs
+++ b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs
@@ -99,7 +99,7 @@ pub fn write(w: &mut Write) -> io::Result<()> {
         }
 
         // keep going
-        return uw::_URC_NO_REASON
+        uw::_URC_NO_REASON
     }
 }
 
diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs
index f1a9518d08d..6d65cb838f6 100644
--- a/src/libstd/sys/unix/net.rs
+++ b/src/libstd/sys/unix/net.rs
@@ -35,7 +35,7 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> {
 
     let detail = unsafe {
         str::from_utf8(CStr::from_ptr(c::gai_strerror(err)).to_bytes()).unwrap()
-            .to_string()
+            .to_owned()
     };
     Err(io::Error::new(io::ErrorKind::Other,
                        &format!("failed to lookup address information: {}",
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index 70be04b631a..af0d8da05f4 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -88,7 +88,7 @@ pub fn error_string(errno: i32) -> String {
         }
 
         let p = p as *const _;
-        str::from_utf8(CStr::from_ptr(p).to_bytes()).unwrap().to_string()
+        str::from_utf8(CStr::from_ptr(p).to_bytes()).unwrap().to_owned()
     }
 }
 
@@ -134,7 +134,7 @@ pub struct SplitPaths<'a> {
                     fn(&'a [u8]) -> PathBuf>,
 }
 
-pub fn split_paths<'a>(unparsed: &'a OsStr) -> SplitPaths<'a> {
+pub fn split_paths(unparsed: &OsStr) -> SplitPaths {
     fn bytes_to_path(b: &[u8]) -> PathBuf {
         PathBuf::from(<OsStr as OsStrExt>::from_bytes(b))
     }
@@ -142,7 +142,7 @@ pub fn split_paths<'a>(unparsed: &'a OsStr) -> SplitPaths<'a> {
     let unparsed = unparsed.as_bytes();
     SplitPaths {
         iter: unparsed.split(is_colon as fn(&u8) -> bool)
-                      .map(bytes_to_path as fn(&'a [u8]) -> PathBuf)
+                      .map(bytes_to_path as fn(&[u8]) -> PathBuf)
     }
 }
 
diff --git a/src/libstd/sys/unix/stdio.rs b/src/libstd/sys/unix/stdio.rs
index c87800a1498..ccbb14677c7 100644
--- a/src/libstd/sys/unix/stdio.rs
+++ b/src/libstd/sys/unix/stdio.rs
@@ -23,7 +23,7 @@ impl Stdin {
         let fd = FileDesc::new(libc::STDIN_FILENO);
         let ret = fd.read(data);
         fd.into_raw();
-        return ret;
+        ret
     }
 }
 
@@ -34,7 +34,7 @@ impl Stdout {
         let fd = FileDesc::new(libc::STDOUT_FILENO);
         let ret = fd.write(data);
         fd.into_raw();
-        return ret;
+        ret
     }
 }
 
@@ -45,7 +45,7 @@ impl Stderr {
         let fd = FileDesc::new(libc::STDERR_FILENO);
         let ret = fd.write(data);
         fd.into_raw();
-        return ret;
+        ret
     }
 }
 
diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
index 5a551e2b3f3..268ec7fe356 100644
--- a/src/libstd/sys/unix/thread.rs
+++ b/src/libstd/sys/unix/thread.rs
@@ -310,7 +310,7 @@ pub mod guard {
             ret = Some(stackaddr as usize + guardsize as usize);
         }
         assert_eq!(pthread_attr_destroy(&mut attr), 0);
-        return ret
+        ret
     }
 
     #[cfg(any(target_os = "linux", target_os = "android"))]
diff --git a/src/libstd/sys/unix/thread_local.rs b/src/libstd/sys/unix/thread_local.rs
index c375788fdc1..e697417675d 100644
--- a/src/libstd/sys/unix/thread_local.rs
+++ b/src/libstd/sys/unix/thread_local.rs
@@ -18,7 +18,7 @@ pub type Key = pthread_key_t;
 pub unsafe fn create(dtor: Option<unsafe extern fn(*mut u8)>) -> Key {
     let mut key = 0;
     assert_eq!(pthread_key_create(&mut key, dtor), 0);
-    return key;
+    key
 }
 
 #[inline]