From f13572a4c6399f84a8681a78ef0236b470ea811c Mon Sep 17 00:00:00 2001 From: MegaBluejay Date: Mon, 14 Aug 2023 17:46:38 +0300 Subject: [PATCH] Remove field attr --- impl/src/error.rs | 2 +- tests/error/derives_forward.rs | 30 --------------- tests/error/nightly/derives_forward.rs | 53 -------------------------- 3 files changed, 1 insertion(+), 84 deletions(-) diff --git a/impl/src/error.rs b/impl/src/error.rs index 358e527f..5b69fe57 100644 --- a/impl/src/error.rs +++ b/impl/src/error.rs @@ -167,7 +167,7 @@ fn allowed_attr_params() -> AttrParams { enum_: vec!["ignore", "forward"], struct_: vec!["ignore", "forward"], variant: vec!["ignore", "forward"], - field: vec!["ignore", "source", "backtrace", "forward"], + field: vec!["ignore", "source", "backtrace"], } } diff --git a/tests/error/derives_forward.rs b/tests/error/derives_forward.rs index 61ce18cf..d1d8a2dd 100644 --- a/tests/error/derives_forward.rs +++ b/tests/error/derives_forward.rs @@ -76,33 +76,3 @@ fn variant_attr() { assert!(err_b.source().is_some()); assert!(err_b.source().unwrap().is::()); } - -derive_display!(FieldAttr); -#[derive(Debug, Error)] -enum FieldAttr { - A { - #[error(forward, source)] - field: Inner, - }, - B { - #[error(source)] - field: Inner, - }, -} - -#[test] -fn field_attr() { - let err_a = FieldAttr::A { - field: Inner { source: SimpleErr }, - }; - - let err_b = FieldAttr::B { - field: Inner { source: SimpleErr }, - }; - - assert!(err_a.source().is_some()); - assert!(err_a.source().unwrap().is::()); - - assert!(err_b.source().is_some()); - assert!(err_b.source().unwrap().is::()); -} diff --git a/tests/error/nightly/derives_forward.rs b/tests/error/nightly/derives_forward.rs index 73c3c864..dac3c8b5 100644 --- a/tests/error/nightly/derives_forward.rs +++ b/tests/error/nightly/derives_forward.rs @@ -147,56 +147,3 @@ fn variant_attr() { assert_eq!(any::request_value::(&err_b), Some(42)); assert_bt!(==, err_b, .get_source_backtrace); } - -derive_display!(FieldAttr); -#[derive(Debug, Error)] -enum FieldAttr { - A { - #[error(forward, backtrace)] - source: Inner, - }, - B { - #[error(backtrace)] - source: Inner, - }, -} - -impl FieldAttr { - fn get_source_backtrace(&self) -> &Backtrace { - any::request_ref(match self { - Self::A { source } => &source.source, - Self::B { source } => &source.source, - }) - .unwrap() - } -} - -#[test] -fn field_attr() { - let err_a = FieldAttr::A { - source: Inner { - source: BacktraceErr { - backtrace: Backtrace::force_capture(), - }, - }, - }; - let err_b = FieldAttr::B { - source: Inner { - source: BacktraceErr { - backtrace: Backtrace::force_capture(), - }, - }, - }; - - assert!(err_a.source().is_some()); - assert!(err_a.source().unwrap().is::()); - assert!(any::request_ref::(&err_a).is_some()); - assert_eq!(any::request_value::(&err_a), Some(42)); - assert_bt!(==, err_a, .get_source_backtrace); - - assert!(err_b.source().is_some()); - assert!(err_b.source().unwrap().is::()); - assert!(any::request_ref::(&err_b).is_some()); - assert_eq!(any::request_value::(&err_b), Some(42)); - assert_bt!(==, err_b, .get_source_backtrace); -}