-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from dtolnay/supertrait
Detect missing supertrait on serialize_trait_object calls
- Loading branch information
Showing
6 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[rustversion::attr(not(nightly), ignore)] | ||
#[cfg_attr(miri, ignore)] | ||
#[test] | ||
fn ui() { | ||
let t = trybuild::TestCases::new(); | ||
t.compile_fail("tests/ui/*.rs"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use erased_serde::serialize_trait_object; | ||
|
||
pub trait MyTrait {} | ||
|
||
serialize_trait_object!(MyTrait); | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0277]: the trait bound `__T: erased_serde::private::serde::Serialize` is not satisfied | ||
--> tests/ui/missing-supertrait.rs:5:1 | ||
| | ||
5 | serialize_trait_object!(MyTrait); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `erased_serde::private::serde::Serialize` is not implemented for `__T` | ||
| | ||
= note: required because of the requirements on the impl of `erased_serde::Serialize` for `__T` | ||
note: required by a bound in `require_erased_serialize_impl` | ||
--> src/private.rs | ||
| | ||
| T: ?Sized + crate::Serialize, | ||
| ^^^^^^^^^^^^^^^^ required by this bound in `require_erased_serialize_impl` | ||
= note: this error originates in the macro `$crate::__internal_serialize_trait_object` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider further restricting this bound | ||
| | ||
85| __T + erased_serde::private::serde::Serialize: ?$crate::private::Sized + $($path)*, | ||
| +++++++++++++++++++++++++++++++++++++++++ |