Conflicting implementations of a marker trait

In my project I have a marker trait called Share, which has no associated items. Therefor, two implementations cannot conflict because the trait contains not data that can conflict. Is there any way to tell the rust compiler that the implementations of the trait do not conflict, even if it seems they do?


There is the unstable #[marker] attribute you can apply to the trait. There are still some outstanding bugs with it though: Tracking issue for allowing overlapping implementations for marker trait · Issue #29864 · rust-lang/rust · GitHub

1 Like

You may be looking for how to use Share to specialize, you can do this using min_specialization and the #[rustc_specialization_trait] attribute, however as hinted at by the "rustc" this is a compiler internal attribute and is unstable.

There's no guarantee that the trait won't get methods in the future, though, which is why this is blocked.

(Without #[marker] that bjorn3 mentions, as that promises it won't get any overridable methods.)


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.