Skip to content

Commit

Permalink
- fix known_enum macro to allow attributes such as features, fixes se…
Browse files Browse the repository at this point in the history
…anmonstar#352

- add step test for --no-default-features
- remove no longer used travis badge
  • Loading branch information
jxs committed Dec 28, 2019
1 parent 077058d commit 4e3db91
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -45,6 +45,9 @@ jobs:
benches: true
- build: tls
features: "--features tls"
- build: no-default-features
features: "--no-default-features"


steps:
- name: Checkout
Expand Down
1 change: 0 additions & 1 deletion README.md
@@ -1,7 +1,6 @@
# warp

[![GHA Build Status](https://github.com/seanmonstar/warp/workflows/CI/badge.svg)](https://github.com/seanmonstar/warp/actions?query=workflow%3ACI)
[![Travis Build Status](https://travis-ci.org/seanmonstar/warp.svg?branch=master)](https://travis-ci.org/seanmonstar/warp)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
[![crates.io](https://img.shields.io/crates/v/warp.svg)](https://crates.io/crates/warp)
[![Released API docs](https://docs.rs/warp/badge.svg)](https://docs.rs/warp)
Expand Down
13 changes: 10 additions & 3 deletions src/reject.rs
Expand Up @@ -190,9 +190,10 @@ enum Rejections {
}

macro_rules! enum_known {
($($var:ident($ty:path),)+) => (
($($(#[$attr:meta])* $var:ident($ty:path),)+) => (
pub(crate) enum Known {
$(
$(#[$attr])*
$var($ty),
)+
}
Expand All @@ -201,6 +202,7 @@ macro_rules! enum_known {
fn inner_as_any(&self) -> &dyn Any {
match *self {
$(
$(#[$attr])*
Known::$var(ref t) => t,
)+
}
Expand All @@ -211,6 +213,7 @@ macro_rules! enum_known {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
$(
$(#[$attr])*
Known::$var(ref t) => t.fmt(f),
)+
}
Expand All @@ -221,6 +224,7 @@ macro_rules! enum_known {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
$(
$(#[$attr])*
Known::$var(ref t) => t.fmt(f),
)+
}
Expand All @@ -229,6 +233,7 @@ macro_rules! enum_known {

$(
#[doc(hidden)]
$(#[$attr])*
impl From<$ty> for Known {
fn from(ty: $ty) -> Known {
Known::$var(ty)
Expand All @@ -250,6 +255,7 @@ enum_known! {
BodyReadError(crate::body::BodyReadError),
BodyDeserializeError(crate::body::BodyDeserializeError),
CorsForbidden(crate::cors::CorsForbidden),
#[cfg(feature = "websocket")]
MissingConnectionUpgrade(crate::ws::MissingConnectionUpgrade),
MissingExtension(crate::ext::MissingExtension),
ReplyHttpError(crate::reply::ReplyHttpError),
Expand Down Expand Up @@ -378,8 +384,9 @@ impl Rejections {
| Known::MissingCookie(_)
| Known::InvalidQuery(_)
| Known::BodyReadError(_)
| Known::BodyDeserializeError(_)
| Known::MissingConnectionUpgrade(_) => StatusCode::BAD_REQUEST,
| Known::BodyDeserializeError(_) => StatusCode::BAD_REQUEST,
#[cfg(feature = "websocket")]
Known::MissingConnectionUpgrade(_) => StatusCode::BAD_REQUEST,
Known::LengthRequired(_) => StatusCode::LENGTH_REQUIRED,
Known::PayloadTooLarge(_) => StatusCode::PAYLOAD_TOO_LARGE,
Known::UnsupportedMediaType(_) => StatusCode::UNSUPPORTED_MEDIA_TYPE,
Expand Down
1 change: 1 addition & 0 deletions src/test.rs
Expand Up @@ -86,6 +86,7 @@ use std::future::Future;
use std::net::SocketAddr;
#[cfg(feature = "websocket")]
use std::pin::Pin;
#[cfg(feature = "websocket")]
use std::task::{self, Poll};

use bytes::Bytes;
Expand Down

0 comments on commit 4e3db91

Please sign in to comment.