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

Cannot define the same inherent method in disjoint blocks #19097

Closed
aturon opened this issue Nov 19, 2014 · 3 comments · Fixed by #24236
Closed

Cannot define the same inherent method in disjoint blocks #19097

aturon opened this issue Nov 19, 2014 · 3 comments · Fixed by #24236
Labels
A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@aturon
Copy link
Member

aturon commented Nov 19, 2014

Currently, the following fails to compile:

struct Foo<T>;

impl<'a, T> Foo<&'a T> {
    fn foo(&self) {}
}
impl<'a, T> Foo<&'a mut T> {
    fn foo(&self) {}
}

The error:

<anon>:7:5: 7:21 error: duplicate definition of value `foo`
<anon>:7     fn foo(&self) {}
             ^~~~~~~~~~~~~~~~
<anon>:4:5: 4:21 note: first definition of value `foo` here
<anon>:4     fn foo(&self) {}
             ^~~~~~~~~~~~~~~~

If you construct an analogous situation using two separate impls of a trait providing foo, it works just fine, because there is no overlap. Inherent impl blocks could be similarly flexible.

@aturon
Copy link
Member Author

aturon commented Nov 19, 2014

cc @nikomatsakis

@reem
Copy link
Contributor

reem commented Nov 19, 2014

cc me

@bluss
Copy link
Member

bluss commented Apr 8, 2015

The example now compiles with struct Foo<T>(T);.

@sfackler sfackler added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 9, 2015
aturon added a commit to aturon/rust that referenced this issue Apr 9, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 10, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Apr 10, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Apr 10, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Apr 10, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 10, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 10, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 10, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 10, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 10, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Apr 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants