mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-07 00:00:12 +02:00
Fix items-after-test-module clippy warning on 1.75.0-beta.1 (#2318)
This commit is contained in:
+40
-40
@@ -211,46 +211,6 @@ macro_rules! __composite_rejection {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod composite_rejection_tests {
|
||||
use self::defs::*;
|
||||
use crate::Error;
|
||||
use std::error::Error as _;
|
||||
|
||||
#[allow(dead_code, unreachable_pub)]
|
||||
mod defs {
|
||||
use crate::{__composite_rejection, __define_rejection};
|
||||
|
||||
__define_rejection! {
|
||||
#[status = BAD_REQUEST]
|
||||
#[body = "error message 1"]
|
||||
pub struct Inner1;
|
||||
}
|
||||
__define_rejection! {
|
||||
#[status = BAD_REQUEST]
|
||||
#[body = "error message 2"]
|
||||
pub struct Inner2(Error);
|
||||
}
|
||||
__composite_rejection! {
|
||||
pub enum Outer { Inner1, Inner2 }
|
||||
}
|
||||
}
|
||||
|
||||
/// The implementation of `.source()` on `Outer` should defer straight to the implementation
|
||||
/// on its inner type instead of returning the inner type itself, because the `Display`
|
||||
/// implementation on `Outer` already forwards to the inner type and so it would result in two
|
||||
/// errors in the chain `Display`ing the same thing.
|
||||
#[test]
|
||||
fn source_gives_inner_source() {
|
||||
let rejection = Outer::Inner1(Inner1);
|
||||
assert!(rejection.source().is_none());
|
||||
|
||||
let msg = "hello world";
|
||||
let rejection = Outer::Inner2(Inner2(Error::new(msg)));
|
||||
assert_eq!(rejection.source().unwrap().to_string(), msg);
|
||||
}
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
macro_rules! all_the_tuples {
|
||||
($name:ident) => {
|
||||
@@ -334,3 +294,43 @@ macro_rules! __impl_deref {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod composite_rejection_tests {
|
||||
use self::defs::*;
|
||||
use crate::Error;
|
||||
use std::error::Error as _;
|
||||
|
||||
#[allow(dead_code, unreachable_pub)]
|
||||
mod defs {
|
||||
use crate::{__composite_rejection, __define_rejection};
|
||||
|
||||
__define_rejection! {
|
||||
#[status = BAD_REQUEST]
|
||||
#[body = "error message 1"]
|
||||
pub struct Inner1;
|
||||
}
|
||||
__define_rejection! {
|
||||
#[status = BAD_REQUEST]
|
||||
#[body = "error message 2"]
|
||||
pub struct Inner2(Error);
|
||||
}
|
||||
__composite_rejection! {
|
||||
pub enum Outer { Inner1, Inner2 }
|
||||
}
|
||||
}
|
||||
|
||||
/// The implementation of `.source()` on `Outer` should defer straight to the implementation
|
||||
/// on its inner type instead of returning the inner type itself, because the `Display`
|
||||
/// implementation on `Outer` already forwards to the inner type and so it would result in two
|
||||
/// errors in the chain `Display`ing the same thing.
|
||||
#[test]
|
||||
fn source_gives_inner_source() {
|
||||
let rejection = Outer::Inner1(Inner1);
|
||||
assert!(rejection.source().is_none());
|
||||
|
||||
let msg = "hello world";
|
||||
let rejection = Outer::Inner2(Inner2(Error::new(msg)));
|
||||
assert_eq!(rejection.source().unwrap().to_string(), msg);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user