Skip to content

Tracking issue for allowing overlapping implementations for marker trait #29864

Open

Description

@nikomatsakis

Tracking issue for rust-lang/rfcs#1268.

Status

Known bugs

History

Prior to stabilization

  1. Is it ok that adding items to a previously empty trait is a breaking change? Should we make declaring something a marker trait more explicit somehow? --> resolved by adding explicit #[marker] annotation, see Support an explicit annotation for marker traits #53693

Other notes

In #96766 we decided NOT to disable the orphan check for marker traits as part of this work (just the overlap check), which was a proposed extension.

Activity

  1. added
    B-unstableBlocker: Implemented in the nightly compiler and unstable.
    T-langRelevant to the language team
    on Nov 18, 2015
  2. nikomatsakis commented on Nov 18, 2015

    @nikomatsakis
    ContributorAuthor

    With respect to the second question of whether we should make a more explicit notion of marker trait, I have been pondering this since the RFC discussion. On the one hand, there are a number of places in Rust today where going from nothing to something is a breaking change: adding a private field to a struct, for example.

    The difference here I think is that:

    1. Given the ability to specify defaults, adding an item to a trait does not necessarily have to be a breaking change otherwise (though methods and fns can cause new ambiguities etc).
    2. If there are impls that are taking advantage of the ability to overlap, there may just be no way to port older code forward, because it would require overlap.

    However, the second point depends a lot on the fate of specialization. If we wind up adopting specialization, and in particular a model that does not require strict subsets, then it would still be possible to adapt existing impls. This makes me a lot less worried. Of course, implementing that form of specialization is tricky, but not (I don't think...) that much trickier than implementing THIS suggestion. The hard part in both cases is the potential for overlap.

  3. added
    B-RFC-implementedBlocker: Approved by a merged RFC and implemented but not stabilized.
    on Aug 29, 2016
  4. sgrif commented on Nov 15, 2016

    @sgrif
    Contributor

    @nrc This has the RFC implemented label, but I don't think it has been. If it has, is there a feature gate that I'm missing? If it hasn't been implemented, is there anything I can do to help push this along? It's now been a year since the RFC was accepted.

  5. added
    B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.
    and removed
    B-RFC-implementedBlocker: Approved by a merged RFC and implemented but not stabilized.
    on Nov 15, 2016
  6. nikomatsakis commented on Nov 15, 2016

    @nikomatsakis
    ContributorAuthor

    @sgrif swapped labels

  7. 78 remaining items

  8. nikomatsakis commented on Dec 26, 2024

    @nikomatsakis
    ContributorAuthor

    I'm nominating this to @rust-lang/lang and @rust-lang/types ---

    I'd like to get a temperature check on this feature. Quick summary is that it lets you put #[marker] on a trait and then permit overlap.

    From lang, I'm curious as to whether folks still think this is desirable. (I do, though I'm potentially open to bike-shedding on the details -- but this precise scenario comes up all the time.)

    From types, I'm curious as to whether folks are aware of impl problems, how this fits with the new solver, etc. Seems like a great candidate to target with a-mir-formality and spec work for testing out a new process.

    @rustbot labels +I-lang-nominated +I-types-nominated

  9. added
    I-lang-nominatedNominated for discussion during a lang team meeting.
    I-types-nominatedNominated for discussion during a types team meeting.
    on Dec 26, 2024
  10. added
    T-typesRelevant to the types team, which will review and decide on the PR/issue.
    on Dec 26, 2024
  11. scottmcm commented on Jan 8, 2025

    @scottmcm
    Member

    I think it goes particularly well with rust-lang/rfcs#3678, since then #[marker] traits could have methods so long as they're final fn.

    That would allow, for example,

    #[marker]
    trait Copy : Clone {
        #[final]
        fn copy(&self) -> Self { *self }
    }
  12. traviscross commented on Jan 8, 2025

    @traviscross
    Contributor

    @rustbot labels -I-lang-nominated

    We talked about this during our lang day in December, and we touched on it briefly again today. We're feeling favorably toward allowing overlap on marker traits that are explicitly designated, and are looking forward to seeing concrete next steps on this nominated for us.

  13. removed
    I-lang-nominatedNominated for discussion during a lang team meeting.
    on Jan 8, 2025
  14. BoxyUwU commented on Jan 8, 2025

    @BoxyUwU
    Member

    This was discussed a bit in the T-types/nominated zulip stream. A proper implementation of this feature needs OR region constraints and is blocked on -Znext-solver everywhere

  15. added
    S-tracking-blockedStatus: This tracking issue is blocked on another tracking issue
    and removed
    I-types-nominatedNominated for discussion during a types team meeting.
    on Jan 8, 2025
  16. added 3 commits that reference this issue on Aug 24, 2026
  17. added a commit that references this issue on Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemB-RFC-implementedBlocker: Approved by a merged RFC and implemented but not stabilized.B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-marker_trait_attr`#![feature(marker_trait_attr)]`S-tracking-blockedStatus: This tracking issue is blocked on another tracking issueS-tracking-needs-to-bakeStatus: The implementation is "complete" but it needs time to bake.T-langRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions