Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Tracking issue for trait alias implementation (RFC 1733) #55628

Open

Description

@nikomatsakis

This is the tracking issue for implementing (not discussing the design) RFC rust-lang/rfcs#1733. It is a subissue of #41517.

Current status

Once #55101 lands, many aspects of trait aliases will be implemented. However, some known limitations remain. These are mostly pre-existing limitations of the trait checker that we intend to lift more generally (see each case below for notes).

Well-formedness requirements. We currently require the trait alias to be well-formed. So, for example, trait Foo<T: Send> { } trait Bar<T> = Foo<T> is an error. We intend to modify this behavior as part of implementing the implied bounds RFC (#44491).

Trait object associated types. If you have trait Foo = Iterator<Item =u32>, you cannot use the trait object type dyn Foo. This is a duplicate of #24010.

Trait object equality. If you have trait Foo { } and trait Bar = Foo, we do not currently consider dyn Foo and dyn Bar to be the same type. Tracking issue #55629.

Pending issues to resolve

Deviations and/or clarifications from the RFC

This section is for us to collect notes on deviations from the RFC text, or clarifications to unresolved questions.

Implementation history

FIXME: This is most likely incomplete.

Other links

Activity

  1. alexreg commented on Nov 2, 2018

    @alexreg
    Contributor

    Good summary. Thanks for writing this up.

  2. eddyb commented on Nov 4, 2018

    @eddyb
    Contributor

    Have we considered blocking stabilization on lazy normalization?
    That is, I'm worried that these are equivalent problems:

    trait Foo<X> {}
    
    type Bar<X: ExtraBound> = dyn Foo<X>;
    fn bad<X>(_: &Bar<X>) {}
    
    trait Foo2<X: ExtraBound> = Foo<X>;
    fn bad2<X>(_: &dyn Foo2<X>) {}

    The alternative, to consider Foo2 its own trait, has its own issues, IMO.

  3. alexreg commented on Feb 28, 2019

    @alexreg
    Contributor

    @eddyb Actually, they're not, under the current implementation, which is nice. The X: ExtraBound bound is enforced. Example.

  4. alexreg commented on Feb 28, 2019

    @alexreg
    Contributor

    @nikomatsakis I just realised you never got around to factoring out the part of my old PR #55994 that banned multi-trait objects via trait aliases... did you still want to tackle that?

  5. added
    B-unstable
    B-RFC-implemented
    C-tracking-issue
    A-trait-system
    on Mar 23, 2019
  6. added
    S-tracking-needs-summary
    on Jun 24, 2022
  7. added
    S-types-deferred
    T-types
    and removed on Jul 15, 2022
  8. johnbchron commented on Sep 21, 2024

    @johnbchron

    5 years later and it would still be great to have.

    I was thinking; a number of the points of contention might be resolved if it's switched to operating purely in name resolution.

  9. added
    F-trait_alias
    on Apr 13, 2026
  10. added
    B-RFC-approved
    and removed
    B-RFC-implemented
    on Nov 18, 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-systemB-RFC-approvedB-unstableC-tracking-issueF-trait_aliasS-tracking-needs-summaryS-types-deferredT-types

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions