mirror of
https://github.com/actix/actix-web.git
synced 2024-11-13 20:31:04 +00:00
better nightly detection
This commit is contained in:
parent
f33c489154
commit
59b8214685
4 changed files with 27 additions and 9 deletions
|
@ -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
|
||||
|
|
13
build.rs
13
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 => (),
|
||||
};
|
||||
}
|
||||
|
|
17
src/error.rs
17
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<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)
|
||||
}
|
||||
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();
|
||||
|
|
|
@ -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
|
||||
))]
|
||||
|
||||
|
|
Loading…
Reference in a new issue