Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default impls cannot take into account associate types #52396

Open
Ericson2314 opened this issue Jul 15, 2018 · 0 comments
Open

Default impls cannot take into account associate types #52396

Ericson2314 opened this issue Jul 15, 2018 · 0 comments
Labels
A-specialization Area: Trait impl specialization C-bug Category: This is a bug. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@Ericson2314
Copy link
Contributor

Ericson2314 commented Jul 15, 2018

Suppose I have some trait with a default method:

trait Foo {
  fn bar(&self, isize) { .. }
}

and I want to add an associated type:

trait Foo {
  type Baz = isize;
  fn bar(&self, Baz);
}

This is a breaking change unless I move the old default method to a new default impl. But there is no way to condition the default impl on choice the choice of associated type. For example:

default impl<A: Foo<Baz = isze>> Foo for A {
  fn Bar(&self, isize) { .. }
}

is prohibited, and both

default impl<A> Foo for A {
  type Baz = isize;
  fn Bar(&self, Baz);
}

and

default impl<A> Foo for A {
  default type Baz = isize;
  fn Bar(&self, Baz);
}

do the wrong thing.

@kennytm kennytm added T-lang Relevant to the language team, which will review and decide on the PR/issue. A-specialization Area: Trait impl specialization labels Jul 16, 2018
@JohnTitor JohnTitor added the C-bug Category: This is a bug. label Nov 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-specialization Area: Trait impl specialization C-bug Category: This is a bug. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants