chore(lib): add dyn keyword to trait objects (#1820)

Requires Rust 1.27.
This commit is contained in:
Sean McArthur
2019-06-03 13:08:13 -07:00
committed by GitHub
parent e0f5a9c6c5
commit 01c03db7ea
28 changed files with 107 additions and 94 deletions

View File

@@ -1565,7 +1565,7 @@ mod dispatch_impl {
impl Connect for DebugConnector {
type Transport = DebugStream;
type Error = io::Error;
type Future = Box<Future<Item = (DebugStream, Connected), Error = io::Error> + Send>;
type Future = Box<dyn Future<Item = (DebugStream, Connected), Error = io::Error> + Send>;
fn connect(&self, dst: Destination) -> Self::Future {
self.connects.fetch_add(1, Ordering::SeqCst);
@@ -2178,7 +2178,7 @@ mod conn {
}
trait FutureHyperExt: Future {
fn expect<E>(self, msg: &'static str) -> Box<Future<Item=Self::Item, Error=E>>;
fn expect<E>(self, msg: &'static str) -> Box<dyn Future<Item=Self::Item, Error=E>>;
}
impl<F> FutureHyperExt for F
@@ -2186,7 +2186,7 @@ where
F: Future + 'static,
F::Error: ::std::fmt::Debug,
{
fn expect<E>(self, msg: &'static str) -> Box<Future<Item=Self::Item, Error=E>> {
fn expect<E>(self, msg: &'static str) -> Box<dyn Future<Item=Self::Item, Error=E>> {
Box::new(self.map_err(move |e| panic!("expect: {}; error={:?}", msg, e)))
}
}

View File

@@ -1779,7 +1779,7 @@ impl Serve {
}
}
type BoxError = Box<::std::error::Error + Send + Sync>;
type BoxError = Box<dyn std::error::Error + Send + Sync>;
struct ReplyBuilder<'a> {
tx: &'a spmc::Sender<Reply>,
@@ -1853,7 +1853,7 @@ enum Msg {
}
impl TestService {
fn call(&self, req: Request<Body>) -> Box<Future<Item=Response<Body>, Error=BoxError> + Send> {
fn call(&self, req: Request<Body>) -> Box<dyn Future<Item=Response<Body>, Error=BoxError> + Send> {
let tx1 = self.tx.clone();
let tx2 = self.tx.clone();
let replies = self.reply.clone();

View File

@@ -212,7 +212,7 @@ macro_rules! __internal_headers_eq {
$pat => (),
other => panic!("headers[{}] was not {}: {:?}", stringify!($name), stringify!($pat), other),
}
}) as ::std::sync::Arc<Fn(&::hyper::HeaderMap) + Send + Sync>
}) as ::std::sync::Arc<dyn Fn(&::hyper::HeaderMap) + Send + Sync>
};
(@val $name: expr, NONE) => {
__internal_headers_eq!(@pat $name, None);
@@ -228,7 +228,7 @@ macro_rules! __internal_headers_eq {
} else {
assert_eq!(__hdrs.get($name), None, stringify!($name));
}
}) as ::std::sync::Arc<Fn(&::hyper::HeaderMap) + Send + Sync>
}) as ::std::sync::Arc<dyn Fn(&::hyper::HeaderMap) + Send + Sync>
});
($headers:ident, { $($name:expr => $val:tt,)* }) => {
$(
@@ -289,7 +289,7 @@ pub struct __SRes {
pub headers: HeaderMap,
}
pub type __HeadersEq = Vec<Arc<Fn(&HeaderMap) + Send + Sync>>;
pub type __HeadersEq = Vec<Arc<dyn Fn(&HeaderMap) + Send + Sync>>;
pub struct __TestConfig {
pub client_version: usize,
@@ -426,7 +426,7 @@ pub fn __run_test(cfg: __TestConfig) {
});
let client_futures: Box<Future<Item=(), Error=()> + Send> = if cfg.parallel {
let client_futures: Box<dyn Future<Item=(), Error=()> + Send> = if cfg.parallel {
let mut client_futures = vec![];
for (creq, cres) in cfg.client_msgs {
client_futures.push(make_request(&client, creq, cres));
@@ -434,7 +434,7 @@ pub fn __run_test(cfg: __TestConfig) {
drop(client);
Box::new(future::join_all(client_futures).map(|_| ()))
} else {
let mut client_futures: Box<Future<Item=Client<HttpConnector>, Error=()> + Send> =
let mut client_futures: Box<dyn Future<Item=Client<HttpConnector>, Error=()> + Send> =
Box::new(future::ok(client));
for (creq, cres) in cfg.client_msgs {
let mk_request = make_request.clone();