From f4a66b38cb9e35bfec0bbc3c97e5298fc8ad8409 Mon Sep 17 00:00:00 2001 From: Renato Zannon Date: Thu, 19 Feb 2015 18:40:04 -0200 Subject: [PATCH] fix(rustup): update lifetime bounds Send no longer implies 'static; update needed lifetime bounds. --- src/header/common/authorization.rs | 4 ++-- src/net.rs | 2 +- src/server/acceptor.rs | 13 ++++++------- src/server/mod.rs | 6 +++--- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/header/common/authorization.rs b/src/header/common/authorization.rs index 9999089e4f..cd9844f245 100644 --- a/src/header/common/authorization.rs +++ b/src/header/common/authorization.rs @@ -22,7 +22,7 @@ impl DerefMut for Authorization { } } -impl Header for Authorization { +impl Header for Authorization { fn header_name() -> &'static str { "Authorization" } @@ -43,7 +43,7 @@ impl Header for Authorization { } } -impl HeaderFormat for Authorization { +impl HeaderFormat for Authorization { fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match Scheme::scheme(None::) { Some(scheme) => try!(write!(fmt, "{} ", scheme)), diff --git a/src/net.rs b/src/net.rs index b11abfa327..f7ff2554f6 100644 --- a/src/net.rs +++ b/src/net.rs @@ -58,7 +58,7 @@ pub trait NetworkAcceptor: Clone + Send { } /// An iterator wrapper over a NetworkAcceptor. -pub struct NetworkConnections<'a, N: NetworkAcceptor>(&'a mut N); +pub struct NetworkConnections<'a, N: NetworkAcceptor + 'a>(&'a mut N); impl<'a, N: NetworkAcceptor> Iterator for NetworkConnections<'a, N> { type Item = IoResult; diff --git a/src/server/acceptor.rs b/src/server/acceptor.rs index 3c0e0b5e15..a4cc5b4a99 100644 --- a/src/server/acceptor.rs +++ b/src/server/acceptor.rs @@ -7,7 +7,7 @@ pub struct AcceptorPool { acceptor: A } -impl AcceptorPool { +impl AcceptorPool { /// Create a thread pool to manage the acceptor. pub fn new(acceptor: A) -> AcceptorPool { AcceptorPool { acceptor: acceptor } @@ -18,9 +18,8 @@ impl AcceptorPool { /// ## Panics /// /// Panics if threads == 0. - pub fn accept(self, - work: F, - threads: usize) -> JoinGuard<'static, ()> { + pub fn accept(self, work: F, threads: usize) -> JoinGuard<'static, ()> + where F: Fn(A::Stream) + Send + Sync + 'static { assert!(threads != 0, "Can't accept on 0 threads."); // Replace with &F when Send changes land. @@ -40,8 +39,8 @@ impl AcceptorPool { } fn spawn_with(supervisor: mpsc::Sender<()>, work: Arc, mut acceptor: A) -where A: NetworkAcceptor, - F: Fn(::Stream) + Send + Sync { +where A: NetworkAcceptor + 'static, + F: Fn(::Stream) + Send + Sync + 'static { use std::old_io::EndOfFile; Thread::spawn(move || { @@ -83,7 +82,7 @@ impl Sentinel { } #[unsafe_destructor] -impl Drop for Sentinel { +impl Drop for Sentinel { fn drop(&mut self) { // If we were cancelled, get out of here. if !self.active { return; } diff --git a/src/server/mod.rs b/src/server/mod.rs index 01fa9184bd..bbb4a4c626 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -56,7 +56,7 @@ impl Server { impl< L: NetworkListener + Send, -A: NetworkAcceptor + Send, +A: NetworkAcceptor + Send + 'static, S: NetworkStream + Clone + Send> Server { /// Creates a new server that will handle `HttpStream`s. pub fn with_listener(ip: IpAddr, port: Port, listener: L) -> Server { @@ -68,7 +68,7 @@ S: NetworkStream + Clone + Send> Server { } /// Binds to a socket, and starts handling connections using a task pool. - pub fn listen_threads(mut self, handler: H, threads: usize) -> HttpResult> { + pub fn listen_threads(mut self, handler: H, threads: usize) -> HttpResult> { debug!("binding to {:?}:{:?}", self.ip, self.port); let acceptor = try!(self.listener.listen((self.ip, self.port))); let socket = try!(acceptor.socket_name()); @@ -85,7 +85,7 @@ S: NetworkStream + Clone + Send> Server { } /// Binds to a socket and starts handling connections. - pub fn listen(self, handler: H) -> HttpResult> { + pub fn listen(self, handler: H) -> HttpResult> { self.listen_threads(handler, os::num_cpus() * 5 / 4) }