mirror of
https://github.com/fafhrd91/actix-web
synced 2025-09-02 09:36:39 +02:00
Don't leak internal macros (#2290)
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __downcast_get_type_id {
|
||||
macro_rules! downcast_get_type_id {
|
||||
() => {
|
||||
/// A helper method to get the type ID of the type
|
||||
/// this trait is implemented on.
|
||||
@@ -30,10 +28,8 @@ macro_rules! __downcast_get_type_id {
|
||||
};
|
||||
}
|
||||
|
||||
//Generate implementation for dyn $name
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! __downcast_dyn {
|
||||
// Generate implementation for dyn $name
|
||||
macro_rules! downcast_dyn {
|
||||
($name:ident) => {
|
||||
/// A struct with a private constructor, for use with
|
||||
/// `__private_get_type_id__`. Its single field is private,
|
||||
@@ -80,15 +76,17 @@ macro_rules! __downcast_dyn {
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use {downcast_dyn, downcast_get_type_id};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#![allow(clippy::upper_case_acronyms)]
|
||||
|
||||
trait MB {
|
||||
__downcast_get_type_id!();
|
||||
downcast_get_type_id!();
|
||||
}
|
||||
|
||||
__downcast_dyn!(MB);
|
||||
downcast_dyn!(MB);
|
||||
|
||||
impl MB for String {}
|
||||
impl MB for () {}
|
||||
|
@@ -18,6 +18,7 @@ mod response_error;
|
||||
pub use self::error::Error;
|
||||
pub use self::internal::*;
|
||||
pub use self::response_error::ResponseError;
|
||||
pub(crate) use macros::{downcast_dyn, downcast_get_type_id};
|
||||
|
||||
/// A convenience [`Result`](std::result::Result) for Actix Web operations.
|
||||
///
|
||||
|
@@ -9,7 +9,7 @@ use std::{
|
||||
use actix_http::{body::AnyBody, header, Response, StatusCode};
|
||||
use bytes::BytesMut;
|
||||
|
||||
use crate::{__downcast_dyn, __downcast_get_type_id};
|
||||
use crate::error::{downcast_dyn, downcast_get_type_id};
|
||||
use crate::{helpers, HttpResponse};
|
||||
|
||||
/// Errors that can generate responses.
|
||||
@@ -41,10 +41,10 @@ pub trait ResponseError: fmt::Debug + fmt::Display {
|
||||
res.set_body(AnyBody::from(buf))
|
||||
}
|
||||
|
||||
__downcast_get_type_id!();
|
||||
downcast_get_type_id!();
|
||||
}
|
||||
|
||||
__downcast_dyn!(ResponseError);
|
||||
downcast_dyn!(ResponseError);
|
||||
|
||||
impl ResponseError for Box<dyn StdError + 'static> {}
|
||||
|
||||
|
Reference in New Issue
Block a user