Skip to content

Commit

Permalink
[proptest] silence clippy::arc_with_non_send_sync warning with prop_o…
Browse files Browse the repository at this point in the history
…neof (#363)

Often, the strategies passed into `prop_oneof!` are `BoxedStrategy`
instances, which are not Send or Sync. Rust 1.72 has a new
`arc_with_non_send_sync` clippy lint that fires in these cases.

The double-curly-braces are not strictly required, but allow the
expression to be annotated with an attribute.
  • Loading branch information
sunshowers authored Aug 27, 2023
1 parent f754b23 commit 466d59d
Showing 1 changed file with 34 additions and 18 deletions.
52 changes: 34 additions & 18 deletions proptest/src/sugar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,68 +333,81 @@ macro_rules! prop_oneof {

($_weight0:expr => $item0:expr $(,)?) => { $item0 };

// NOTE: The clippy::arc_with_non_send_sync lint is disabled here because
// the strategies passed into prop_oneof! are often not Send or Sync, such
// as BoxedStrategy.
//
// The double-curly-braces are not strictly required, but allow the expression
// to be annotated with an attribute.

($weight0:expr => $item0:expr,
$weight1:expr => $item1:expr $(,)?) => {
$weight1:expr => $item1:expr $(,)?) => {{
#[allow(clippy::arc_with_non_send_sync)]
$crate::strategy::TupleUnion::new(
(($weight0, $crate::std_facade::Arc::new($item0)),
($weight1, $crate::std_facade::Arc::new($item1))))
};
}};

($weight0:expr => $item0:expr,
$weight1:expr => $item1:expr,
$weight2:expr => $item2:expr $(,)?) => {
$weight2:expr => $item2:expr $(,)?) => {{
#[allow(clippy::arc_with_non_send_sync)]
$crate::strategy::TupleUnion::new(
(($weight0, $crate::std_facade::Arc::new($item0)),
($weight1, $crate::std_facade::Arc::new($item1)),
($weight2, $crate::std_facade::Arc::new($item2))))
};
}};

($weight0:expr => $item0:expr,
$weight1:expr => $item1:expr,
$weight2:expr => $item2:expr,
$weight3:expr => $item3:expr $(,)?) => {
$weight3:expr => $item3:expr $(,)?) => {{
#[allow(clippy::arc_with_non_send_sync)]
$crate::strategy::TupleUnion::new(
(($weight0, $crate::std_facade::Arc::new($item0)),
($weight1, $crate::std_facade::Arc::new($item1)),
($weight2, $crate::std_facade::Arc::new($item2)),
($weight3, $crate::std_facade::Arc::new($item3))))
};
}};

($weight0:expr => $item0:expr,
$weight1:expr => $item1:expr,
$weight2:expr => $item2:expr,
$weight3:expr => $item3:expr,
$weight4:expr => $item4:expr $(,)?) => {
$weight4:expr => $item4:expr $(,)?) => {{
#[allow(clippy::arc_with_non_send_sync)]
$crate::strategy::TupleUnion::new(
(($weight0, $crate::std_facade::Arc::new($item0)),
($weight1, $crate::std_facade::Arc::new($item1)),
($weight2, $crate::std_facade::Arc::new($item2)),
($weight3, $crate::std_facade::Arc::new($item3)),
($weight4, $crate::std_facade::Arc::new($item4))))
};
}};

($weight0:expr => $item0:expr,
$weight1:expr => $item1:expr,
$weight2:expr => $item2:expr,
$weight3:expr => $item3:expr,
$weight4:expr => $item4:expr,
$weight5:expr => $item5:expr $(,)?) => {
$weight5:expr => $item5:expr $(,)?) => {{
#[allow(clippy::arc_with_non_send_sync)]
$crate::strategy::TupleUnion::new(
(($weight0, $crate::std_facade::Arc::new($item0)),
($weight1, $crate::std_facade::Arc::new($item1)),
($weight2, $crate::std_facade::Arc::new($item2)),
($weight3, $crate::std_facade::Arc::new($item3)),
($weight4, $crate::std_facade::Arc::new($item4)),
($weight5, $crate::std_facade::Arc::new($item5))))
};
}};

($weight0:expr => $item0:expr,
$weight1:expr => $item1:expr,
$weight2:expr => $item2:expr,
$weight3:expr => $item3:expr,
$weight4:expr => $item4:expr,
$weight5:expr => $item5:expr,
$weight6:expr => $item6:expr $(,)?) => {
$weight6:expr => $item6:expr $(,)?) => {{
#[allow(clippy::arc_with_non_send_sync)]
$crate::strategy::TupleUnion::new(
(($weight0, $crate::std_facade::Arc::new($item0)),
($weight1, $crate::std_facade::Arc::new($item1)),
Expand All @@ -403,7 +416,7 @@ macro_rules! prop_oneof {
($weight4, $crate::std_facade::Arc::new($item4)),
($weight5, $crate::std_facade::Arc::new($item5)),
($weight6, $crate::std_facade::Arc::new($item6))))
};
}};

($weight0:expr => $item0:expr,
$weight1:expr => $item1:expr,
Expand All @@ -412,7 +425,8 @@ macro_rules! prop_oneof {
$weight4:expr => $item4:expr,
$weight5:expr => $item5:expr,
$weight6:expr => $item6:expr,
$weight7:expr => $item7:expr $(,)?) => {
$weight7:expr => $item7:expr $(,)?) => {{
#[allow(clippy::arc_with_non_send_sync)]
$crate::strategy::TupleUnion::new(
(($weight0, $crate::std_facade::Arc::new($item0)),
($weight1, $crate::std_facade::Arc::new($item1)),
Expand All @@ -422,7 +436,7 @@ macro_rules! prop_oneof {
($weight5, $crate::std_facade::Arc::new($item5)),
($weight6, $crate::std_facade::Arc::new($item6)),
($weight7, $crate::std_facade::Arc::new($item7))))
};
}};

($weight0:expr => $item0:expr,
$weight1:expr => $item1:expr,
Expand All @@ -432,7 +446,8 @@ macro_rules! prop_oneof {
$weight5:expr => $item5:expr,
$weight6:expr => $item6:expr,
$weight7:expr => $item7:expr,
$weight8:expr => $item8:expr $(,)?) => {
$weight8:expr => $item8:expr $(,)?) => {{
#[allow(clippy::arc_with_non_send_sync)]
$crate::strategy::TupleUnion::new(
(($weight0, $crate::std_facade::Arc::new($item0)),
($weight1, $crate::std_facade::Arc::new($item1)),
Expand All @@ -443,7 +458,7 @@ macro_rules! prop_oneof {
($weight6, $crate::std_facade::Arc::new($item6)),
($weight7, $crate::std_facade::Arc::new($item7)),
($weight8, $crate::std_facade::Arc::new($item8))))
};
}};

($weight0:expr => $item0:expr,
$weight1:expr => $item1:expr,
Expand All @@ -454,7 +469,8 @@ macro_rules! prop_oneof {
$weight6:expr => $item6:expr,
$weight7:expr => $item7:expr,
$weight8:expr => $item8:expr,
$weight9:expr => $item9:expr $(,)?) => {
$weight9:expr => $item9:expr $(,)?) => {{
#[allow(clippy::arc_with_non_send_sync)]
$crate::strategy::TupleUnion::new(
(($weight0, $crate::std_facade::Arc::new($item0)),
($weight1, $crate::std_facade::Arc::new($item1)),
Expand All @@ -466,7 +482,7 @@ macro_rules! prop_oneof {
($weight7, $crate::std_facade::Arc::new($item7)),
($weight8, $crate::std_facade::Arc::new($item8)),
($weight9, $crate::std_facade::Arc::new($item9))))
};
}};

($($weight:expr => $item:expr),+ $(,)?) => {
$crate::strategy::Union::new_weighted(vec![
Expand Down

0 comments on commit 466d59d

Please sign in to comment.