thiserror/tests/test_option.rs
David Tolnay dd9206cfd0
Remove clippy deny attributes from test suite
These were superseded by the clippy invocation made in our CI workflow:

    run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic
2022-04-24 15:22:58 -07:00

105 lines
2.3 KiB
Rust

#![cfg_attr(thiserror_nightly_testing, feature(backtrace))]
#[cfg(thiserror_nightly_testing)]
pub mod structs {
use std::backtrace::Backtrace;
use thiserror::Error;
#[derive(Error, Debug)]
#[error("...")]
pub struct OptSourceNoBacktrace {
#[source]
source: Option<anyhow::Error>,
}
#[derive(Error, Debug)]
#[error("...")]
pub struct OptSourceAlwaysBacktrace {
#[source]
source: Option<anyhow::Error>,
backtrace: Backtrace,
}
#[derive(Error, Debug)]
#[error("...")]
pub struct NoSourceOptBacktrace {
#[backtrace]
backtrace: Option<Backtrace>,
}
#[derive(Error, Debug)]
#[error("...")]
pub struct AlwaysSourceOptBacktrace {
source: anyhow::Error,
#[backtrace]
backtrace: Option<Backtrace>,
}
#[derive(Error, Debug)]
#[error("...")]
pub struct OptSourceOptBacktrace {
#[source]
source: Option<anyhow::Error>,
#[backtrace]
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)]
fn test_option() {}