diff --git a/Cargo.toml b/Cargo.toml index 77b9a84ba97..30ece7b8f5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -114,6 +114,7 @@ trycmd = { version = "0.13", default-features = false, features = ["color-auto", humantime = "2" snapbox = "0.2.9" shlex = "1.1.0" +static_assertions = "1.1.0" [[example]] name = "demo" diff --git a/src/builder/command.rs b/src/builder/command.rs index 1fcb64ecc8b..bbd14dc6caf 100644 --- a/src/builder/command.rs +++ b/src/builder/command.rs @@ -5107,3 +5107,8 @@ where _ => None, } } + +#[test] +fn check_auto_traits() { + static_assertions::assert_impl_all!(Command: Send, Sync, Unpin); +} diff --git a/src/error/mod.rs b/src/error/mod.rs index df9a84c56f9..fbd2b30a886 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -1147,12 +1147,7 @@ impl Display for Backtrace { } } -#[cfg(test)] -mod tests { - /// Check `clap::Error` impls Send and Sync. - mod clap_error_impl_send_sync { - use crate::Error; - trait Foo: std::error::Error + Send + Sync + 'static {} - impl Foo for Error {} - } +#[test] +fn check_auto_traits() { + static_assertions::assert_impl_all!(Error: Send, Sync, Unpin); } diff --git a/src/parser/error.rs b/src/parser/error.rs index bdafa9ae50a..caeba4b8fee 100644 --- a/src/parser/error.rs +++ b/src/parser/error.rs @@ -54,3 +54,14 @@ impl std::fmt::Display for MatchesError { } } } + +#[test] +fn check_auto_traits() { + static_assertions::assert_impl_all!( + MatchesError: Send, + Sync, + std::panic::RefUnwindSafe, + std::panic::UnwindSafe, + Unpin + ); +} diff --git a/src/parser/matches/arg_matches.rs b/src/parser/matches/arg_matches.rs index 03df49ab30a..d0df68441ff 100644 --- a/src/parser/matches/arg_matches.rs +++ b/src/parser/matches/arg_matches.rs @@ -1741,6 +1741,11 @@ fn unwrap_os_string_arg<'v>(id: &Id, value: &'v AnyValue) -> &'v OsStr { mod tests { use super::*; + #[test] + fn check_auto_traits() { + static_assertions::assert_impl_all!(ArgMatches: Send, Sync, Unpin); + } + #[test] fn test_default_values() { #![allow(deprecated)] diff --git a/tests/derive_ui/next/tuple_struct.stderr b/tests/derive_ui/next/tuple_struct.stderr index c68f42ea960..1f5f9086520 100644 --- a/tests/derive_ui/next/tuple_struct.stderr +++ b/tests/derive_ui/next/tuple_struct.stderr @@ -17,5 +17,5 @@ error[E0599]: no function or associated item named `parse` found for struct `Opt | = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `parse`, perhaps you need to implement one of them: - candidate #1: `StructOpt` + candidate #1: `Parser` candidate #2: `TypedValueParser`