diff --git a/Cargo.toml b/Cargo.toml index 40515fb1b..9aab5a1f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,9 +32,6 @@ tls = ["native-tls", "tokio-tls"] # openssl alpn = ["openssl", "openssl/v102", "openssl/v110", "tokio-openssl"] -# nightly -nightly = [] - [dependencies] log = "0.3" failure = "0.1" @@ -91,6 +88,7 @@ skeptic = "0.13" [build-dependencies] skeptic = "0.13" +version_check = "0.1" [profile.release] lto = true diff --git a/build.rs b/build.rs index b828ebe49..3afd10295 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,6 @@ extern crate skeptic; +extern crate version_check; + use std::{env, fs}; @@ -11,8 +13,19 @@ fn main() { let f = env::var("OUT_DIR").unwrap() + "/skeptic-tests.rs"; let _ = fs::File::create(f); } + + match version_check::is_nightly() { + Some(true) => println!("cargo:rustc-cfg=actix_nightly"), + Some(false) => (), + None => (), + }; } #[cfg(not(unix))] fn main() { + match version_check::is_nightly() { + Some(true) => println!("cargo:rustc-cfg=actix_nightly"), + Some(false) => (), + None => (), + }; } diff --git a/src/error.rs b/src/error.rs index 8ad17daa5..4fca84181 100644 --- a/src/error.rs +++ b/src/error.rs @@ -4,7 +4,7 @@ use std::str::Utf8Error; use std::string::FromUtf8Error; use std::io::Error as IoError; -#[cfg(feature="nightly")] +#[cfg(actix_nightly)] use std::error::Error as StdError; use cookie; @@ -76,11 +76,11 @@ impl From for Error { } /// Default error is `InternalServerError` -#[cfg(feature="nightly")] +#[cfg(actix_nightly)] default impl ErrorResponse for T { - fn error_response(&self) -> HttpResponse { - HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR, Body::Empty) - } + fn error_response(&self) -> HttpResponse { + HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR, Body::Empty) + } } /// `InternalServerError` for `JsonError` @@ -343,6 +343,13 @@ mod tests { use cookie::ParseError as CookieParseError; use super::*; + #[test] + #[cfg(actix_nightly)] + fn test_nightly() { + let resp: HttpResponse = IoError::new(io::ErrorKind::Other, "test").error_response(); + assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR); + } + #[test] fn test_into_response() { let resp: HttpResponse = ParseError::Incomplete.error_response(); diff --git a/src/lib.rs b/src/lib.rs index cbb30a950..a063bc5aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ //! Web framework for [Actix](https://github.com/actix/actix) -#![cfg_attr(feature="nightly", feature( +#![cfg_attr(actix_nightly, feature( specialization, // for impl ErrorResponse for std::error::Error ))]