Skip to content

Commit

Permalink
Detect missing supertrait on serialize_trait_object calls
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 15, 2022
1 parent 76854cb commit 0b99efe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ macro_rules! __internal_serialize_trait_object {
$crate::__internal_serialize_trait_object!(impl ($($generics)*) ($($path)* + $crate::private::Send) ($($bound)*));
$crate::__internal_serialize_trait_object!(impl ($($generics)*) ($($path)* + $crate::private::Sync) ($($bound)*));
$crate::__internal_serialize_trait_object!(impl ($($generics)*) ($($path)* + $crate::private::Send + $crate::private::Sync) ($($bound)*));
const _: () = {
fn __check_erased_serialize_supertrait<__T, $($generics)*>()
where
__T: ?$crate::private::Sized + $($path)*,
$($bound)*
{
$crate::private::require_erased_serialize_impl::<__T>();
}
};
};

// The impl.
Expand Down
8 changes: 7 additions & 1 deletion src/private.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
//! Not public API. Used as `$crate::private` by macros.
pub use core::marker::{Send, Sync};
pub use core::marker::{Send, Sized, Sync};
pub use core::result::Result;
pub use serde;

pub fn require_erased_serialize_impl<T>()
where
T: ?Sized + crate::Serialize,
{
}

0 comments on commit 0b99efe

Please sign in to comment.