Skip to content

Commit

Permalink
Add explicit source case to forward tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaBluejay committed Aug 15, 2023
1 parent 7688e66 commit 2c43dd1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 8 additions & 3 deletions tests/error/derives_forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ derive_display!(EnumAttr);
#[derive(Debug, Error)]
#[error(forward)]
enum EnumAttr {
A { source: Inner },
B { source: Inner },
A {
source: Inner,
},
B {
#[error(source)]
explicit_source: Inner,
},
}

#[test]
Expand All @@ -38,7 +43,7 @@ fn enum_attr() {
};

let err_b = EnumAttr::B {
source: Inner { source: SimpleErr },
explicit_source: Inner { source: SimpleErr },
};

assert!(err_a.source().is_some());
Expand Down
8 changes: 4 additions & 4 deletions tests/error/nightly/derives_forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ enum EnumAttr {
source: Inner,
},
B {
#[error(backtrace)]
source: Inner,
#[error(source, backtrace)]
explicit_source: Inner,
},
}

impl EnumAttr {
fn get_source_backtrace(&self) -> &Backtrace {
request_ref(match self {
Self::A { source } => &source.source,
Self::B { source } => &source.source,
Self::B { explicit_source } => &explicit_source.source,
})
.unwrap()
}
Expand All @@ -74,7 +74,7 @@ fn enum_attr() {
},
};
let err_b = EnumAttr::B {
source: Inner {
explicit_source: Inner {
source: BacktraceErr {
backtrace: Backtrace::force_capture(),
},
Expand Down

0 comments on commit 2c43dd1

Please sign in to comment.