Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Verify auto-traits for core types #3877

Merged
merged 1 commit into from Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions src/builder/command.rs
Expand Up @@ -5107,3 +5107,8 @@ where
_ => None,
}
}

#[test]
fn check_auto_traits() {
static_assertions::assert_impl_all!(Command: Send, Sync, Unpin);
}
11 changes: 3 additions & 8 deletions src/error/mod.rs
Expand Up @@ -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);
}
11 changes: 11 additions & 0 deletions src/parser/error.rs
Expand Up @@ -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
);
}
5 changes: 5 additions & 0 deletions src/parser/matches/arg_matches.rs
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion tests/derive_ui/next/tuple_struct.stderr
Expand Up @@ -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`