Skip to content

Tracking issue for 'Allow Self to appear in the where clause of trait impls' #38864

Closed

Description

@nrc

RFC: https://github.com/rust-lang/rfcs/blob/master/text/1647-allow-self-in-where-clauses.md

RFC PR: rust-lang/rfcs#1647

Proposes allowing the Self type to be used in every position in trait implementations, including where clauses and other parameters to the trait being implemented.

Activity

  1. added
    B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.
    B-unstableBlocker: Implemented in the nightly compiler and unstable.
    T-langRelevant to the language team
    on Jan 6, 2017
  2. added a commit that references this issue on Jan 25, 2017
  3. added 8 commits that reference this issue on Feb 25, 2017
  4. sgrif commented on Apr 30, 2017

    @sgrif
    Contributor

    The RFC still isn't fully implemented. In particular, this example from the RFC text still fails to compile:

    impl SomeTrait for SomeType where Self::AssocType: SomeOtherTrait {
        type AssocType = SomeOtherType;
    }
  5. eddyb commented on Apr 30, 2017

    @eddyb
    Contributor

    @sgrif What's the error?

  6. Mark-Simulacrum commented on Apr 30, 2017

    @Mark-Simulacrum
    Member

    https://is.gd/amqdSq:

    struct SomeType;
    struct SomeOtherType;
    
    trait SomeTrait {
        type AssocType;
    }
    trait SomeOtherTrait {}
    
    impl SomeTrait for SomeType where Self::AssocType: SomeOtherTrait {
        type AssocType = SomeOtherType;
    }
    fn main() {}
    rustc 1.19.0-nightly (afa1240e5 2017-04-29)
    error[E0275]: overflow evaluating the requirement `<SomeType as SomeTrait>::AssocType`
     --> <anon>:9:6
      |
    9 | impl SomeTrait for SomeType where Self::AssocType: SomeOtherTrait {
      |      ^^^^^^^^^
      |
      = note: required because of the requirements on the impl of `SomeTrait` for `SomeType`
    
    error: aborting due to previous error
    
  7. eddyb commented on Apr 30, 2017

    @eddyb
    Contributor

    Ah that's not part of the actual syntactical support (which works!), but rather the trait system.
    You can reproduce by expanding Self::AssocType to <SomeType as SomeTrait>::AssocType.
    This looks like it was overlooked in the RFC, and I'd suggest opening a separate issue.
    I suppose we can keep this one open and depend on that issue but they're unrelated IMO.
    cc @rust-lang/lang

  8. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Jul 22, 2017
  9. steveklabnik commented on Mar 12, 2019

    @steveklabnik
    Contributor

    According to the last comment here, it seems like maybe this is finished?

  10. sgrif commented on Mar 12, 2019

    @sgrif
    Contributor

    The issue I raised still exists. I'm not sure how it was overlooked in the RFC, the example given from the RFC itself, and the text explicitly states that we'd like to be able to reference associated types from the trait being implemented. I agree that this is a fix that needs to happen in the trait system, not just syntactic support, but it is something the RFC calls out explicitly multiple times.

  11. petrochenkov commented on Mar 12, 2019

    @petrochenkov
    Contributor

    Could you open a separate ticket please, focused on that specific bug?
    This is a tracking issue for the feature in general, and the feature in general was implemented and stabilized.

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-approvedBlocker: Approved by a merged RFC but not yet implemented.B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-langRelevant to the language team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions