-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
impl Fn with generic associated type conflicts, succeeds with concrete type #40761
Comments
Minimized: trait Trait {}
trait Associate {
type Assoc;
}
impl<T> Trait for T {}
impl Trait for Associate<Assoc=()> {} // ok
impl<T> Trait for Associate<Assoc=T> {} // error |
Note that both are errors if the blanket impl is changed to |
Going off of what |
withoutboats just explained a bit of the It seems
All together this is pretty tricky to implement, especially because some struct
|
Indeed, this normally isn't what you would do -- you'd use a blanket impl (i.e. Aside from that, I still can't explain the discrepancy in this issue. It seems like once the associated type is made generic, the compiler doesn't realize that |
I'm having a little trouble following this issue. I believe that the bug here is that the following code isn't allowed due to conflicting implementations. However, that's confusing to me, because it seems that trait Trait {}
trait Associate {
type Assoc;
}
impl<T> Trait for T {}
//impl Trait for Associate<Assoc=()> {} // ok
impl<T> Trait for Associate<Assoc=T> {} // error |
Triage: this seems to be fixed now? The examples compile. |
Closing this as it is fixed now. |
Wasn't really sure how to describe this issue, please edit title if there's a better summary.
http://play.integer32.com/?gist=021df0320a79df0146121b59c61ec287&version=undefined
The above compiles, but if you comment out the
works
line and uncomment thefails
line (so there is only one impl ofFn
), the compiler will error with:I'm not clear why there seems to be an inconsistency here. There are a bunch of somewhat related issues to do with conflicts and associated types (#19032, #23341), but nothing that I can see that's directly relevant to this, where the two things being impl'd on are seemingly unrelated.
The text was updated successfully, but these errors were encountered: