diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-11-15 20:18:36 +0000 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-11-15 20:18:36 +0000 |
| commit | c0bd0c9efd429b35354484e24fe272fa1fbfe901 (patch) | |
| tree | 395d4918e6a2b882fc05b285001b6cb72ab10af2 /subprojects/thiserror/tests/test_option.rs | |
| parent | 0436fbc77039fa3d754f2db5cfefdd437fea51d1 (diff) | |
| parent | 6eba9cd92c295c5389944f6adda1f1e83b2cb008 (diff) | |
| download | gentoo-utils-c0bd0c9efd429b35354484e24fe272fa1fbfe901.tar.gz | |
Merge commit '6eba9cd92c295c5389944f6adda1f1e83b2cb008' as 'subprojects/thiserror'
Diffstat (limited to 'subprojects/thiserror/tests/test_option.rs')
| -rw-r--r-- | subprojects/thiserror/tests/test_option.rs | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/subprojects/thiserror/tests/test_option.rs b/subprojects/thiserror/tests/test_option.rs new file mode 100644 index 0000000..21cd5e1 --- /dev/null +++ b/subprojects/thiserror/tests/test_option.rs @@ -0,0 +1,109 @@ +#![cfg(feature = "std")] +#![cfg_attr(thiserror_nightly_testing, feature(error_generic_member_access))] + +#[cfg(thiserror_nightly_testing)] +pub mod structs { + use std::backtrace::Backtrace; + use thiserror::Error; + + #[derive(Error, Debug)] + #[error("...")] + pub struct OptSourceNoBacktrace { + #[source] + pub source: Option<anyhow::Error>, + } + + #[derive(Error, Debug)] + #[error("...")] + pub struct OptSourceAlwaysBacktrace { + #[source] + pub source: Option<anyhow::Error>, + pub backtrace: Backtrace, + } + + #[derive(Error, Debug)] + #[error("...")] + pub struct NoSourceOptBacktrace { + #[backtrace] + pub backtrace: Option<Backtrace>, + } + + #[derive(Error, Debug)] + #[error("...")] + pub struct AlwaysSourceOptBacktrace { + pub source: anyhow::Error, + #[backtrace] + pub backtrace: Option<Backtrace>, + } + + #[derive(Error, Debug)] + #[error("...")] + pub struct OptSourceOptBacktrace { + #[source] + pub source: Option<anyhow::Error>, + #[backtrace] + pub backtrace: Option<Backtrace>, + } +} + +#[cfg(thiserror_nightly_testing)] +pub mod enums { + use std::backtrace::Backtrace; + use thiserror::Error; + + #[derive(Error, Debug)] + pub enum OptSourceNoBacktrace { + #[error("...")] + Test { + #[source] + source: Option<anyhow::Error>, + }, + } + + #[derive(Error, Debug)] + pub enum OptSourceAlwaysBacktrace { + #[error("...")] + Test { + #[source] + source: Option<anyhow::Error>, + backtrace: Backtrace, + }, + } + + #[derive(Error, Debug)] + pub enum NoSourceOptBacktrace { + #[error("...")] + Test { + #[backtrace] + backtrace: Option<Backtrace>, + }, + } + + #[derive(Error, Debug)] + pub enum AlwaysSourceOptBacktrace { + #[error("...")] + Test { + source: anyhow::Error, + #[backtrace] + backtrace: Option<Backtrace>, + }, + } + + #[derive(Error, Debug)] + pub enum OptSourceOptBacktrace { + #[error("...")] + Test { + #[source] + source: Option<anyhow::Error>, + #[backtrace] + backtrace: Option<Backtrace>, + }, + } +} + +#[test] +#[cfg_attr( + not(thiserror_nightly_testing), + ignore = "requires `--cfg=thiserror_nightly_testing`" +)] +fn test_option() {} |
