From 7b8f7ae4f3f5b73ecd9d50c6dad568a8398f813c Mon Sep 17 00:00:00 2001 From: SabrinaJewson Date: Mon, 30 May 2022 18:39:04 +0100 Subject: [PATCH] Implement `ResponseError` for `Infallible` --- actix-web/src/error/error.rs | 6 ------ actix-web/src/error/response_error.rs | 10 ++++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/actix-web/src/error/error.rs b/actix-web/src/error/error.rs index 3d3978dde..3a5a128f6 100644 --- a/actix-web/src/error/error.rs +++ b/actix-web/src/error/error.rs @@ -51,12 +51,6 @@ impl StdError for Error { } } -impl From for Error { - fn from(val: std::convert::Infallible) -> Self { - match val {} - } -} - /// `Error` for any error that implements `ResponseError` impl From for Error { fn from(err: T) -> Error { diff --git a/actix-web/src/error/response_error.rs b/actix-web/src/error/response_error.rs index 0b8a82ce8..7d2c06154 100644 --- a/actix-web/src/error/response_error.rs +++ b/actix-web/src/error/response_error.rs @@ -1,6 +1,7 @@ //! `ResponseError` trait and foreign impls. use std::{ + convert::Infallible, error::Error as StdError, fmt, io::{self, Write as _}, @@ -54,6 +55,15 @@ downcast_dyn!(ResponseError); impl ResponseError for Box {} +impl ResponseError for Infallible { + fn status_code(&self) -> StatusCode { + match *self {} + } + fn error_response(&self) -> HttpResponse { + match *self {} + } +} + #[cfg(feature = "openssl")] impl ResponseError for actix_tls::accept::openssl::reexports::Error {}