refactor(lib): remove build script features since minimum version is higher

This commit is contained in:
Sean McArthur
2018-09-28 12:02:21 -07:00
parent b0c132023c
commit 09156a70a6
6 changed files with 6 additions and 47 deletions

View File

@@ -49,9 +49,6 @@ serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
[build-dependencies]
rustc_version = "0.2.3"
[features] [features]
default = [ default = [
"__internal_flaky_tests", "__internal_flaky_tests",

View File

@@ -1,13 +0,0 @@
extern crate rustc_version;
use rustc_version::{version, Version};
fn main() {
// Check for a minimum version to see if new rust features can be used
let version = version().unwrap();
if version >= Version::parse("1.26.0").unwrap() {
println!("cargo:rustc-cfg=__hyper_impl_trait_available");
}
if version >= Version::parse("1.23.0").unwrap() {
println!("cargo:rustc-cfg=__hyper_inherent_ascii");
}
}

View File

@@ -240,11 +240,11 @@ where
} }
} }
pub(crate) fn send_request_retryable(&mut self, req: Request<B>) -> impl_trait!(ty: Future<Item = Response<Body>, Error = (::Error, Option<Request<B>>)> + Send) pub(crate) fn send_request_retryable(&mut self, req: Request<B>) -> impl Future<Item = Response<Body>, Error = (::Error, Option<Request<B>>)>
where where
B: Send, B: Send,
{ {
impl_trait!(e: match self.dispatch.try_send(req) { match self.dispatch.try_send(req) {
Ok(rx) => { Ok(rx) => {
Either::A(rx.then(move |res| { Either::A(rx.then(move |res| {
match res { match res {
@@ -260,7 +260,7 @@ where
let err = ::Error::new_canceled(Some("connection was not ready")); let err = ::Error::new_canceled(Some("connection was not ready"));
Either::B(future::err((err, Some(req)))) Either::B(future::err((err, Some(req))))
} }
}) }
} }
} }
@@ -300,11 +300,11 @@ impl<B> Http2SendRequest<B>
where where
B: Payload + 'static, B: Payload + 'static,
{ {
pub(super) fn send_request_retryable(&mut self, req: Request<B>) -> impl_trait!(ty: Future<Item=Response<Body>, Error=(::Error, Option<Request<B>>)> + Send) pub(super) fn send_request_retryable(&mut self, req: Request<B>) -> impl Future<Item=Response<Body>, Error=(::Error, Option<Request<B>>)>
where where
B: Send, B: Send,
{ {
impl_trait!(e: match self.dispatch.try_send(req) { match self.dispatch.try_send(req) {
Ok(rx) => { Ok(rx) => {
Either::A(rx.then(move |res| { Either::A(rx.then(move |res| {
match res { match res {
@@ -320,7 +320,7 @@ where
let err = ::Error::new_canceled(Some("connection was not ready")); let err = ::Error::new_canceled(Some("connection was not ready"));
Either::B(future::err((err, Some(req)))) Either::B(future::err((err, Some(req))))
} }
}) }
} }
} }

View File

@@ -1,21 +0,0 @@
#[macro_export]
#[cfg(__hyper_impl_trait_available)]
macro_rules! impl_trait {
(ty: $($t:tt)+) => {
impl $($t)+
};
(e: $e:expr) => {
$e
}
}
#[macro_export]
#[cfg(not(__hyper_impl_trait_available))]
macro_rules! impl_trait {
(ty: $($t:tt)+) => {
Box<$($t)+>
};
(e: $e:expr) => {
Box::new($e)
}
}

View File

@@ -3,8 +3,6 @@ pub(crate) mod drain;
mod exec; mod exec;
pub(crate) mod io; pub(crate) mod io;
mod lazy; mod lazy;
#[macro_use]
mod macros;
mod never; mod never;
pub(crate) use self::buf::StaticBuf; pub(crate) use self::buf::StaticBuf;

View File

@@ -2,8 +2,6 @@ use bytes::BytesMut;
use http::HeaderMap; use http::HeaderMap;
use http::header::{CONTENT_LENGTH, TRANSFER_ENCODING}; use http::header::{CONTENT_LENGTH, TRANSFER_ENCODING};
use http::header::{HeaderValue, OccupiedEntry, ValueIter}; use http::header::{HeaderValue, OccupiedEntry, ValueIter};
#[cfg(not(__hyper_inherent_ascii))]
use std::ascii::AsciiExt;
pub fn connection_keep_alive(value: &HeaderValue) -> bool { pub fn connection_keep_alive(value: &HeaderValue) -> bool {
connection_has(value, "keep-alive") connection_has(value, "keep-alive")