You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0277]: static assertion failed
--> tests/messages.rs:14:1
|
14 | assert_impl_one!(Foo: A, B, C);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `Foo` must implement exactly one of the given traits
| required by `_::{{closure}}#0::AmbiguousIfMoreThanOne::some_item`
|
= help: the trait `_::{{closure}}#0::AmbiguousIfMoreThanOne<_>` is not implemented for `Foo`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
This can be done like so (behind a nightly feature flag):
macro_rules! assert_impl_one {($x:ty: $($t:path),+ $(,)?) => {const _: fn() = || {
#[cfg_attr(
feature = "nightly",
rustc_on_unimplemented(
message = "static assertion failed",
label = "`{Self}` must implement exactly one of the given traits",
))]traitAmbiguousIfMoreThanOne<A> {// ...}// ...}};}
The text was updated successfully, but these errors were encountered:
By using
on_unimplemented
(tracking issue: rust-lang/rust#29628), custom error messages like the following can be emitted on assertion failure:This can be done like so (behind a
nightly
feature flag):The text was updated successfully, but these errors were encountered: