1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-27 17:52:56 +01:00

better nightly detection

This commit is contained in:
Nikolay Kim 2017-11-24 10:28:43 -08:00
parent f33c489154
commit 59b8214685
4 changed files with 27 additions and 9 deletions

View File

@ -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

View File

@ -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 => (),
};
}

View File

@ -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,7 +76,7 @@ impl<T: ErrorResponse> From<T> for Error {
}
/// Default error is `InternalServerError`
#[cfg(feature="nightly")]
#[cfg(actix_nightly)]
default impl<T: StdError + Sync + Send + 'static> ErrorResponse for T {
fn error_response(&self) -> HttpResponse {
HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR, Body::Empty)
@ -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();

View File

@ -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
))]