Skip to content

Commit 9962393

Browse files
authored
Merge pull request #3877 from epage/assert
test: Verify auto-traits for core types
2 parents a05f4d3 + 3c4e684 commit 9962393

File tree

6 files changed

+26
-9
lines changed

6 files changed

+26
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ trycmd = { version = "0.13", default-features = false, features = ["color-auto",
114114
humantime = "2"
115115
snapbox = "0.2.9"
116116
shlex = "1.1.0"
117+
static_assertions = "1.1.0"
117118

118119
[[example]]
119120
name = "demo"

src/builder/command.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5107,3 +5107,8 @@ where
51075107
_ => None,
51085108
}
51095109
}
5110+
5111+
#[test]
5112+
fn check_auto_traits() {
5113+
static_assertions::assert_impl_all!(Command: Send, Sync, Unpin);
5114+
}

src/error/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,12 +1147,7 @@ impl Display for Backtrace {
11471147
}
11481148
}
11491149

1150-
#[cfg(test)]
1151-
mod tests {
1152-
/// Check `clap::Error` impls Send and Sync.
1153-
mod clap_error_impl_send_sync {
1154-
use crate::Error;
1155-
trait Foo: std::error::Error + Send + Sync + 'static {}
1156-
impl Foo for Error {}
1157-
}
1150+
#[test]
1151+
fn check_auto_traits() {
1152+
static_assertions::assert_impl_all!(Error: Send, Sync, Unpin);
11581153
}

src/parser/error.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,14 @@ impl std::fmt::Display for MatchesError {
5454
}
5555
}
5656
}
57+
58+
#[test]
59+
fn check_auto_traits() {
60+
static_assertions::assert_impl_all!(
61+
MatchesError: Send,
62+
Sync,
63+
std::panic::RefUnwindSafe,
64+
std::panic::UnwindSafe,
65+
Unpin
66+
);
67+
}

src/parser/matches/arg_matches.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,6 +1741,11 @@ fn unwrap_os_string_arg<'v>(id: &Id, value: &'v AnyValue) -> &'v OsStr {
17411741
mod tests {
17421742
use super::*;
17431743

1744+
#[test]
1745+
fn check_auto_traits() {
1746+
static_assertions::assert_impl_all!(ArgMatches: Send, Sync, Unpin);
1747+
}
1748+
17441749
#[test]
17451750
fn test_default_values() {
17461751
#![allow(deprecated)]

tests/derive_ui/next/tuple_struct.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ error[E0599]: no function or associated item named `parse` found for struct `Opt
1717
|
1818
= help: items from traits can only be used if the trait is implemented and in scope
1919
= note: the following traits define an item `parse`, perhaps you need to implement one of them:
20-
candidate #1: `StructOpt`
20+
candidate #1: `Parser`
2121
candidate #2: `TypedValueParser`

0 commit comments

Comments
 (0)